From 2ad687a32e07b6a6864773bc61602cfacc19476a Mon Sep 17 00:00:00 2001 From: Rob Herley Date: Wed, 17 Jan 2024 17:54:10 -0500 Subject: [PATCH] add integration test for delete --- .github/workflows/artifact-tests.yml | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/artifact-tests.yml b/.github/workflows/artifact-tests.yml index aa0ab371..a74db480 100644 --- a/.github/workflows/artifact-tests.yml +++ b/.github/workflows/artifact-tests.yml @@ -72,7 +72,7 @@ jobs: console.log('Successfully blocked second artifact upload') } verify: - name: Verify + name: Verify and Delete runs-on: ubuntu-latest needs: [upload] steps: @@ -164,3 +164,31 @@ jobs: } } } + - name: Delete Artifacts + uses: actions/github-script@v7 + with: + script: | + const {default: artifactClient} = require('./packages/artifact/lib/artifact') + + const artifactsToDelete = [ + 'my-artifact-ubuntu-latest', + 'my-artifact-windows-latest', + 'my-artifact-macos-latest' + ] + + for (const artifactName of artifactsToDelete) { + const {id} = await artifactClient.deleteArtifact(artifactName) + } + + const {artifacts} = await artifactClient.listArtifacts({latest: true}) + const foundArtifacts = artifacts.filter(artifact => + artifactsToDelete.includes(artifact.name) + ) + + if (foundArtifacts.length !== 0) { + console.log('Unexpected length of found artifacts:', foundArtifacts) + throw new Error( + `Expected 0 artifacts but found ${foundArtifacts.length} artifacts.` + ) + } +