Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: "CodeQL"

on:
push:
branches: [ main, develop ]
branches: [main, develop]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main, develop ]
branches: [main, develop]
schedule:
- cron: '34 21 * * 1'

Expand All @@ -17,40 +17,40 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
language: ['python']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
31 changes: 14 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ on:
# normal behavior: run when a new release is created
release:
types: [published]
# allow running manually on main
workflow_dispatch:
branches: [main]

permissions:
contents: read
Expand All @@ -27,19 +24,19 @@ jobs:
name: pypi
url: https://pypi.org/project/viapy/
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
22 changes: 10 additions & 12 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: unit tests
on:
push: # run on all branches
pull_request:
- branches: [develop, main]
branches: [develop, main]
schedule: # run automatically on main branch each Tuesday at 11am
- cron: "0 16 * * 2"

Expand All @@ -20,25 +20,23 @@ jobs:
uses: actions/checkout@v6

- name: Install uv and Python version
uses: astral-sh/setup@v7
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python }}

- name: Install package dependencies
run: |
{
if [ "${{ matrix.django }}" -gt "0" ]
then
uv add django==${{ matrix.django }}
uv sync --extra test --extra django_test
else
uv sync --extra test
}
run: >-
if [ "${{ matrix.django }}" -gt "0" ]; then
uv add django=="${{ matrix.django }}";
uv sync --extra test --extra django_test;
else
uv sync --extra test;
fi

- name: Setup test settings
run: |
cp ci/testsettings.py testsettings.py
python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> testsettings.py
uv run python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> testsettings.py

- name: Run pytest
run: uv run pytest --cov=viapy --cov=tests --cov-report=xml --cov-report=term
Expand Down
55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This config file specifies which pre-commit hooks to run.
#
# To set up, run `pre-commit install`
# To run all hooks manually, run `pre-commit run --all-files`
repos:
# Ruff Python linter and formatter (configs in pyproject.toml)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
hooks:
# Run the linter
- id: ruff-check
args: [--fix, --show-fixes] # enable lint fixes
# Run the formatter
- id: ruff-format
# yamlfmt for formatting YAML files
- repo: https://github.com/google/yamlfmt
rev: v0.17.2
hooks:
- id: yamlfmt
# Codespell for spell checking
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
- tomli
exclude_types: ["css", "html", "javascript", "json"]
# Some out-of-the-box file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# Check for files with merge conflict strings
- id: check-merge-conflict
# Verify syntax of TOML files
- id: check-toml
# Verify syntax of YAML files
- id: check-yaml
args: [--unsafe]
# Verifies that test files begin with test_
- id: name-tests-test
args: [--pytest-test-first]
# Removes trailing whitespace from all files
- id: trailing-whitespace
exclude: "docs/"
# Check uv.lock file is up to date
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.8.6
hooks:
- id: uv-lock
# Validate GitHub Actions workflow files
- repo: https://github.com/mpalmer/action-validator
rev: v0.8.0
hooks:
- id: action-validator
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CHANGELOG
* Handle negative years when parsing birth and death dates
* Now tested on python 3.9 through 3.12
* Now tested against Django 3.2 through 5.0
* Migrate continous integration to GitHub Actions
* Migrate continuous integration to GitHub Actions

0.2
---
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ django-autocomplete-light lookup view and a VIAF url widget.

.. image:: https://codecov.io/gh/Princeton-CDH/viapy/branch/master/graph/badge.svg
:target: https://codecov.io/gh/Princeton-CDH/viapy/branch/master
:alt: Code coverage
:alt: Code coverage

.. image:: https://www.codefactor.io/repository/github/princeton-cdh/viapy/badge
:target: https://www.codefactor.io/repository/github/princeton-cdh/viapy
:alt: CodeFactor

.. image:: https://img.shields.io/pypi/pyversions/viapy
:alt: PyPI - Python Version

.. image:: https://img.shields.io/pypi/djversions/viapy
:alt: PyPI - Django Version

Expand Down Expand Up @@ -80,7 +80,7 @@ and a tool of your choice for creating python virtual environments

Initial setup and installation:

* Install ``uv`` if it's not installed.
* Install ``uv`` if it's not installed.
It can be installed via PyPi, Homebrew, or a standalone installer.
See uv's `installation documentation <https://docs.astral.sh/uv/getting-started/installation>`_
for more details.
Expand Down
11 changes: 5 additions & 6 deletions ci/testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@

INSTALLED_APPS = (
# 'django.contrib.contenttypes',
'dal',
'dal_select2',
'viapy',
"dal",
"dal_select2",
"viapy",
)

ROOT_URLCONF = 'viapy.test_urls'
ROOT_URLCONF = "viapy.test_urls"

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

# must be added
# SECRET_KEY = ''

27 changes: 25 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ django = ["django>=3.2", "django-autocomplete-light"]
django_test = ["pytest-django", "viapy[django]"]
docs = ["sphinx"]
test_all = ["viapy[test]", "viapy[django_test]"]
dev = ["pre-commit", "viapy[django]", "viapy[test_all]", "viapy[docs]"]
dev = [
"ruff",
"pre-commit",
"viapy[django]",
"viapy[test_all]",
"viapy[docs]"
]

[dependency-groups]
dev = ["viapy[dev]"]

[tool.pytest]
[tool.pytest.ini_options]
# Need to use ini_options for Python 3.9
testpaths = ["tests"]
pythonpath = ["."]
DJANGO_SETTINGS_MODULE = "testsettings"
Expand All @@ -80,3 +87,19 @@ exclude_lines = [

[tool.coverage.html]
directory = "coverage_html_report"

[tool.ruff.lint]
# Include these rules in addition to ruff's defaults
extend-select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"I", #isort
"NPY", # numpy-specific rules
"PERF", # perflint
"PTH", # flake8-use-pathlib
"RUF", # ruff-specific rules
"SIM", # flake8-simplify
"UP", # pyupgrade
]
# Can use to ignore specific rules within above selection
ignore = []
15 changes: 8 additions & 7 deletions sphinx-docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# viapy documentation build configuration file, created by
# sphinx-quickstart on Thu Oct 12 17:06:23 2017.
Expand All @@ -15,23 +14,25 @@

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# documentation root, use pathlib.Path.resolve to make it absolute, like shown here.
#
# import os
# import pathlib
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, pathlib.Path().resolve())

import os
import pathlib
import sys

import django

sys.path.insert(0, os.path.abspath("."))
from viapy import __version__

sys.path.insert(0, pathlib.Path().resolve())

os.environ["DJANGO_SETTINGS_MODULE"] = "docsettings"
django.setup()

from viapy import __version__


# -- General configuration ------------------------------------------------

Expand Down
13 changes: 6 additions & 7 deletions sphinx-docs/docsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

INSTALLED_APPS = (
# 'django.contrib.contenttypes',
'dal',
'dal_select2',
'viapy',
"dal",
"dal_select2",
"viapy",
)

ROOT_URLCONF = 'viapy.test_urls'
ROOT_URLCONF = "viapy.test_urls"

LANGUAGE_CODE = 'en-us'

SECRET_KEY = 'f$J4FB3B=}1bFtJ$}b9s28Vsf?&otV}o0*V)g;#OD5%20uksel'
LANGUAGE_CODE = "en-us"

SECRET_KEY = "f$J4FB3B=}1bFtJ$}b9s28Vsf?&otV}o0*V)g;#OD5%20uksel"
Loading
Loading