-
Notifications
You must be signed in to change notification settings - Fork 2
210 lines (189 loc) · 7.6 KB
/
Copy pathci.yml
File metadata and controls
210 lines (189 loc) · 7.6 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
name: CI
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash
env:
FORCE_COLOR: "1"
jobs:
validate:
name: Validate (Ubuntu, Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- python-version: "3.12"
primary: true
- python-version: "3.13"
primary: false
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Restore pip cache
uses: actions/cache@v5
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt', 'pyproject.toml') }}
restore-keys: |
pip-${{ runner.os }}-py${{ matrix.python-version }}-
pip-${{ runner.os }}-
- name: Install system dependencies (wxPython runtime + xvfb for headless)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libgtk-3-dev \
libnotify-dev \
libsdl2-dev \
libwebkit2gtk-4.1-dev \
freeglut3-dev \
xvfb
- name: Ruff (format check + lint)
if: matrix.primary
# Collapsed from two astral-sh/ruff-action invocations into one
# inline step. Each action invocation carried ~5s of composite-
# action boot overhead; running both commands in a single step
# against a pip-installed ruff (tiny wheel, cached by the
# explicit pip cache) saves ~10s per CI run while keeping
# the same fail-before-install-deps ordering.
run: |
pip install --quiet 'ruff>=0.15.14'
ruff format --check .
ruff check .
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Unit tests use in-repo stubs for wx and sound_lib when
# those GUI/audio runtime packages are unavailable.
# Keep CI validation independent from extras.wxpython.org wheel availability;
# packaging workflows still install real wxPython for build artifacts.
python - <<'PY'
from pathlib import Path
runtime_stubs = ("wxpython", "sound_lib @")
filters = {
"requirements.txt": Path("/tmp/requirements-ci.txt"),
"requirements-dev.txt": Path("/tmp/requirements-dev-ci.txt"),
}
for source, target in filters.items():
kept = []
for line in Path(source).read_text(encoding="utf-8").splitlines():
stripped = line.strip().lower()
if stripped == "-r requirements.txt" or stripped.startswith(runtime_stubs):
continue
kept.append(line)
target.write_text("\n".join(kept) + "\n", encoding="utf-8")
PY
pip install -r /tmp/requirements-ci.txt
pip install -r /tmp/requirements-dev-ci.txt
pip install --no-deps -e .
- name: Check CHANGELOG entry
# Skipped when a PR carries the `skip-changelog` label. For non-PR events
# the labels expression is null (contains() returns false), so pushes
# still run the gate and rely on a `Changelog: none` commit trailer.
if: matrix.primary && !contains(github.event.pull_request.labels.*.name, 'skip-changelog')
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE="origin/${{ github.base_ref }}"
git fetch --no-tags --depth=1 origin "${{ github.base_ref }}:${BASE}" || true
echo "PR detected - checking changelog entries against $BASE"
elif [ "${{ github.event_name }}" = "push" ] && [ -n "${{ github.event.before }}" ] && [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
BASE="${{ github.event.before }}"
git fetch --no-tags origin "$BASE" || true
echo "Push detected - checking changelog entries against $BASE"
else
BASE="HEAD~1"
echo "Manual run detected - checking changelog entries against $BASE"
fi
if ! python scripts/changelog_tools.py check --base "$BASE" --head HEAD; then
{
echo "### CHANGELOG gate"
echo
echo "User-facing changes need a curated \`CHANGELOG.md\` entry under \`## [Unreleased]\`."
echo "This keeps nightly and stable release notes based on product wording instead of PR titles."
} >> "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Run tests (headless via xvfb)
timeout-minutes: 15
env:
PYTHONPATH: src
ACCESSIWEATHER_TEST_MODE: "1"
HYPOTHESIS_PROFILE: ci
run: |
if [ "${{ matrix.primary }}" = "true" ]; then
mkdir -p reports
xvfb-run -a pytest tests/ \
--ignore=tests/test_alert_dialog_copy_integration.py \
--ignore=tests/test_alert_dialog_dispatch.py \
-n 8 --dist=loadgroup -v --tb=short -m "not integration" \
--cov=src/accessiweather \
--cov-report=
xvfb-run -a pytest \
tests/test_alert_dialog_copy_integration.py \
tests/test_alert_dialog_dispatch.py \
-n 0 -v --tb=short -m "not integration" \
--cov=src/accessiweather \
--cov-append \
--cov-report=xml:reports/coverage.xml \
--cov-report=term-missing
else
xvfb-run -a pytest tests/ \
--ignore=tests/test_alert_dialog_copy_integration.py \
--ignore=tests/test_alert_dialog_dispatch.py \
-n 8 --dist=loadgroup -v --tb=short -m "not integration"
xvfb-run -a pytest \
tests/test_alert_dialog_copy_integration.py \
tests/test_alert_dialog_dispatch.py \
-n 0 -v --tb=short -m "not integration"
fi
- name: Run integration tests (cassette replay)
if: matrix.primary
timeout-minutes: 10
env:
PYTHONPATH: src
ACCESSIWEATHER_TEST_MODE: "1"
HYPOTHESIS_PROFILE: ci
VCR_RECORD_MODE: "none"
run: |
xvfb-run -a pytest tests/integration/ \
-n 0 -v --tb=short --record-mode=none
- name: Install diff-cover
if: matrix.primary && github.event_name == 'pull_request'
run: pip install diff-cover>=9.0.0
- name: Coverage gate
if: matrix.primary && github.event_name == 'pull_request'
env:
HEAD_REF: ${{ github.head_ref }}
run: |
if [[ "$HEAD_REF" == refactor/* ]]; then
echo "Refactor PR branch detected; skipping diff coverage gate for mechanical code movement."
exit 0
fi
BASE="origin/${{ github.base_ref }}"
CHANGED_SRC=$(git diff --name-only "$BASE"..HEAD | grep '^src/' || true)
NON_EXCLUDED_CHANGED=$(echo "$CHANGED_SRC" | grep -Ev '^src/accessiweather/ui/|^src/accessiweather/notifications/toast_notifier.py$|^src/weather_gov_api_client/' || true)
if [ -z "$NON_EXCLUDED_CHANGED" ]; then
echo "No non-excluded src/ changes to gate. Skipping diff coverage gate."
exit 0
fi
diff-cover reports/coverage.xml \
--compare-branch="$BASE" \
--fail-under=80 \
--diff-range-notation='..' \
--exclude '*/accessiweather/ui/*'
echo "New code meets coverage threshold."