Repository navigation
110 lines (101 loc) · 3.25 KB
/
Copy pathpython-test.yml
File metadata and controls
110 lines (101 loc) · 3.25 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
name: Python test (reusable)
on:
workflow_call:
inputs:
python-version:
type: string
default: "3.14"
working-dir:
type: string
default: "."
requirements:
description: Path to runtime requirements file (skipped if file is missing)
type: string
default: requirements.txt
dev-requirements:
description: Path to dev/test requirements file (skipped if file is missing)
type: string
default: requirements-dev.txt
lint-paths:
description: Space-separated paths passed to `ruff check`
type: string
default: "src/ tests/"
test-paths:
description: Space-separated paths passed to `pytest`
type: string
default: "tests/"
run-lint:
type: boolean
default: true
run-format-check:
type: boolean
default: true
run-tests:
type: boolean
default: true
run-mypy:
description: |
Run `mypy` against `mypy-paths`. Defaults off because mypy is not
universal — opt in per-repo when the project has it configured.
mypy must be installed via the dev requirements.
type: boolean
default: false
mypy-paths:
description: Paths passed to `mypy`
type: string
default: "src/"
runner:
description: |
Runner label for this job. Defaults to `ubuntu-latest` (GitHub-hosted);
since v8 that is the default for every `runner` input here, where it
used to be an `arc-*` scale set. Pass a self-hosted scale-set label
(e.g. `arc-df-uninsta`) only for a job that genuinely needs the
cluster — `deploy-k8s.yml` and `deploy-helm.yml` are the two that
always will. A default is not a migration: a caller that passes a
label keeps its pool, this repo's own shims included.
type: string
default: "ubuntu-latest"
permissions:
contents: read
jobs:
test:
runs-on: ${{ inputs.runner }}
permissions:
contents: read
defaults:
run:
working-directory: ${{ inputs.working-dir }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ inputs.python-version }}
cache: pip
- name: Install dependencies
env:
REQ: ${{ inputs.requirements }}
DEV: ${{ inputs.dev-requirements }}
run: |
python -m pip install --upgrade pip
if [ -f "$REQ" ]; then
pip install -r "$REQ"
else
echo "::notice::No $REQ found, skipping runtime requirements install"
fi
if [ -f "$DEV" ]; then
pip install -r "$DEV"
else
echo "::notice::No $DEV found, skipping dev requirements install"
fi
- if: inputs.run-lint
name: ruff check
run: ruff check ${{ inputs.lint-paths }}
- if: inputs.run-format-check
name: ruff format --check
run: ruff format --check ${{ inputs.lint-paths }}
- if: inputs.run-mypy
name: mypy
run: mypy ${{ inputs.mypy-paths }}
- if: inputs.run-tests
name: pytest
run: pytest ${{ inputs.test-paths }}