tests-alpine.yml
This file
Path
.github/workflows/tests-alpine.yml
215 lines · 8.9 KiB · YAML
Last changed by
[actions] cache container images, verified against digests looked up liveJordan Harbandbefore adoption5c05fb6
History of this fileTake it
[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 1–48why, one step back1name: 'Tests: alpine'23on: [push, pull_request]45permissions:6 contents: read78jobs:9 fast:10 permissions:11 contents: read1213 # Native runners per arch (no QEMU): arm64 uses the ubuntu-24.04-arm image.14 name: 'fast ${{ matrix.arch }} (alpine ${{ matrix.alpine }}, ${{ matrix.shell }})'15 runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}1617 strategy:18 fail-fast: false19 matrix:20 alpine:21 - '3.15'22 - '3.19'23 - '3'24 arch:25 - x6426 - arm6427 shell:28 - sh29 - bash30 - dash31 - zsh32 # - ksh (#574)3334 steps:35 - name: Harden Runner36 uses: step-security/harden-runner@v237 with:38 allowed-endpoints:39 github.com:44340 registry.npmjs.org:44341 raw.githubusercontent.com:44342 nodejs.org:44343 iojs.org:44344 unofficial-builds.nodejs.org:44345 dl-cdn.alpinelinux.org:44346 dl-cdn.alpinelinux.org:8047 registry-1.docker.io:44348 auth.docker.io:443[actions] pull container images through Google's Docker Hub mirrorJordan Harbandbefore adoption37be73f
line 49why, one step back49 mirror.gcr.io:443[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 50–69why, one step back50 production.cloudflare.docker.com:44351 production.cloudfront.docker.com:44352 - uses: actions/checkout@v653 id: checkout54 continue-on-error: true55 with:56 submodules: true57 - name: 'nvmrc submodule fallback (forks without their own nvmrc)'58 if: steps.checkout.outcome == 'failure'59 shell: bash60 run: |61 git submodule set-url test/fixtures/nvmrc https://github.com/nvm-sh/nvmrc.git62 git submodule sync --recursive63 git submodule update --init --recursive64 - uses: ljharb/actions/node/install@main65 name: 'npm install (on host; node_modules is mounted into the container)'66 with:67 node-version: 'lts/*'68 skip-ls-check: true69 - run: npm ls urchin[actions] cache container images, verified against digests looked up liveJordan Harbandbefore adoption5c05fb6
lines 70–83why, one step back70 # Pull through Google's Docker Hub mirror, which is not subject to Docker Hub's71 # anonymous pull rate limits, and cache the image; a cached image is only used72 # if it matches the digests the registry serves now73 - name: 'Resolve the alpine:${{ matrix.alpine }} image digests'74 id: image75 run: sh .github/scripts/docker-image.sh resolve mirror.gcr.io/library/alpine:${{ matrix.alpine }} >> "$GITHUB_OUTPUT"76 - uses: actions/cache@v677 with:78 path: ${{ runner.temp }}/docker-image.tar79 key: docker-image-${{ runner.arch }}-${{ steps.image.outputs.key }}80 - name: 'Load or pull the alpine:${{ matrix.alpine }} image'81 env:82 DIGESTS: ${{ steps.image.outputs.digests }}83 run: sh .github/scripts/docker-image.sh ensure mirror.gcr.io/library/alpine:${{ matrix.alpine }} "${RUNNER_TEMP}/docker-image.tar"[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 84–91why, one step back84 - name: 'Run fast tests on Alpine ${{ matrix.alpine }} (${{ matrix.arch }})'85 run: |86 docker run --rm \87 -v "${{ github.workspace }}:/workspace" \88 -w /workspace \89 -e "TEST_SHELL=${{ matrix.shell }}" \90 -e "TERM=xterm-256color" \91 -e "GITHUB_ACTIONS=true" \[actions] pull container images through Google's Docker Hub mirrorJordan Harbandbefore adoption37be73f
line 92why, one step back92 mirror.gcr.io/library/alpine:${{ matrix.alpine }} \[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 93–155why, one step back93 sh -c '94 set -ex95 cat /etc/alpine-release; uname -m96 for i in 1 2 3 4 5; do97 apk add --no-cache \98 make bash zsh dash \99 grep sed gawk coreutils util-linux findutils ncurses \100 curl wget ca-certificates openssl tar xz gzip git \101 sudo su-exec libstdc++ libgcc && break102 echo "apk add failed, attempt $i/5"; sleep $((i * 5))103 done104 # Mirror the ubuntu runner: run the suite as a non-root user with105 # passwordless sudo and a PTY so the permission/terminal tests106 # behave the same. The user takes the mounted checkout uid so107 # files stay host-owned (no chown; post-checkout cleanup works).108 # No node is installed, so no active version skews the output.109 HOST_UID="$(stat -c %u /workspace)"110 adduser -D -u "$HOST_UID" tester 2>/dev/null || adduser -D tester111 echo "tester ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/tester112 chmod 0440 /etc/sudoers.d/tester113 export NVM_DIR=/workspace HOME=/home/tester114 unset NVM_BIN NVM_INC NVM_CD_FLAGS115 su-exec tester script -q -e -c "make TEST_SUITE=fast SHELL=$TEST_SHELL URCHIN=/workspace/node_modules/.bin/urchin test-$TEST_SHELL" /dev/null116 '117118 musl-binary:119 permissions:120 contents: read121122 # Regression lock, same-era diagonal only: modern musl node needs a newer123 # libstdc++ than old Alpine ships, and arm64-musl exists only from124 # v20.20.1/v22.21.1/v24.9.0 (built on modern Alpine), so arm64 pins modern Alpine.125 name: 'musl-binary ${{ matrix.arch }} (alpine ${{ matrix.alpine }}, node ${{ matrix.node }})'126 runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}127128 strategy:129 fail-fast: false130 matrix:131 include:132 - { arch: x64, alpine: '3.10', node: v8.17.0 }133 - { arch: x64, alpine: '3.10', node: v10.24.1 }134 - { arch: x64, alpine: '3.12', node: v12.22.12 }135 - { arch: x64, alpine: '3.15', node: v14.21.3 }136 - { arch: x64, alpine: '3.16', node: v16.20.2 }137 - { arch: x64, alpine: '3.18', node: v18.20.4 }138 - { arch: x64, alpine: '3.20', node: v20.18.1 }139 - { arch: x64, alpine: '3', node: v22.12.0 }140 - { arch: arm64, alpine: '3.20', node: v20.20.1 }141 - { arch: arm64, alpine: '3', node: v22.21.1 }142 - { arch: arm64, alpine: '3', node: v24.9.0 }143144 steps:145 - name: Harden Runner146 uses: step-security/harden-runner@v2147 with:148 allowed-endpoints:149 github.com:443150 registry.npmjs.org:443151 unofficial-builds.nodejs.org:443152 dl-cdn.alpinelinux.org:443153 dl-cdn.alpinelinux.org:80154 registry-1.docker.io:443155 auth.docker.io:443[actions] pull container images through Google's Docker Hub mirrorJordan Harbandbefore adoption37be73f
line 156why, one step back156 mirror.gcr.io:443[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 157–161why, one step back157 production.cloudflare.docker.com:443158 production.cloudfront.docker.com:443159 - uses: actions/checkout@v6160 with:161 submodules: false[actions] cache container images, verified against digests looked up liveJordan Harbandbefore adoption5c05fb6
lines 162–175why, one step back162 # Pull through Google's Docker Hub mirror, which is not subject to Docker Hub's163 # anonymous pull rate limits, and cache the image; a cached image is only used164 # if it matches the digests the registry serves now165 - name: 'Resolve the alpine:${{ matrix.alpine }} image digests'166 id: image167 run: sh .github/scripts/docker-image.sh resolve mirror.gcr.io/library/alpine:${{ matrix.alpine }} >> "$GITHUB_OUTPUT"168 - uses: actions/cache@v6169 with:170 path: ${{ runner.temp }}/docker-image.tar171 key: docker-image-${{ runner.arch }}-${{ steps.image.outputs.key }}172 - name: 'Load or pull the alpine:${{ matrix.alpine }} image'173 env:174 DIGESTS: ${{ steps.image.outputs.digests }}175 run: sh .github/scripts/docker-image.sh ensure mirror.gcr.io/library/alpine:${{ matrix.alpine }} "${RUNNER_TEMP}/docker-image.tar"[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 176–182why, one step back176 - name: 'Install node ${{ matrix.node }} from a musl binary on Alpine ${{ matrix.alpine }}'177 run: |178 docker run --rm \179 -v "${{ github.workspace }}:/workspace" \180 -w /workspace \181 -e "NODE_VERSION=${{ matrix.node }}" \182 -e "TERM=xterm-256color" \[actions] pull container images through Google's Docker Hub mirrorJordan Harbandbefore adoption37be73f
line 183why, one step back183 mirror.gcr.io/library/alpine:${{ matrix.alpine }} \[actions] add `tests-alpine`: a green fast suite and a musl-binary regression matrixJordan Harbandbefore adoptiond83da5d
lines 184–215why, one step back184 sh -c '185 set -ex186 cat /etc/alpine-release; uname -m187 # libstdc++/libgcc are load-bearing: the unofficial musl node188 # binary dynamically links them. No build toolchain: -b forbids189 # the source fallback, so a missing binary is a hard failure.190 for i in 1 2 3 4 5; do191 apk add --no-cache \192 bash ca-certificates curl wget tar xz gzip \193 grep sed coreutils libstdc++ libgcc && break194 echo "apk add failed, attempt $i/5"; sleep $((i * 5))195 done196 export NVM_DIR=/workspace197 unset NVM_BIN NVM_INC NVM_CD_FLAGS198 # The default nodejs.org mirror serves no -musl artifacts; this one does.199 export NVM_NODEJS_ORG_MIRROR=https://unofficial-builds.nodejs.org/download/release200 . /workspace/nvm.sh --no-use201 nvm install -b --skip-default-packages "$NODE_VERSION"202 nvm use "$NODE_VERSION"203 [ "$(node -v)" = "$NODE_VERSION" ] || { echo "version mismatch: $(node -v)"; exit 1; }204 node -e "process.exit(0)"205 ldd "$(command -v node)" | grep -qi musl206 '207208 all:209 permissions:210 contents: none211 name: 'all alpine tests'212 needs: [fast, musl-binary]213 runs-on: ubuntu-latest214 steps:215 - run: true