Repository navigation
Expand file tree
/
Copy pathtest_ci_cache_keys.sh
More file actions
132 lines (117 loc) · 4.02 KB
/
Copy pathtest_ci_cache_keys.sh
File metadata and controls
132 lines (117 loc) · 4.02 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
#!/usr/bin/env bash
# Mutation tests: both required invalidation and reuse, in a disposable repo.
set -euo pipefail
repo=$(cd "$(dirname "$0")/.." && pwd)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
cd "$work"
git init -q
git config user.name 'Cache test'
git config user.email 'cache-test@example.invalid'
mkdir -p scripts jac/jaclang/compiler jac/jaclang/scale jac/bootstrap jac/native
cp "$repo/scripts/ci_cache_keys.sh" scripts/
cp "$repo/jac/jaclang/compiler_inputs.txt" jac/jaclang/
printf 'compiler\n' > jac/jaclang/compiler/pass.jac
printf 'app\n' > jac/jaclang/scale/app.jac
printf 'fetch\n' > jac/bootstrap/fetch_pbs.zig
printf '{}\n' > jac/bootstrap/pins.json
printf 'shim\n' > jac/native/shim.cpp
printf 'dependencies\n' > jac/build.zig.zon
printf '[project]\nversion = "1.0.0"\n\n[check]\nexclude = ["a"]\n' > jac.toml
git add .
git commit -qm seed
keys() { bash scripts/ci_cache_keys.sh; }
key() { printf '%s\n' "$1" | sed -n "s/^$2=//p"; }
same() { [ "$(key "$before" "$1")" = "$(key "$after" "$1")" ] || { echo "Unexpected invalidation: $1" >&2; exit 1; }; }
changed() { [ "$(key "$before" "$1")" != "$(key "$after" "$1")" ] || { echo "Missed invalidation: $1" >&2; exit 1; }; }
commit() { git add .; git commit -qm "$1"; }
before=$(keys)
# Build outputs present at save time must not change any checkout fingerprint.
mkdir -p jac/jaclang/vendor/typeshed/stdlib jac/jaclang/compiler/__pycache__
printf generated > jac/jaclang/vendor/typeshed/stdlib/generated.pyi
printf generated > jac/jaclang/compiler/libjacllvm.so
printf generated > jac/jaclang/compiler/__pycache__/generated.pyc
after=$(keys)
[ "$before" = "$after" ]
rm -rf jac/jaclang/vendor jac/jaclang/compiler/__pycache__ jac/jaclang/compiler/libjacllvm.so
printf 'app edit\n' >> jac/jaclang/scale/app.jac
commit app
after=$(keys)
same compiler; same python; same devassets
changed payload; changed binary
before=$after
mkdir -p jac/jaclang/compiler/tests
printf fixture > jac/jaclang/compiler/tests/fixture.jac
printf test > jac/jaclang/compiler/pass.test.jac
commit tests
after=$(keys)
same compiler; same python
before=$after
printf 'compiler edit\n' >> jac/jaclang/compiler/pass.jac
commit compiler
after=$(keys)
changed compiler; same python; changed binary; same devassets
before=$after
git mv jac/jaclang/compiler/pass.jac jac/jaclang/compiler/renamed.jac
commit rename
after=$(keys)
changed compiler; same python
before=$after
git rm -q jac/jaclang/compiler/renamed.jac
commit delete
after=$(keys)
changed compiler; same python
before=$after
printf ' ' >> jac/bootstrap/pins.json
commit pin
after=$(keys)
changed python; same compiler; changed binary; changed devassets
before=$after
printf fetch >> jac/bootstrap/fetch_pbs.zig
commit fetcher
after=$(keys)
changed python; same compiler
before=$after
printf dependency >> jac/build.zig.zon
commit dependency
after=$(keys)
changed binary; same python
before=$after
printf shim >> jac/native/shim.cpp
commit shim
after=$(keys)
changed binary; same python; changed devassets
before=$after
mkdir -p jac/examples/tiny_jacyac
printf example > jac/examples/tiny_jacyac/web.jac
commit tiny-example
after=$(keys)
changed binary; same compiler; same python
before=$after
mkdir -p jac/jaclang/dist/payload
printf payload > jac/jaclang/dist/payload/fetch.jac
commit payload-tool
after=$(keys)
changed devassets; same python
for input in client/js_runtime.jac compiler/backends/native/floors.jac \
compiler/backends/native/musl_compat/forwarders.c \
compiler/backends/native/compiler_rt/aarch64/lse.S \
compiler/backends/native/wasm_rt/libc.c; do
before=$after
mkdir -p "jac/jaclang/$(dirname "$input")"
printf edit >> "jac/jaclang/$input"
commit "$input"
after=$(keys)
changed devassets; same python
done
before=$after
printf '[project]\nversion = "1.0.0"\n\n[check]\nexclude = ["a", "b"]\n' > jac.toml
commit toml-settings
after=$(keys)
same devbinary; changed binary
before=$after
printf '[project]\nversion = "1.0.1"\n\n[check]\nexclude = ["a", "b"]\n' > jac.toml
commit toml-version
after=$(keys)
changed devbinary
echo 'CI cache mutation tests passed'