-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (167 loc) · 7.24 KB
/
Copy pathsmoke-tests.yml
File metadata and controls
178 lines (167 loc) · 7.24 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
name: Smoke Tests (reusable)
# Heart-owned reusable smoke-test workflow for the PyAuto workspaces.
# Each workspace's .github/workflows/smoke_tests.yml is a thin caller:
#
# jobs:
# smoke:
# uses: PyAutoLabs/PyAutoHeart/.github/workflows/smoke-tests.yml@main
# with: { chain: "PyAutoNerves PyAutoFit PyAutoArray PyAutoGalaxy PyAutoLens" }
# secrets: inherit
#
# The workflow owns the ceremony (dependency-chain checkout at the matching
# branch, python setup, cache dirs, running the workspace's own
# .github/scripts/run_smoke.py, Slack on failure); everything that differs
# per workspace stays IN the workspace: the install epilogue
# (.github/scripts/smoke_install.sh, receiving PYTHON_VERSION — extras,
# pins, version conditionals) and the smoke runner itself. The dependency
# chain is an input and checkouts use the calling owner, so forks of the
# organism reuse this workflow without modification.
#
# The workflow filename is intentionally stable for downstream callers.
on:
workflow_call:
inputs:
chain:
description: "Space-separated dependency libraries in install order, e.g. 'PyAutoNerves PyAutoFit'"
required: true
type: string
python-versions:
description: "JSON list of python versions to matrix over"
required: false
type: string
default: '["3.12", "3.13"]'
slack-channel-id:
description: "Slack channel for failure notification"
required: false
type: string
default: "C03S98FEDK2"
jobs:
# Docs-only gate: skip the matrix when the diff touches nothing but prose.
# FAIL CLOSED — any doubt (no base sha, unfetchable base, empty diff, a
# single non-allowlisted file) runs the matrix; only an explicit
# every-file-matches verdict skips. The allowlist is deliberately tiny:
# dotfiles and path-keyed sidecars count as code. The two-dot diff against
# the base TIP (not the merge-base) means upstream drift on the base branch
# shows up as extra files and conservatively runs the matrix. A skipped
# matrix job reports "skipped", which satisfies required-check semantics.
changes:
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.diff.outputs.docs_only }}
steps:
- name: Checkout workspace (shallow)
uses: actions/checkout@v4
- name: Classify the diff
id: diff
env:
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
run: |
docs_only=false
files=""
if [ -n "$BASE" ] \
&& [ "$BASE" != "0000000000000000000000000000000000000000" ] \
&& git fetch --quiet --depth=1 origin "$BASE" 2>/dev/null; then
files="$(git diff --name-only "$BASE" HEAD 2>/dev/null || true)"
if [ -n "$files" ]; then
docs_only=true
while IFS= read -r f; do
case "$f" in
*.md|docs/*|LICENSE|runtime.txt) ;;
*) docs_only=false; break ;;
esac
done <<< "$files"
fi
fi
echo "docs_only=$docs_only" >> "$GITHUB_OUTPUT"
if [ "$docs_only" = true ]; then
{
echo "### Smoke matrix skipped — docs/metadata-only change"
printf -- '- `%s`\n' $files
} >> "$GITHUB_STEP_SUMMARY"
fi
smoke:
needs: changes
if: needs.changes.outputs.docs_only != 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
steps:
- name: Checkout workspace (repo under test, at the PR ref)
uses: actions/checkout@v4
with:
path: workspace
- name: Clone dependency chain + PyAutoHands (matching branch if it exists)
shell: bash
run: |
set -e
BRANCH="${{ github.head_ref || github.ref_name }}"
OWNER="${{ github.repository_owner }}"
for dep in ${{ inputs.chain }} PyAutoHands; do
git clone "https://github.com/$OWNER/$dep" "$dep"
if git -C "$dep" ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
echo "Branch $BRANCH exists in $dep — checking it out"
git -C "$dep" fetch origin "$BRANCH"
git -C "$dep" checkout "$BRANCH"
fi
done
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install (base + the workspace's own epilogue)
env:
PYTHON_VERSION: ${{ matrix.python-version }}
run: |
pip install --upgrade pip setuptools wheel
pip install pyyaml
bash workspace/.github/scripts/smoke_install.sh
- name: Prepare cache dirs
run: mkdir -p /tmp/numba_cache /tmp/matplotlib
- name: Validate env profiles (strict — PyAutoHands#161 step 5)
# Binding PR-time config gate for every workspace that carries a smoke
# profile: the profile must parse, no dead patterns, no legacy names.
# Config-only errors fail here in seconds instead of in the next
# nightly. The release-only strict flags — no PYAUTO_DISABLE_JAX
# enumeration creeping back (strict-derivation), every script's
# resolved backend matching its JAX name marker (strict-markers) —
# apply only where a canonical profile_release.yaml exists (the
# *_workspace_test repos).
run: |
# Fire if the workspace carries a smoke profile: the canonical
# profile_smoke.yaml (PyAutoHands#161/#181 step 6 rename).
# --strict-declarations (PyAutoHands#187): pattern-overrides that are
# expressible as in-file '# ENV:' declarations are errors — the
# migration landed in every workspace, so new ones must not creep in.
if [ -f workspace/config/build/profile_smoke.yaml ]; then
if [ -f workspace/config/build/profile_release.yaml ]; then
python PyAutoHands/autohands/validate_env_profiles.py workspace \
--strict-derivation --strict-markers --strict-declarations
else
python PyAutoHands/autohands/validate_env_profiles.py workspace \
--strict-declarations
fi
else
echo "No config/build/profile_smoke.yaml — profile validation skipped."
fi
- name: Run smoke tests
env:
JAX_ENABLE_X64: "True"
NUMBA_CACHE_DIR: /tmp/numba_cache
MPLCONFIGDIR: /tmp/matplotlib
PYTHONPATH: ${{ github.workspace }}/PyAutoHands/autohands
run: |
cd workspace
python .github/scripts/run_smoke.py
- name: Slack notify on failure
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.21.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
channel-id: ${{ inputs.slack-channel-id }}
payload: |
{
"text": "${{ github.repository }}/${{ github.ref_name }} smoke tests (Python ${{ matrix.python-version }}) ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}