Files
VoiceStudio/.github/workflows/action-contracts.yml
Palash Debnath e6934abf0c ci(actions): retry the same-job artifact download once (#4273)
The by-name download right after upload intermittently fails with 'Artifact not found' while the artifact list catches up. This hit #4266 and #4268 three times. Retry once after 20 seconds; the byte verification still runs on the downloaded files.
2026-11-20 11:14:06 +05:30

111 lines
4.5 KiB
YAML

name: Action contracts
on:
pull_request:
paths: ['.github/workflows/**', '.github/actions/**']
push:
branches: [main]
paths: ['.github/workflows/**', '.github/actions/**']
permissions:
contents: read
concurrency:
group: action-contracts-${{ github.event.pull_request.number || github.ref }}-${{ github.event_name == 'pull_request' && 'pr' || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
contracts:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-latest, macos-latest]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Create two byte fixtures
run: |
node --input-type=module <<'JS'
import { mkdirSync, writeFileSync } from 'node:fs';
mkdirSync('contract-fixture', { recursive: true });
writeFileSync('contract-fixture/visible.txt', 'VoiceStudio artifact contract\n');
writeFileSync('contract-fixture/.hidden.txt', Buffer.from([0, 13, 10, 255, 65]));
JS
# Leave archive unset: multi-file upload must retain the pinned default.
- name: Upload the named archive
id: archive
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: action-contract-${{ runner.os }}
path: contract-fixture/
include-hidden-files: true
if-no-files-found: error
retention-days: 1
- name: Check the artifact ID contract
env:
ARTIFACT_ID: ${{ steps.archive.outputs.artifact-id }}
run: |
node --input-type=module <<'JS'
import assert from 'node:assert/strict';
assert.match(process.env.ARTIFACT_ID ?? '', /^[1-9][0-9]*$/);
JS
# The artifact list is eventually consistent: a by-name download in the
# same job as the upload can briefly report "Artifact not found". Retry
# once after a pause instead of failing the contract on that race.
- name: Download the named archive
id: download
continue-on-error: true
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: action-contract-${{ runner.os }}
path: contract-restored
- name: Wait before retrying the download
if: steps.download.outcome == 'failure'
run: sleep 20
- name: Retry the named archive download
if: steps.download.outcome == 'failure'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: action-contract-${{ runner.os }}
path: contract-restored
- name: Verify names and exact downloaded bytes
run: |
node --input-type=module <<'JS'
import assert from 'node:assert/strict';
import { readdirSync, readFileSync } from 'node:fs';
assert.deepEqual(readdirSync('contract-restored').sort(), ['.hidden.txt', 'visible.txt']);
assert.deepEqual(readFileSync('contract-restored/visible.txt'), Buffer.from('VoiceStudio artifact contract\n'));
assert.deepEqual(readFileSync('contract-restored/.hidden.txt'), Buffer.from([0, 13, 10, 255, 65]));
JS
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
if: runner.os == 'Linux'
- name: Prepare the scratch Docker context
if: runner.os == 'Linux'
run: |
node --input-type=module <<'JS'
import { writeFileSync } from 'node:fs';
writeFileSync('contract-fixture/Dockerfile', 'FROM scratch\nCOPY visible.txt /proof.txt\n');
JS
- name: Build without registry credentials or publication
if: runner.os == 'Linux'
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: contract-fixture
file: contract-fixture/Dockerfile
push: false
outputs: type=local,dest=contract-image
- name: Verify the actual build export
if: runner.os == 'Linux'
run: |
node --input-type=module <<'JS'
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
assert.deepEqual(readFileSync('contract-image/proof.txt'), Buffer.from('VoiceStudio artifact contract\n'));
JS