Skip to content

Commit 111670b

Browse files
committed
Enable pre-commit & add workflow hook
1 parent b89fa6b commit 111670b

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: unit tests
2+
3+
on:
4+
push: # run on every push or PR to any branch
5+
pull_request:
6+
schedule: # run automatically on main branch each Tuesday at 11am
7+
- cron: "0 16 * * 2"
8+
9+
jobs:
10+
python-unit:
11+
name: Python unit tests
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
django: ["4.0", "4.1", "4.2", "5.0", "5.1"]
17+
exclude:
18+
# django 5.0 and 5.1 require python 3.10 minimum
19+
- python: "3.9"
20+
django: 5.0
21+
- python: "3.9"
22+
django: 5.1
23+
# django 4.0 only goes up to python 3.10
24+
- python: "3.11"
25+
django: 4.0
26+
- python: "3.12"
27+
django: 4.0
28+
- python: "3.13"
29+
django: 4.0
30+
# django 4.1 only goes up to python 3.11
31+
- python: "3.12"
32+
django: 4.1
33+
- python: "3.13"
34+
django: 4.1
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Python
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python }}
43+
44+
# Base python cache on the hash of test requirements file
45+
# if the file changes, the cache is invalidated.
46+
- name: Cache pip
47+
uses: actions/cache@v4
48+
with:
49+
path: ~/.cache/pip
50+
key: pip-${{ hashFiles('requirements-test.txt') }}
51+
restore-keys: |
52+
pip-${{ hashFiles('requirements-test.txt') }}
53+
54+
- name: Install package with dependencies
55+
run: |
56+
pip install -q Django==${{ matrix.django }}
57+
pip install -r requirements-test.txt
58+
59+
- name: Run python tests
60+
run: python tests/run_tests.py

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
exclude: ".*/vendor/.*"
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-added-large-files
7+
args: ["--maxkb=128"]
8+
- id: check-ast
9+
- id: check-byte-order-marker
10+
- id: check-case-conflict
11+
- id: check-docstring-first
12+
- id: check-executables-have-shebangs
13+
- id: check-json
14+
- id: check-merge-conflict
15+
- id: check-symlinks
16+
- id: check-toml
17+
- id: check-xml
18+
- id: check-yaml
19+
- id: debug-statements
20+
- id: detect-private-key
21+
- id: end-of-file-fixer
22+
- id: mixed-line-ending
23+
args: ["--fix=lf"]
24+
- id: pretty-format-json
25+
args: ["--autofix", "--no-sort-keys", "--indent=4"]
26+
- id: trailing-whitespace
27+
28+
- repo: https://github.com/executablebooks/mdformat
29+
rev: 0.7.22
30+
hooks:
31+
- id: mdformat
32+
additional_dependencies:
33+
- mdformat-gfm
34+
35+
- repo: https://github.com/gruntwork-io/pre-commit
36+
rev: v0.1.29
37+
hooks:
38+
- id: shellcheck
39+
40+
- repo: https://github.com/astral-sh/ruff-pre-commit
41+
rev: v0.11.10
42+
hooks:
43+
- id: ruff-check
44+
args: ["--fix", "--exit-non-zero-on-fix"]
45+
- id: ruff-format

0 commit comments

Comments
 (0)