Repository navigation
345 lines (336 loc) · 14.8 KB
/
Copy pathsetup-cli-smoke-test.yml
File metadata and controls
345 lines (336 loc) · 14.8 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
name: setup-cli Smoke Test
# Daily check that the `supabase/setup-cli` GitHub Action installs the Supabase CLI. It tests the
# newest version on each npm dist-tag once that version has been on npm for three hours, so registry
# propagation right after a publish cannot fail it. Catches regressions like supabase/setup-cli#427,
# where musl libc + archive layout changes silently broke the action on Alpine. v3 installs from
# npm, and a fallback to the GitHub release is reported; a separate job forces that fallback.
# Dispatch it with a version to test one release by hand.
on:
schedule:
# Releases rarely land in the three hours before this time, so the age cutoff seldom skips a version.
- cron: "17 4 * * *"
workflow_dispatch:
inputs:
version:
description: Supabase CLI version to test (e.g. 2.40.0). Empty tests the newest version on each npm dist-tag.
required: false
type: string
default: ""
permissions:
contents: read
jobs:
resolve:
name: Resolve versions to test
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
targets: ${{ steps.targets.outputs.targets }}
steps:
- id: targets
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
MIN_AGE_SECONDS: "10800"
run: |
set -euo pipefail
if [[ -n "${INPUT_VERSION}" ]]; then
version="${INPUT_VERSION#v}"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "::error::Not a Supabase CLI version: ${INPUT_VERSION}"
exit 1
fi
targets="$(jq -cn --arg v "${version}" '[{tags: "manual", version: $v}]')"
else
cli="$(npm view supabase dist-tags time --json)"
# Only versions that depend on the @supabase/cli-* platform packages are tested; older
# lines download the binary in a postinstall script that setup-cli v3 does not run.
platform='{}'
while IFS= read -r version; do
deps="$(npm view "supabase@${version}" optionalDependencies --json < /dev/null)"
platform="$(jq -c --arg v "${version}" --argjson deps "${deps:-null}" \
'. + {($v): (($deps // {}) | has("@supabase/cli-linux-x64"))}' <<< "${platform}")"
done < <(jq -r '."dist-tags" | [.[]] | unique[]' <<< "${cli}")
candidates="$(jq -c --argjson platform "${platform}" '
.time as $time
| [."dist-tags" | to_entries[]
| {
tag: .key,
version: .value,
platform: $platform[.value],
age: (now - ($time[.value] | sub("\\.[0-9]+Z$"; "Z") | fromdateiso8601))
}]' <<< "${cli}")"
jq -r '.[] | select(.platform | not)
| "::notice::Skipping dist-tag \(.tag) (\(.version)): it does not depend on the @supabase/cli-* platform packages"' <<< "${candidates}"
jq -r --argjson min "${MIN_AGE_SECONDS}" '.[] | select(.platform and .age < $min)
| "::warning::Skipping dist-tag \(.tag) (\(.version)): published less than \($min / 3600) hours ago, so npm may still be propagating it"' <<< "${candidates}"
targets="$(jq -c --argjson min "${MIN_AGE_SECONDS}" '
map(select(.platform and .age >= $min))
| group_by(.version)
| map({tags: (map(.tag) | join(", ")), version: .[0].version})' <<< "${candidates}")"
if ! jq -e 'any(.[]; .tag == "latest" and .platform)' <<< "${candidates}" > /dev/null; then
echo "::error::dist-tag latest does not depend on the @supabase/cli-* platform packages"
exit 1
fi
if [[ "${targets}" == "[]" ]]; then
echo "::error::No dist-tag has a version old enough to test"
exit 1
fi
fi
echo "Versions to test: $(jq -r 'map("\(.version) (\(.tags))") | join(", ")' <<< "${targets}")"
echo "targets=${targets}" >> "$GITHUB_OUTPUT"
setup-cli-smoke-test:
name: setup-cli ${{ matrix.major-version }} (${{ matrix.runner }}, ${{ matrix.target.version }})
needs: resolve
if: needs.resolve.outputs.targets != '[]'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.resolve.outputs.targets) }}
runner:
- ubuntu-latest
- macos-latest
- windows-latest
# GitHub Actions doesn't allow expressions in `uses:`, so the action ref is selected via
# `if:`-gated install steps below instead of interpolating `matrix.major-version`.
major-version:
- v1
- v2
- v3
runs-on: ${{ matrix.runner }}
timeout-minutes: 15
env:
VERSION: ${{ matrix.target.version }}
steps:
- name: Install Supabase CLI via setup-cli@v1
if: matrix.major-version == 'v1'
uses: supabase/setup-cli@1dedf2c611547ede7232d26866dd3c56ab903bbb # v1.7.3
with:
version: ${{ matrix.target.version }}
- name: Install Supabase CLI via setup-cli@v2
if: matrix.major-version == 'v2'
uses: supabase/setup-cli@afb1b15109756ea5cf9d8985a359d9095235ca2b # v2.1.2
with:
version: ${{ matrix.target.version }}
- name: Install Supabase CLI via setup-cli@v3
id: setup-cli-v3
if: matrix.major-version == 'v3'
uses: supabase/setup-cli@689adcfb80d947100a1eab127289b97d1fb07b13 # v3.2.0
with:
version: ${{ matrix.target.version }}
- name: Verify supabase --version matches the expected version
shell: bash
run: |
set -euo pipefail
actual="$(supabase --version | tr -d '\r' | head -n1)"
echo "supabase --version: ${actual}"
if [ "${actual}" != "${VERSION}" ]; then
echo "Version mismatch: expected ${VERSION}, got ${actual}" >&2
exit 1
fi
- name: Warn if setup-cli fell back from npm
id: npm-source
if: matrix.major-version == 'v3'
shell: bash
env:
INSTALL_SOURCE: ${{ steps.setup-cli-v3.outputs.install-source }}
run: |
set -euo pipefail
if [ "${INSTALL_SOURCE}" != "npm" ]; then
echo "::warning::setup-cli fell back to ${INSTALL_SOURCE} because installing supabase@${VERSION} from npm failed; check the setup-cli step log"
echo "${INSTALL_SOURCE}" > npm-fallback.txt
echo "fallback=true" >> "$GITHUB_OUTPUT"
fi
- name: Record the npm fallback
if: steps.npm-source.outputs.fallback == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-fallback-v3-${{ matrix.runner }}-${{ matrix.target.version }}
path: npm-fallback.txt
# A separate job because GitHub Actions only honours `container:` on Linux runners, and mixing
# container + non-container entries in one matrix is fragile when the value is empty. The
# musl-vs-glibc + archive layout regressions from supabase/setup-cli#427 only reproduce inside
# a real Alpine container.
setup-cli-smoke-test-alpine:
name: setup-cli ${{ matrix.major-version }} (alpine, ${{ matrix.target.version }})
needs: resolve
if: needs.resolve.outputs.targets != '[]'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.resolve.outputs.targets) }}
major-version:
- v1
- v2
- v3
runs-on: ubuntu-latest
timeout-minutes: 15
# `node:20-alpine` ships a musl-linked Node, required for JavaScript-based actions to launch
# here — the runner's mounted glibc Node won't execute inside an Alpine container.
container:
# The image is pinned by tag, not by digest. It only hosts the installer smoke test, and
# nothing would update a digest here automatically.
# jactionlint ignore=unpinned-images
image: node:20-alpine
env:
VERSION: ${{ matrix.target.version }}
steps:
- name: Install Alpine prerequisites
run: apk add --no-cache bash curl git jq tar
- name: Install Supabase CLI via setup-cli@v1
if: matrix.major-version == 'v1'
uses: supabase/setup-cli@1dedf2c611547ede7232d26866dd3c56ab903bbb # v1.7.3
with:
version: ${{ matrix.target.version }}
- name: Install Supabase CLI via setup-cli@v2
if: matrix.major-version == 'v2'
uses: supabase/setup-cli@afb1b15109756ea5cf9d8985a359d9095235ca2b # v2.1.2
with:
version: ${{ matrix.target.version }}
- name: Install Supabase CLI via setup-cli@v3
id: setup-cli-v3
if: matrix.major-version == 'v3'
uses: supabase/setup-cli@689adcfb80d947100a1eab127289b97d1fb07b13 # v3.2.0
with:
version: ${{ matrix.target.version }}
- name: Verify supabase --version matches the expected version
shell: bash
run: |
set -euo pipefail
actual="$(supabase --version | tr -d '\r' | head -n1)"
echo "supabase --version: ${actual}"
if [ "${actual}" != "${VERSION}" ]; then
echo "Version mismatch: expected ${VERSION}, got ${actual}" >&2
exit 1
fi
- name: Warn if setup-cli fell back from npm
id: npm-source
if: matrix.major-version == 'v3'
shell: bash
env:
INSTALL_SOURCE: ${{ steps.setup-cli-v3.outputs.install-source }}
run: |
set -euo pipefail
if [ "${INSTALL_SOURCE}" != "npm" ]; then
echo "::warning::setup-cli fell back to ${INSTALL_SOURCE} because installing supabase@${VERSION} from npm failed; check the setup-cli step log"
echo "${INSTALL_SOURCE}" > npm-fallback.txt
echo "fallback=true" >> "$GITHUB_OUTPUT"
fi
- name: Record the npm fallback
if: steps.npm-source.outputs.fallback == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-fallback-v3-alpine-${{ matrix.target.version }}
path: npm-fallback.txt
setup-cli-smoke-test-github-release:
name: setup-cli v3 GitHub release fallback (ubuntu-latest, ${{ matrix.target.version }})
needs: resolve
if: needs.resolve.outputs.targets != '[]'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.resolve.outputs.targets) }}
runs-on: ubuntu-latest
timeout-minutes: 10
env:
VERSION: ${{ matrix.target.version }}
# An npm executable that always fails sends setup-cli down its GitHub release fallback.
SUPABASE_SETUP_CLI_NPM: "false"
steps:
- name: Install Supabase CLI via setup-cli@v3
id: setup-cli-v3
uses: supabase/setup-cli@689adcfb80d947100a1eab127289b97d1fb07b13 # v3.2.0
with:
version: ${{ matrix.target.version }}
- name: Verify supabase --version matches the expected version
shell: bash
run: |
set -euo pipefail
actual="$(supabase --version | tr -d '\r' | head -n1)"
echo "supabase --version: ${actual}"
if [ "${actual}" != "${VERSION}" ]; then
echo "Version mismatch: expected ${VERSION}, got ${actual}" >&2
exit 1
fi
- name: Verify setup-cli installed from the GitHub release
shell: bash
env:
INSTALL_SOURCE: ${{ steps.setup-cli-v3.outputs.install-source }}
run: |
set -euo pipefail
if [ "${INSTALL_SOURCE}" != "github-release" ]; then
echo "::error::setup-cli installed from ${INSTALL_SOURCE} instead of falling back to the GitHub release with npm disabled"
exit 1
fi
summary:
name: Summarize results
needs:
[
resolve,
setup-cli-smoke-test,
setup-cli-smoke-test-alpine,
setup-cli-smoke-test-github-release,
]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
timeout-minutes: 2
permissions:
actions: read
outputs:
status: ${{ steps.status.outputs.status }}
versions: ${{ steps.status.outputs.versions }}
steps:
- id: status
shell: bash
env:
RESOLVED: ${{ needs.resolve.result == 'success' }}
TARGETS: ${{ needs.resolve.outputs.targets }}
# A job that times out reports `cancelled`, so it counts as a failure here.
FAILED: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
run: |
set -euo pipefail
semver='[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?'
# Lists the versions read from stdin with their dist-tags, e.g. "3.3.0-beta.2 (beta)".
describe() {
jq -rRs --argjson targets "${TARGETS}" '
split("\n") | map(select(. != "")) | unique
| map(. as $v | ($targets | map(select(.version == $v)) | first | .tags) as $tags
| if $tags then "\($v) (\($tags))" else $v end)
| join(", ")' | tr -cd '0-9A-Za-z.,() -'
}
if [[ "${RESOLVED}" != "true" ]]; then
echo "status=setup-cli-smoke-untested" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "${FAILED}" == "true" ]]; then
versions="$(gh api --paginate "repos/${REPO}/actions/runs/${RUN_ID}/jobs?filter=latest" \
--jq '.jobs[] | select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out") | .name' \
| sed -nE "s/.*, (${semver})\)\$/\1/p" | describe)"
echo "status=setup-cli-smoke-failure" >> "$GITHUB_OUTPUT"
echo "versions=${versions}" >> "$GITHUB_OUTPUT"
exit 0
fi
names="$(gh api --paginate "repos/${REPO}/actions/runs/${RUN_ID}/artifacts" --jq '.artifacts[].name')"
if grep -q '^npm-fallback-' <<< "${names}"; then
versions="$(sed -nE "s/^npm-fallback-.*-(${semver})\$/\1/p" <<< "${names}" | describe)"
echo "status=setup-cli-npm-fallback" >> "$GITHUB_OUTPUT"
echo "versions=${versions}" >> "$GITHUB_OUTPUT"
fi
# Manual runs are for debugging, so only scheduled runs page. A summary job that failed or timed
# out before it could classify the run is reported as a smoke-test failure.
notify-slack:
name: Notify Slack
needs: summary
if: >-
${{ !cancelled() &&
github.event_name == 'schedule' &&
(needs.summary.result != 'success' || needs.summary.outputs.status != '') }}
uses: ./.github/workflows/slack-notify.yml
with:
package: Supabase CLI
status: ${{ needs.summary.outputs.status || 'setup-cli-smoke-failure' }}
versions: ${{ needs.summary.outputs.versions }}
secrets:
SLACK_RELEASE_WEBHOOK: ${{ secrets.SLACK_RELEASE_WEBHOOK }}