feat: wait for artifact to become available

This commit is contained in:
Ivan Dlugos 2024-08-15 12:02:25 +02:00
parent fa0a91b85d
commit e7141b6a94
6 changed files with 31303 additions and 37483 deletions

View file

@ -128,3 +128,81 @@ jobs:
Write-Error "File contents of downloaded artifacts are incorrect"
}
shell: pwsh
# Test "wait-until-available" functionality by running two jobs, one requiring artifacts of another
test-wait-producer:
name: 'Test: wait (producer)'
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
# TODO find a better way to ensure the "consumer" job started before the artifact is produced.
# Maybe run the download in the background process in the same job and checking it's result after upload-artifact.
- run: sleep 300
# Test "wait until available"end-to-end by uploading two artifacts and then downloading them
- name: Create artifacts
run: echo "Lorem ipsum dolor sit amet" > file-A.txt
- uses: actions/upload-artifact@v4
with:
name: 'Artifact-wait-${{ matrix.runs-on }}'
path: file-A.txt
test-wait-consumer:
name: 'Test: wait (consumer)'
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Setup Node 20
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
- run: npm install
- run: npm run build
# Test downloading a single artifact
- name: Download artifact A
uses: ./
with:
name: 'Artifact-wait-${{ matrix.runs-on }}'
path: some/new/path
wait-timeout: 600
# Test downloading an artifact using tilde expansion
- name: Download artifact A
uses: ./
with:
name: 'Artifact-wait-${{ matrix.runs-on }}'
path: ~/some/path/with/a/tilde
# no need for a timeout here
- name: Verify successful download
run: |
$file1 = "some/new/path/file-A.txt"
$file2 = "~/some/path/with/a/tilde/file-A.txt"
if(!(Test-Path -path $file1) -or !(Test-Path -path $file2))
{
Write-Error "Expected files do not exist"
}
if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Lorem ipsum dolor sit amet"))
{
Write-Error "File contents of downloaded artifacts are incorrect"
}
shell: pwsh