Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
113 lines (96 loc) · 4.45 KB
/
Copy pathjustfile
File metadata and controls
113 lines (96 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Keep in sync with just-version in .github/workflows/ci.yml
set minimum-version := '1.55.0'
mod pdc 'just/pdc.just'
python := shell("cat .python-version")
_default:
@just --list --unsorted
# Lint and check formatting
[group('dev')]
lint:
uv run ruff check .
uv run ruff format . --check
# Format and autofix lint issues
[group('dev')]
format:
uv run ruff format .
uv run ruff check . --fix
# Audit GitHub Actions workflows with zizmor (passes through args)
[group('dev')]
zizmor *args:
uvx --exclude-newer "7 days" zizmor .github/ {{args}}
# Run all three type checkers, failing at the end if any failed
[group('dev')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
typecheck python=python lowest_direct="false":
#!/usr/bin/env bash
status=0
for checker in mypy pyrefly ty; do
{{just_executable()}} typecheck-$checker --python={{python}} \
{{ if lowest_direct == "true" { "--lowest-direct" } else { "" } }} || status=1
done
exit $status
# Type check the package and tests with mypy, then the package in strict mode
[group('dev')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
typecheck-mypy python=python lowest_direct="false":
#!/usr/bin/env bash
status=0
{{just_executable()}} _typecheck {{python}} {{lowest_direct}} mypy || status=1
{{just_executable()}} _typecheck {{python}} {{lowest_direct}} mypy --strict src || status=1
exit $status
# Type check the package and tests with pyrefly
[group('dev')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
typecheck-pyrefly python=python lowest_direct="false" *args: (_typecheck python lowest_direct "pyrefly check" args)
# Type check the package and tests with ty
[group('dev')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
typecheck-ty python=python lowest_direct="false" *args: (_typecheck python lowest_direct "ty check" args)
# Run the unit tests against the installed package
[group('test')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
[arg("upgrade", long, value="true")]
test python=python lowest_direct="false" upgrade="false" *args: (_pytest python lowest_direct upgrade args)
# Run the integration tests against the installed package and a live PDC stack (run `just pdc up` first)
[group('test')]
[arg("python", long)]
[arg("lowest_direct", long="lowest-direct", value="true")]
[arg("upgrade", long, value="true")]
integration python=python lowest_direct="false" upgrade="false" *args: (_pytest python lowest_direct upgrade "integration_tests/ " + args)
_typecheck python lowest_direct tool *args:
uv run --python={{python}} {{ if lowest_direct == "true" { "--resolution=lowest-direct" } else { "" } }} --isolated --no-dev --group tests --group typecheck -- \
{{tool}} --python-version={{python}} {{args}}
_pytest python lowest_direct upgrade *args:
@if [ "{{upgrade}}" = "true" ]; then uv lock --upgrade --dry-run; fi
uv run --python={{python}} \
{{ if lowest_direct == "true" { "--resolution=lowest-direct" } else { "" } }} \
{{ if upgrade == "true" { "--upgrade" } else { "" } }} \
--isolated --no-editable --no-dev --group tests --reinstall -- \
python -I -m pytest {{args}}
# Run lint, type checks, unit tests, and integration tests (run `just pdc up` first)
[group('test')]
check: lint typecheck test integration
# Download the current PDC OpenAPI spec
[group('codegen')]
update-api-spec:
curl -fsSL https://api.philanthropydatacommons.org/openapi/api.json -o src/pdc_api/openapi.json
uv run python -c "import json; json.load(open('src/pdc_api/openapi.json'))"
# Regenerate src/pdc_api/_generated.py from src/pdc_api/openapi.json
[group('codegen')]
codegen:
uv run python codegen/preprocess.py src/pdc_api/openapi.json codegen/openapi.preprocessed.json
uv run datamodel-codegen \
--input codegen/openapi.preprocessed.json --input-file-type openapi \
--output src/pdc_api/_generated.py \
--output-model-type pydantic_v2.BaseModel \
--base-class pdc_api._base.BaseSchema \
--snake-case-field --use-annotated --use-standard-collections --use-union-operator \
--collapse-root-models --capitalise-enum-members --target-python-version 3.12 --disable-timestamp \
--formatters ruff-format ruff-check
uv run python codegen/postprocess.py src/pdc_api/_generated.py
uv run ruff format src/pdc_api/_generated.py