From 9a2c2ad401492a62d09da8e627068efa64ecd62e Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Thu, 13 Mar 2025 12:15:13 -0400 Subject: [PATCH] chore: upload individual binaries as artifacts (#3714) Signed-off-by: Keith Zantow --- .github/workflows/validations.yaml | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/validations.yaml b/.github/workflows/validations.yaml index 600a93000..8c02accc3 100644 --- a/.github/workflows/validations.yaml +++ b/.github/workflows/validations.yaml @@ -89,6 +89,61 @@ jobs: key: snapshot-build-${{ github.run_id }} + Upload-Snapshot-Artifacts: + # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline + name: "Upload snapshot artifacts" + needs: [Build-Snapshot-Artifacts] + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 + + - name: Bootstrap environment + uses: ./.github/actions/bootstrap + with: + download-test-fixture-cache: true + + - name: Download snapshot build + id: snapshot-cache + uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2 + with: + path: | + snapshot + .task + fail-on-cache-miss: true + key: snapshot-build-${{ github.run_id }} + + # workaround for https://github.com/actions/cache/issues/1265 + - name: (cache-miss) Snapshot build missing + if: steps.snapshot-cache.outputs.cache-hit != 'true' + run: echo "unable to download snapshots from previous job" && false + + - run: npm install @actions/artifact@2.2.2 + + - uses: actions/github-script@v7 + with: + script: | + const { readdirSync } = require('fs') + const { DefaultArtifactClient } = require('@actions/artifact') + const artifact = new DefaultArtifactClient() + const ls = d => readdirSync(d, { withFileTypes: true }) + const baseDir = "./snapshot" + const dirs = ls(baseDir).filter(f => f.isDirectory()).map(f => f.name) + const uploads = [] + for (const dir of dirs) { + // uploadArtifact returns Promise<{id, size}> + uploads.push(artifact.uploadArtifact( + // name of the archive: + `${dir}`, + // array of all files to include: + ls(`${baseDir}/${dir}`).map(f => `${baseDir}/${dir}/${f.name}`), + // base directory to trim from entries: + `${baseDir}/${dir}`, + { retentionDays: 30 } + )) + } + // wait for all uploads to finish + Promise.all(uploads) + Acceptance-Linux: # Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline name: "Acceptance tests (Linux)" @@ -214,6 +269,7 @@ jobs: - Acceptance-Linux - Acceptance-Mac - Cli-Linux + - Upload-Snapshot-Artifacts steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2