-
Notifications
You must be signed in to change notification settings - Fork 19
80 lines (76 loc) · 2.85 KB
/
Copy pathci.yml
File metadata and controls
80 lines (76 loc) · 2.85 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
name: CI (new-flat subpackages)
on:
pull_request:
merge_group:
push:
branches: [main]
jobs:
discover-subpackages:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
run_template_smoke: ${{ steps.discover.outputs.run_template_smoke }}
reason: ${{ steps.discover.outputs.reason }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v5
- name: Discover changed subpackages
id: discover
run: |
# Resolve a base SHA we can diff against. Each event type carries
# the right base under a different payload key.
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
BASE_REF="${{ github.base_ref }}"
elif [ "${{ github.event_name }}" = "merge_group" ]; then
BASE_SHA="${{ github.event.merge_group.base_sha }}"
BASE_REF="main"
else
BASE_SHA="${{ github.event.before }}"
BASE_REF="main"
fi
# Fallback to HEAD~1 if the event base is not available or zeroed.
if [ -z "$BASE_SHA" ] || [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then
BASE_SHA="HEAD~1"
fi
# Fail loud rather than fall through to `git ls-files` — the latter
# silently runs the full matrix on every PR if the base ref is bad,
# which masks the real problem (missing fetch depth, wrong base sha).
CHANGED=$(git diff --name-only "$BASE_SHA"...HEAD)
uv run python .github/scripts/discover_subpackages.py \
--changed-files "${CHANGED}" \
--base-ref "${BASE_REF}" \
--repo-root "${{ github.workspace }}"
template-smoke:
needs: discover-subpackages
if: needs.discover-subpackages.outputs.run_template_smoke == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Generate demo subpackage
run: |
mkdir -p /tmp/template-smoke
cd /tmp/template-smoke
uv run --with cookiecutter cookiecutter \
"${{ github.workspace }}/cookiecutter" \
--no-input \
name=tplsmoke \
core_path=stdlib.sampling_algos
- name: Test demo subpackage
run: |
cd /tmp/template-smoke/tplsmoke
uv sync --all-extras
uv run pytest -v -m "not qualitative and not e2e"
test:
needs: discover-subpackages
if: fromJson(needs.discover-subpackages.outputs.matrix)[0] != null
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.discover-subpackages.outputs.matrix) }}
uses: ./.github/workflows/package-ci.yml
with:
package: ${{ matrix.package }}