-
Notifications
You must be signed in to change notification settings - Fork 0
327 lines (281 loc) · 13.2 KB
/
Copy pathworkstation-scripts.yml
File metadata and controls
327 lines (281 loc) · 13.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
name: workstation-scripts
on:
pull_request:
paths:
- 'profiles/linux-dev/workstation-v0/**'
- 'docs/workstation/**'
- '.github/workflows/workstation-scripts.yml'
push:
branches:
- main
paths:
- 'profiles/linux-dev/workstation-v0/**'
- 'docs/workstation/**'
- '.github/workflows/workstation-scripts.yml'
jobs:
shellcheck-and-syntax:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Shellcheck (workstation-v0)
run: |
set -euo pipefail
# Policy: ShellCheck warnings are treated as failures for workstation-v0 scripts.
files=$(git ls-files 'profiles/linux-dev/workstation-v0/**/*.sh' \
'profiles/linux-dev/workstation-v0/**/sourceos' \
'profiles/linux-dev/workstation-v0/**/install-sourceos-cli.sh' || true)
if [ -z "$files" ]; then
echo "No scripts found."
exit 0
fi
fail=0
while IFS= read -r f; do
shellcheck -S warning "$f" || fail=1
done <<<"$files"
exit $fail
- name: Bash syntax check (bash -n)
run: |
set -euo pipefail
files=$(git ls-files 'profiles/linux-dev/workstation-v0/**/*.sh' \
'profiles/linux-dev/workstation-v0/**/sourceos' \
'profiles/linux-dev/workstation-v0/**/install-sourceos-cli.sh' || true)
if [ -z "$files" ]; then
echo "No scripts found."
exit 0
fi
while IFS= read -r f; do
bash -n "$f"
done <<<"$files"
- name: Smoke: patch-shell apply is idempotent
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-shell.sh'
bash -n "$p"
tmp=$(mktemp)
printf '# rc\n' > "$tmp"
SOURCEOS_RC_FILES="$tmp" bash "$p" apply
SOURCEOS_RC_FILES="$tmp" bash "$p" apply
test "$(grep -cF '# >>> sourceos workstation-v0 >>>' "$tmp")" -eq 1
test "$(grep -cF '# <<< sourceos workstation-v0 <<<' "$tmp")" -eq 1
grep -F 'export PATH="$HOME/.local/bin:$PATH"' "$tmp" >/dev/null
- name: Smoke: patch-shell revert removes marker block
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-shell.sh'
tmp=$(mktemp)
printf '# rc\n' > "$tmp"
SOURCEOS_RC_FILES="$tmp" bash "$p" apply
SOURCEOS_RC_FILES="$tmp" bash "$p" revert
! grep -qF '# >>> sourceos workstation-v0 >>>' "$tmp"
! grep -qF '# <<< sourceos workstation-v0 <<<' "$tmp"
- name: Smoke: patch-shell JSON contract parses
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-shell.sh'
tmp=$(mktemp)
printf '# rc\n' > "$tmp"
out=$(SOURCEOS_RC_FILES="$tmp" bash "$p" dry-run --json)
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.fix.shell"; assert j["mode"]=="dry-run"; assert "summary" in j; assert isinstance(j["results"], list); print("ok")' <<<"$out"
- name: Smoke: patch-fish apply/revert
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-fish.sh'
bash -n "$p"
tmp=$(mktemp)
printf '# fish\n' > "$tmp"
SOURCEOS_FISH_CONFIG="$tmp" bash "$p" apply
SOURCEOS_FISH_CONFIG="$tmp" bash "$p" revert
! grep -qF '# >>> sourceos workstation-v0 (fish) >>>' "$tmp"
! grep -qF '# <<< sourceos workstation-v0 (fish) <<<' "$tmp"
- name: Smoke: patch-fish JSON contract parses
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-fish.sh'
tmp=$(mktemp)
printf '# fish\n' > "$tmp"
out=$(SOURCEOS_FISH_CONFIG="$tmp" bash "$p" dry-run --json)
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.fix.fish"; assert j["mode"]=="dry-run"; assert "result" in j; print("ok")' <<<"$out"
- name: Smoke: patch-all apply/revert
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-all.sh'
bash -n "$p"
rc_tmp=$(mktemp)
fish_tmp=$(mktemp)
printf '# rc\n' > "$rc_tmp"
printf '# fish\n' > "$fish_tmp"
SOURCEOS_RC_FILES="$rc_tmp" SOURCEOS_FISH_CONFIG="$fish_tmp" bash "$p" apply
SOURCEOS_RC_FILES="$rc_tmp" SOURCEOS_FISH_CONFIG="$fish_tmp" bash "$p" revert
! grep -qF '# >>> sourceos workstation-v0 >>>' "$rc_tmp"
! grep -qF '# <<< sourceos workstation-v0 <<<' "$rc_tmp"
! grep -qF '# >>> sourceos workstation-v0 (fish) >>>' "$fish_tmp"
! grep -qF '# <<< sourceos workstation-v0 (fish) <<<' "$fish_tmp"
- name: Smoke: patch-all JSON contract parses
run: |
set -euo pipefail
p='profiles/linux-dev/workstation-v0/bin/patch-all.sh'
rc_tmp=$(mktemp)
fish_tmp=$(mktemp)
printf '# rc\n' > "$rc_tmp"
printf '# fish\n' > "$fish_tmp"
out=$(SOURCEOS_RC_FILES="$rc_tmp" SOURCEOS_FISH_CONFIG="$fish_tmp" bash "$p" dry-run --json)
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.fix.all"; assert j["mode"]=="dry-run"; assert "results" in j and "shell" in j["results"] and "fish" in j["results"]; print("ok")' <<<"$out"
- name: Smoke: sourceos help exits cleanly
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
bash -n "$f"
SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$f" --help >/dev/null
- name: Smoke: sourceos fix all dry-run exits cleanly
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
rc_tmp=$(mktemp)
fish_tmp=$(mktemp)
printf '# rc\n' > "$rc_tmp"
printf '# fish\n' > "$fish_tmp"
SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 SOURCEOS_RC_FILES="$rc_tmp" SOURCEOS_FISH_CONFIG="$fish_tmp" bash "$f" fix all dry-run >/dev/null
- name: Smoke: sourceos fix all JSON contract parses
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
rc_tmp=$(mktemp)
fish_tmp=$(mktemp)
printf '# rc\n' > "$rc_tmp"
printf '# fish\n' > "$fish_tmp"
out=$(SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 SOURCEOS_RC_FILES="$rc_tmp" SOURCEOS_FISH_CONFIG="$fish_tmp" bash "$f" fix all dry-run --json)
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.fix.all"; assert j["mode"]=="dry-run"; assert "results" in j; print("ok")' <<<"$out"
- name: Smoke: sourceos fix shell dry-run exits cleanly
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
tmp=$(mktemp)
printf '# rc\n' > "$tmp"
SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 SOURCEOS_RC_FILES="$tmp" bash "$f" fix shell dry-run >/dev/null
- name: Smoke: sourceos fix fish dry-run exits cleanly
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
tmp=$(mktemp)
printf '# fish\n' > "$tmp"
SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 SOURCEOS_FISH_CONFIG="$tmp" bash "$f" fix fish dry-run >/dev/null
- name: Smoke: doctor JSON contract parses
run: |
set -euo pipefail
export PATH="$(pwd)/profiles/linux-dev/workstation-v0/bin:$PATH"
d='profiles/linux-dev/workstation-v0/doctor.sh'
set +e
out=$(SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$d" --json)
rc=$?
set -e
if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then
echo "Unexpected exit code: $rc" >&2
exit 1
fi
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.doctor"; assert j["profile"]=="linux-dev/workstation-v0"; assert "summary" in j; assert isinstance(j["results"], list); print("ok")' <<<"$out"
- name: Smoke: sourceos doctor JSON contract parses
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
export PATH="$(pwd)/profiles/linux-dev/workstation-v0/bin:$PATH"
set +e
out=$(SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$f" doctor --json)
rc=$?
set -e
if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then
echo "Unexpected exit code: $rc" >&2
exit 1
fi
python3 -c 'import json,sys; j=json.loads(sys.stdin.read()); assert j["kind"]=="sourceos.doctor"; assert j["profile"]=="linux-dev/workstation-v0"; print("ok")' <<<"$out"
- name: Smoke: sourceos doctor report file writes
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
export PATH="$(pwd)/profiles/linux-dev/workstation-v0/bin:$PATH"
out_json=$(mktemp)
set +e
SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$f" doctor --write "$out_json" >/dev/null
rc=$?
set -e
if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then
echo "Unexpected exit code: $rc" >&2
exit 1
fi
test -s "$out_json"
python3 -c 'import json,sys; j=json.load(open(sys.argv[1])); assert j["kind"]=="sourceos.doctor"; print("ok")' "$out_json"
- name: Smoke: sourceos status JSON parses
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
bash -n "$f"
# `sourceos status --json` may return exit 0 (all deps present) or 2 (missing deps).
# We only require the JSON output to parse and contain expected keys.
set +e
out=$(SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$f" status --json)
rc=$?
set -e
if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then
echo "Unexpected exit code: $rc" >&2
exit 1
fi
python3 -c '
import json, sys
j = json.loads(sys.stdin.read())
req = ["profile", "ok", "gnome", "required_missing", "optional_missing", "warnings"]
miss = [k for k in req if k not in j]
assert not miss, "missing keys: " + ",".join(miss)
assert isinstance(j["warnings"], list), "warnings must be a list"
assert isinstance(j["required_missing"], list), "required_missing must be a list"
assert isinstance(j["optional_missing"], list), "optional_missing must be a list"
assert isinstance(j["ok"], bool), "ok must be a bool"
assert isinstance(j["gnome"], bool), "gnome must be a bool"
print("ok: schema valid, warnings count=" + str(len(j["warnings"])))
' <<<"$out"
- name: Smoke: sourceos status --json warnings includes aggregate polish checks
run: |
set -euo pipefail
f='profiles/linux-dev/workstation-v0/bin/sourceos'
# Validate commands (as required by validation evidence requirement):
echo "CMD: bash -n $f"
bash -n "$f"
echo "PASS: bash -n"
echo "CMD: SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash $f status --json"
set +e
out=$(SOURCEOS_PROFILE_DIR=profiles/linux-dev/workstation-v0 bash "$f" status --json)
rc=$?
set -e
echo "exit code: $rc"
if [ "$rc" -ne 0 ] && [ "$rc" -ne 2 ]; then
echo "FAIL: unexpected exit code $rc" >&2
exit 1
fi
echo "PASS: exit code $rc is 0 or 2"
# Validate JSON schema and aggregate polish warning integration
python3 -c '
import json, sys
j = json.loads(sys.stdin.read())
# Schema check: all expected keys present
req = ["profile", "ok", "gnome", "required_missing", "optional_missing", "warnings"]
miss = [k for k in req if k not in j]
assert not miss, "missing keys: " + ",".join(miss)
print("PASS: all schema keys present:", req)
# Type check: warnings is a list (aggregate polish warnings integrate here)
assert isinstance(j["warnings"], list), "warnings must be a list"
print("PASS: warnings is list, count=" + str(len(j["warnings"])))
print("warnings:", j["warnings"])
# Confirm profile value
assert j["profile"] == "linux-dev/workstation-v0", "unexpected profile: " + str(j["profile"])
print("PASS: profile =", j["profile"])
' <<<"$out"
echo "PASS: aggregate polish warning integration validated"
- name: Drift guard: forbid legacy launcher strings
run: |
set -euo pipefail
# Prevent drift back to non-open launcher references.
if grep -RIn --exclude-dir=.git -E 'Albert|albert toggle|SOURCEOS_ALLOW_THIRDPARTY_REPOS' docs/workstation profiles/linux-dev/workstation-v0; then
echo "Found forbidden legacy launcher reference." >&2
exit 1
fi