-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (157 loc) · 4.53 KB
/
ci.yml
File metadata and controls
177 lines (157 loc) · 4.53 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: CI Baseline
on:
pull_request:
paths:
- "src/**"
- "tests/**"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/ci.yml"
- "**/*.md"
- "**/*.json"
- "**/*.yml"
- "**/*.yaml"
- "**/*.sh"
- ".pre-commit-config.yaml"
- ".yamllint"
- ".markdownlint.jsonc"
push:
branches:
- main
- "release/**"
paths:
- "src/**"
- "tests/**"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/ci.yml"
- "**/*.md"
- "**/*.json"
- "**/*.yml"
- "**/*.yaml"
- "**/*.sh"
- ".pre-commit-config.yaml"
- ".yamllint"
- ".markdownlint.jsonc"
permissions:
contents: read
pull-requests: read
concurrency:
group: ci-baseline-${{ github.ref }}
cancel-in-progress: true
env:
# Force JS actions onto Node 24 ahead of the June 2026 GHA default flip.
# Several third-party actions still target Node 20; remove this once the
# ecosystem fully catches up.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
# Pin pre-commit so CI matches what devs run locally. Bump alongside
# repo conventions.
PRE_COMMIT_VERSION: "4.5.1"
jobs:
changes:
name: Detect changed scopes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
src: ${{ steps.filter.outputs.src }}
shell: ${{ steps.filter.outputs.shell }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Evaluate changed paths
id: filter
uses: dorny/paths-filter@6852f92c20ea7fd3b0c25de3b5112db3a98da050 # v3
with:
token: ""
list-files: csv
filters: |
src:
- "src/**"
- "tests/**"
- "pyproject.toml"
- "uv.lock"
- ".github/workflows/ci.yml"
shell:
- "**/*.sh"
- ".github/workflows/ci.yml"
pre-commit-quality-gates:
name: Pre-commit quality gates
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Cache pre-commit environments
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Install pre-commit
run: python -m pip install "pre-commit==${{ env.PRE_COMMIT_VERSION }}"
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure
python-tests:
name: Python tests (${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
needs: changes
if: needs.changes.outputs.src == 'true'
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
cache-dependency-glob: "**/uv.lock"
- name: Install dependencies
run: |
uv sync --group dev --group test
uv pip install pytest-cov
- name: Run pytest with coverage
run: |
uv run pytest -q \
--cov=src --cov-report=term-missing --cov-report=xml
- name: Upload coverage XML
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}
path: coverage.xml
if-no-files-found: warn
shell-script-sanity:
name: Shell script sanity
runs-on: ubuntu-latest
timeout-minutes: 5
needs: changes
if: needs.changes.outputs.shell == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Install ShellCheck
run: sudo apt-get update && sudo apt-get install --yes shellcheck
- name: Run ShellCheck
run: |
mapfile -t shell_files < <(git ls-files '*.sh')
if [ "${#shell_files[@]}" -eq 0 ]; then
echo "No shell scripts found."
exit 0
fi
shellcheck "${shell_files[@]}"