Repository navigation
293 lines (286 loc) · 10.2 KB
/
Copy pathfresh-install.yml
File metadata and controls
293 lines (286 loc) · 10.2 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Fresh install and first use
on:
push:
branches: [main]
paths:
- "src/**"
- "solutions/**"
- "d2x/**"
- "mcpp.toml"
- ".d2x.json"
- ".xlings.json"
- ".github/workflows/**"
- ".github/actions/**"
- ".devcontainer/**"
- ".vscode/tasks.json"
- "scripts/**"
- "README*.md"
- "docs/**"
- "book/src/base/chapter_1.md"
- "book/en/src/base/chapter_1.md"
- "book/src/changelog.md"
- "book/en/src/changelog.md"
pull_request:
paths:
- "src/**"
- "solutions/**"
- "d2x/**"
- "mcpp.toml"
- ".d2x.json"
- ".xlings.json"
- ".github/workflows/**"
- ".github/actions/**"
- ".devcontainer/**"
- ".vscode/tasks.json"
- "scripts/**"
- "README*.md"
- "docs/**"
- "book/src/base/chapter_1.md"
- "book/en/src/base/chapter_1.md"
- "book/src/changelog.md"
- "book/en/src/changelog.md"
workflow_dispatch:
inputs:
candidate_run:
description: 'Optional successful d2learn/d2x CI run ID (explicit prerelease override)'
type: string
default: ''
candidate_sha:
description: 'Exact checkout SHA recorded in that candidate provenance'
type: string
default: ''
diagnose:
description: 'Also compare standalone build and checker in separate cold Windows environments'
type: boolean
default: false
schedule:
- cron: '23 4 * * 1'
permissions:
contents: read
actions: read
env:
XLINGS_NON_INTERACTIVE: '1'
D2X_CANDIDATE_SHA: ${{ inputs.candidate_sha }}
D2X_CANDIDATE_DIR: .d2x/candidate
jobs:
native:
if: ${{ !inputs.diagnose }}
name: fresh (${{ matrix.os }}, ${{ matrix.route }}, MSVC=${{ !matrix.mask_msvc }})
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [macos-15, windows-2022, windows-2025]
route: [readme, cold]
mask_msvc: [false]
include:
- {os: windows-2025, route: readme, mask_msvc: true}
- {os: windows-2025, route: cold, mask_msvc: true}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
if: inputs.candidate_run != ''
with:
repository: d2learn/d2x
run-id: ${{ inputs.candidate_run }}
github-token: ${{ github.token }}
name: ${{ runner.os == 'Linux' && 'candidate-linux-x86_64' || format('candidate-{0}', matrix.os) }}
path: ${{ env.D2X_CANDIDATE_DIR }}
- name: Verify explicit candidate provenance
if: inputs.candidate_run != ''
shell: bash
run: ${{ runner.os == 'Windows' && 'python' || 'python3' }} scripts/ci/candidate.py
- name: Select an empty toolchain home
shell: bash
run: echo "MCPP_HOME=$RUNNER_TEMP/d2mcpp-fresh" >> "$GITHUB_ENV"
- name: Assert host architecture
shell: bash
run: |
uname -a
if [[ "$RUNNER_OS" == macOS ]]; then test "$(uname -m)" = arm64; fi
test ! -e target
test ! -e .d2x/state.json
- name: Mask MSVC
if: matrix.mask_msvc
shell: powershell
run: ./scripts/ci/mask-msvc.ps1
- name: Follow the README install and practice commands (Unix)
if: runner.os != 'Windows' && matrix.route == 'readme'
run: python3 scripts/ci/readme.py
- name: Follow the README install and practice commands (PowerShell 5.1)
if: runner.os == 'Windows' && matrix.route == 'readme'
shell: powershell
run: python scripts/ci/readme.py
- name: Cold install only (Unix)
if: runner.os != 'Windows' && matrix.route == 'cold'
run: python3 scripts/ci/prepare.py --install-only
- name: Cold install only (PowerShell 5.1)
if: runner.os == 'Windows' && matrix.route == 'cold'
shell: powershell
run: python scripts/ci/prepare.py --install-only
- name: First check, save, advance and resume
if: matrix.route == 'cold'
shell: bash
run: python scripts/ci/first-run.py --allow-source-edit --cold
- name: Cold route also verifies all reference answers
if: matrix.route == 'cold'
run: python scripts/ci/solutions.py
- name: Assert GNU target without MSVC
if: matrix.mask_msvc
shell: bash
env:
ROUTE: ${{ matrix.route }}
run: |
logs="$(pwd)/.d2x/ci-logs"
if [[ "$ROUTE" == readme ]]; then cd "$(cat "$logs/readme-course-path.txt")"; fi
# doctor returns nonzero for warnings too (missing MSVC is expected).
mcpp self doctor > "$logs/doctor.txt" 2>&1 || true
cat "$logs/doctor.txt"
grep -q 'gcc.*what a build here uses' "$logs/doctor.txt"
grep -q 'payload mingw-gcc' "$logs/doctor.txt"
grep -q 'x86_64.*windows-gnu' "$logs/doctor.txt"
ls -d target/*windows-gnu
- uses: actions/upload-artifact@v4
if: always()
with:
name: first-run-${{ matrix.os }}-${{ matrix.route }}-${{ matrix.mask_msvc || false }}
path: .d2x/ci-logs/
if-no-files-found: ignore
include-hidden-files: true
linux-minimal:
if: ${{ !inputs.diagnose }}
name: fresh (Linux without a compiler, ${{ matrix.route }})
runs-on: ubuntu-24.04
container: ubuntu:24.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
route: [readme, cold]
steps:
- name: Install transport and CI tools, no C++ compiler
run: |
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates git xz-utils unzip python3
useradd -m -s /bin/bash learner
! command -v g++
! command -v clang++
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
if: inputs.candidate_run != ''
with:
repository: d2learn/d2x
run-id: ${{ inputs.candidate_run }}
github-token: ${{ github.token }}
name: candidate-linux-x86_64
path: ${{ env.D2X_CANDIDATE_DIR }}
- name: Verify explicit candidate provenance
if: inputs.candidate_run != ''
shell: bash
run: ${{ runner.os == 'Windows' && 'python' || 'python3' }} scripts/ci/candidate.py
- name: Give the ordinary user a fresh checkout
shell: bash
env:
ROUTE: ${{ matrix.route }}
run: |
course_dir="$GITHUB_WORKSPACE"
if [[ "$ROUTE" == readme ]]; then
course_dir="/home/learner/first use with spaces/$(python3 -c 'print("long-project-directory-" * 6)')"
mkdir -p "$course_dir"
cp -a "$GITHUB_WORKSPACE/." "$course_dir/"
fi
chown -R learner:learner "$course_dir"
echo "COURSE_DIR=$course_dir" >> "$GITHUB_ENV"
- name: Follow the README or start checker cold
shell: bash
env:
ROUTE: ${{ matrix.route }}
run: |
cd "$COURSE_DIR"
if [[ "$ROUTE" == cold ]]; then
runuser -u learner -- python3 scripts/ci/prepare.py --install-only
runuser -u learner -- env MCPP_HOME=/home/learner/.mcpp PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/first-run.py --allow-source-edit --cold
runuser -u learner -- env PATH="/home/learner/.xlings/subos/current/bin:$PATH" python3 scripts/ci/solutions.py
else
runuser -u learner -- python3 scripts/ci/readme.py
fi
- uses: actions/upload-artifact@v4
if: always()
with:
name: first-run-linux-${{ matrix.route }}
path: ${{ env.COURSE_DIR }}/.d2x/ci-logs/
if-no-files-found: ignore
include-hidden-files: true
released-course:
name: d2x download and pinned install
if: ${{ !inputs.diagnose && inputs.candidate_run == '' }}
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Verify the documented existing-d2x download route
run: python3 scripts/ci/readme.py --d2x-download ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && '--published' || '' }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: published-course-first-use
path: .d2x/ci-logs/
if-no-files-found: ignore
include-hidden-files: true
cold-diagnostics:
if: inputs.diagnose
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
route: [build, run, checker]
steps:
- uses: actions/checkout@v4
- name: Mask MSVC
shell: powershell
run: ./scripts/ci/mask-msvc.ps1
- name: Select independent cold home
shell: bash
run: echo "MCPP_HOME=$RUNNER_TEMP/diagnostic-${{ matrix.route }}" >> "$GITHUB_ENV"
- name: Install tools only
shell: powershell
run: python scripts/ci/prepare.py --install-only
- name: Diagnose baseline cold startup
shell: bash
env:
DIAGNOSTIC_ROUTE: ${{ matrix.route }}
run: python scripts/ci/cold-diagnostics.py
- uses: actions/upload-artifact@v4
if: always()
with:
name: cold-diagnostic-${{ matrix.route }}
path: .d2x/ci-logs/
include-hidden-files: true
latest-stable:
if: ${{ !inputs.diagnose && inputs.candidate_run == '' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, macos-15, windows-2025]
steps:
- uses: actions/checkout@v4
- name: Install xlings (Unix)
if: runner.os != 'Windows'
run: bash scripts/install-xlings.sh
- name: Install xlings (PowerShell 5.1)
if: runner.os == 'Windows'
shell: powershell
run: ./scripts/install-xlings.ps1
- name: Check public latest and independently restore course pins
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: ${{ runner.os == 'Windows' && 'python' || 'python3' }} scripts/ci/latest.py
- uses: actions/upload-artifact@v4
if: always()
with:
name: latest-stable-versions-${{ matrix.os }}
path: .d2x/ci-logs/
include-hidden-files: true