-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (130 loc) · 5.05 KB
/
Copy pathvalidate-branches.yml
File metadata and controls
138 lines (130 loc) · 5.05 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
name: Validate learner branches
# Validation gate for the ACC start-of-module-N delta store. Runs on any PR that
# touches the delta store / course-build tooling, and is reusable (workflow_call)
# so the dispatch receiver can gate a regen PR on the same checks.
on:
pull_request:
paths:
- 'course-build/**'
- '.github/workflows/validate-branches.yml'
workflow_dispatch:
inputs:
dispatch_id:
description: 'Staging namespace to validate (regen/<id>/...)'
required: false
default: 'ci-manual'
ref:
description: 'Git ref (branch/SHA) to validate'
required: false
default: ''
workflow_call:
inputs:
dispatch_id:
description: 'Staging namespace to validate'
required: false
type: string
default: 'ci-call'
ref:
description: 'Git ref (branch/SHA) to validate. Defaults to the caller ref.'
required: false
type: string
default: ''
permissions:
contents: read
concurrency:
group: validate-branches-${{ github.ref }}-${{ inputs.ref }}
cancel-in-progress: true
jobs:
# Fast, deterministic checks: deltas apply cleanly onto acc-base, each cumulative
# tree matches manifest.expectedTreeSha, expected .github assets present, ancestry
# linear. Also emits the buildable start-branch matrix for the heavy job.
verify-deltas:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.matrix.outputs.branches }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # need full history + base commit for git am
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Ensure base commit present
run: git fetch --no-tags origin "$(node -e "console.log(require('./course-build/manifest.json').base.sha)")" || true
- name: Deterministic delta check (trees, assets, ancestry)
run: node course-build/scripts/build-branches.mjs --check
- name: Self-test (classification + path detection)
run: node course-build/scripts/selftest.mjs
- name: Compute buildable start-branch matrix
id: matrix
run: |
branches=$(node -e "const m=require('./course-build/manifest.json');const b=m.modules.filter(x=>x.status==='backfilled'&&(x.patches||[]).length).map(x=>x.startBranch);process.stdout.write(JSON.stringify(b))")
echo "branches=$branches" >> "$GITHUB_OUTPUT"
echo "Buildable: $branches"
# Secret scan of the delta store and everything the built branches would contain.
secret-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref || github.ref }}
- name: gitleaks (delta store + course-build)
uses: gitleaks/gitleaks-action@v2
env:
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: 'false'
GITLEAKS_ENABLE_SUMMARY: 'true'
# Heavy gate: build each buildable learner branch from deltas and run the suites
# that exist in that cumulative state (web / .NET / Java / Python / Playwright),
# plus the no-uncommitted-files-after-setup assertion.
build-and-test:
needs: verify-deltas
if: needs.verify-deltas.outputs.branches != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
start_branch: ${{ fromJSON(needs.verify-deltas.outputs.branches) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref || github.ref }}
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Ensure base commit present
run: git fetch --no-tags origin "$(node -e "console.log(require('./course-build/manifest.json').base.sha)")" || true
- name: Configure git identity (for git am)
run: |
git config user.name "acc-course-bot"
git config user.email "acc-course-bot@users.noreply.github.com"
- name: Build + validate ${{ matrix.start_branch }}
run: bash course-build/scripts/validate-branch.sh "${{ matrix.start_branch }}"
env:
DISPATCH_ID: ci-${{ github.run_id }}
# Aggregate result used as the required status check / workflow_call output.
summary:
needs: [verify-deltas, secret-scan, build-and-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Fail if any gate failed
run: |
echo "verify-deltas: ${{ needs.verify-deltas.result }}"
echo "secret-scan: ${{ needs.secret-scan.result }}"
echo "build-and-test:${{ needs.build-and-test.result }}"
test "${{ needs.verify-deltas.result }}" = "success"
test "${{ needs.secret-scan.result }}" = "success"
test "${{ needs.build-and-test.result }}" = "success"