-
Notifications
You must be signed in to change notification settings - Fork 54
254 lines (239 loc) · 7.12 KB
/
tests.yml
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
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
env:
CCACHE_ACTION_CI: true
jobs:
build:
# Run npm build and check that the dist/ folder is up to date.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
npm install
git diff --exit-code
unit_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run unit tests
run: |
npm install
npm test
test_ccache:
# Test that ccache/sccache are installed and configured correctly.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shell: [bash]
variant: [sccache, ccache]
include:
- { os: windows-latest, shell: powershell, variant: sccache }
- { os: windows-latest, shell: powershell, variant: ccache, xfail: true }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Run ccache-action
id: ccache
uses: ./
with:
verbose: 2
variant: ${{ matrix.variant }}
max-size: 10M
job-summary: 'ccache statistics'
key: parent
- name: Test ccache 1/2
run: |
[[ ${{ steps.ccache.outputs.test-cache-hit }} = true ]] || [[ ${{ steps.ccache.outputs.test-cache-hit }} = false ]]
if [ ${{ matrix.variant }} = sccache ]; then
which sccache
sccache -V
sccache -s
# sccache -s | grep -E 'Max cache size.+10 MiB'
sccache -s | grep -E "Cache location.+${SCCACHE_DIR:-ccache-action[\\/]+\.sccache}"
else
which ccache
ccache -V
# Some versions of ccache don't have -v or -s
ccache -sv || ccache -s || true
fi
# Example program
echo "int x = $RANDOM;" > test.c
${{ matrix.variant }} gcc test.c -c -o test.o
- name: Re-compile test program in Bash
run: ${{ matrix.variant }} gcc test.c -c -o test.o
- name: Re-compile test program in Bash
run: ${{ matrix.variant }} gcc test.c -c -o test.o
if: ${{ matrix.shell == 'bash' }}
- name: Re-compile test program in PowerShell
run: |
${{ matrix.variant }} gcc test.c -c -o test.o
shell: powershell
if: ${{ matrix.shell == 'powershell' }}
- name: Test ccache 2/2
run: |
${{ matrix.variant }} -sv || ${{ matrix.variant }} -s || true
${{ matrix.variant }} -s | grep -E '(Hits:.+2.+/.+3)|cache hit.+2$|Cache hits.+2$'
if: ${{ !matrix.xfail }}
test_cache_hit:
# Test that loading from the cache works.
needs: [test_ccache]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shell: [bash]
variant: [sccache, ccache]
include:
- { os: windows-latest, shell: powershell, variant: sccache }
- { os: windows-latest, shell: powershell, variant: ccache }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Run ccache action
uses: ./
id: output
with:
variant: ${{ matrix.variant }}
key: parent
- name: Test output true
run: |
[[ ${{ steps.output.outputs.test-cache-hit }} = true ]]
test_cache_miss:
# Test that cache misses do not break anything.
needs: [test_ccache]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shell: [bash]
variant: [sccache, ccache]
include:
- { os: windows-latest, shell: powershell, variant: sccache }
- { os: windows-latest, shell: powershell, variant: ccache }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: |
echo "RAND=$RANDOM" >> $GITHUB_ENV
- name: Run ccache action
uses: ./
id: output
with:
variant: ${{ matrix.variant }}
key: random-key-${{ env.RAND }}
- name: Test output false
run: |
[[ ${{ steps.output.outputs.test-cache-hit }} = false ]]
test_restore_keys:
# Test the "restore-keys" option.
needs: [test_ccache]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
shell: [bash]
variant: [sccache, ccache]
include:
- { os: windows-latest, shell: powershell, variant: sccache }
- { os: windows-latest, shell: powershell, variant: ccache }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: |
echo "RAND=$RANDOM" >> $GITHUB_ENV
- name: Run ccache action
uses: ./
id: restore-keys
with:
variant: ${{ matrix.variant }}
key: child-${{ env.RAND }}
restore-keys: |
parent
- name: Test restore-keys
run: |
[[ ${{ steps.restore-keys.outputs.test-cache-hit }} = true ]]
test_docker_ubuntu:
# Test that it works in a Docker container without sudo.
runs-on: ubuntu-latest
container: ubuntu:latest
steps:
- uses: actions/checkout@v4
- run: apt update
shell: bash
- name: Run ccache-action
uses: ./
test_docker_alpine:
# Test that it works in Alpine Docker container with apk package manager.
runs-on: ubuntu-latest
container: alpine:latest
steps:
- uses: actions/checkout@v4
- run: apk update
shell: sh
- name: Run ccache-action
uses: ./
test_option_save:
# Test that the 'save' option is available.
runs-on: ubuntu-latest
strategy:
matrix:
save: [true, false]
steps:
- uses: actions/checkout@v4
- name: Run ccache-action
uses: ./
with:
save: ${{ matrix.save }}
test_option_append_timestamp:
# Test that the 'append-timestamp' option is available.
runs-on: ubuntu-latest
strategy:
matrix:
append-timestamp: [true, false]
steps:
- uses: actions/checkout@v4
- name: Run ccache-action
uses: ./
with:
append-timestamp: ${{ matrix.append-timestamp }}
test_option_create_symlink:
# Test that the 'create-symlink' option is available.
runs-on: ubuntu-latest
strategy:
matrix:
create-symlink: [true, false]
steps:
- uses: actions/checkout@v4
- name: Run ccache-action
uses: ./
with:
create-symlink: ${{ matrix.create-symlink }}
- name: Test symlink
run: |
if [ ${{ matrix.create-symlink }} = true ]; then
ls -l $(which gcc) | grep $(which ccache)
else
ls -l $(which gcc) | grep -v $(which ccache)
fi
test_option_evict:
runs-on: ubuntu-latest
strategy:
matrix:
evict: [true, false]
steps:
- uses: actions/checkout@v4
- name: Run ccache-action
uses: ./
with:
evict-old-files: ${{ matrix.evict }}