Repository navigation
138 lines (127 loc) · 3.74 KB
/
Copy pathwarp-cache-e2e.yml
File metadata and controls
138 lines (127 loc) · 3.74 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: warp-cache-e2e
on:
pull_request:
paths-ignore:
- '**.md'
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
permissions:
contents: read
jobs:
save:
name: save (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
[
warp-ubuntu-latest-x64-2x,
warp-windows-2022-x64-4x,
warp-macos-15-arm64-6x
]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
# The cache key is derived from this file's hash, so a per-run value
# guarantees a fresh key and a genuine miss -> save -> hit round trip.
- name: Write run-unique lockfile
shell: bash
env:
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
mkdir -p warp-fixture
cat > warp-fixture/package-lock.json <<EOF
{
"name": "warp-cache-e2e-${RUN_ID}-${RUN_ATTEMPT}",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
EOF
- name: Setup Node
id: setup
uses: ./
with:
node-version: 24
cache: npm
cache-dependency-path: warp-fixture/package-lock.json
- name: Assert cache miss on a fresh key
shell: bash
env:
PRIMARY_KEY: ${{ steps.setup.outputs.cache-primary-key }}
CACHE_HIT: ${{ steps.setup.outputs.cache-hit }}
run: |
echo "primary-key: $PRIMARY_KEY"
if [ "$CACHE_HIT" != "false" ]; then
echo "expected a miss on a run-unique key, got cache-hit=$CACHE_HIT"
exit 1
fi
# Give the post step real bytes to upload.
- name: Populate the npm cache
shell: bash
run: npm cache add is-number@7.0.0
restore:
name: restore (${{ matrix.os }})
needs: save
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
[
warp-ubuntu-latest-x64-2x,
warp-windows-2022-x64-4x,
warp-macos-15-arm64-6x
]
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Write the same run-unique lockfile
shell: bash
env:
RUN_ID: ${{ github.run_id }}
RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
mkdir -p warp-fixture
cat > warp-fixture/package-lock.json <<EOF
{
"name": "warp-cache-e2e-${RUN_ID}-${RUN_ATTEMPT}",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
EOF
- name: Setup Node
id: setup
uses: ./
with:
node-version: 24
cache: npm
cache-dependency-path: warp-fixture/package-lock.json
- name: Assert the cache saved by the save job was restored
shell: bash
env:
PRIMARY_KEY: ${{ steps.setup.outputs.cache-primary-key }}
MATCHED_KEY: ${{ steps.setup.outputs.cache-matched-key }}
CACHE_HIT: ${{ steps.setup.outputs.cache-hit }}
run: |
echo "primary-key: $PRIMARY_KEY"
echo "matched-key: $MATCHED_KEY"
if [ "$CACHE_HIT" != "true" ]; then
echo "expected a hit on the key saved by the save job"
exit 1
fi
if [ "$MATCHED_KEY" != "$PRIMARY_KEY" ]; then
echo "matched key did not equal the primary key"
exit 1
fi