name: Test on: push: paths-ignore: - '**.md' pull_request: paths-ignore: - '**.md' jobs: build: name: Build strategy: matrix: runs-on: [ubuntu-latest, macos-latest, windows-latest] fail-fast: false runs-on: ${{ matrix.runs-on }} steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node 20 uses: actions/setup-node@v4 with: node-version: 20.x cache: 'npm' - name: npm install run: npm install - name: Compile run: npm run build - name: Lint run: npm run lint - name: Format run: npm run format-check - name: Create artifacts run: | mkdir -p path/to/artifact-A mkdir -p path/to/artifact-B echo "Lorem ipsum dolor sit amet" > path/to/artifact-A/file-A.txt echo "Hello world from file B" > path/to/artifact-B/file-B.txt - name: Upload artifact A uses: actions/upload-artifact@v4 with: name: Artifact-A-${{ matrix.runs-on }} path: path/to/artifact-A - name: Upload artifact B uses: actions/upload-artifact@v4 with: name: Artifact-B-${{ matrix.runs-on }} path: path/to/artifact-B # Test downloading a single artifact - name: Download artifact A uses: ./ with: name: Artifact-A-${{ matrix.runs-on }} path: some/new/path # Test downloading an artifact using tilde expansion - name: Download artifact A uses: ./ with: name: Artifact-A-${{ matrix.runs-on }} path: ~/some/path/with/a/tilde - 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 # Test downloading both artifacts at once - name: Download all Artifacts uses: ./ with: path: some/other/path - name: Verify successful download run: | $fileA = "some/other/path/Artifact-A-${{ matrix.runs-on }}/file-A.txt" $fileB = "some/other/path/Artifact-B-${{ matrix.runs-on }}/file-B.txt" if(!(Test-Path -path $fileA) -or !(Test-Path -path $fileB)) { Write-Error "Expected files do not exist" } if(!((Get-Content $fileA) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $fileB) -ceq "Hello world from file B")) { Write-Error "File contents of downloaded artifacts are incorrect" } shell: pwsh if-not-found-with-name: name: Test `if-not-found` param wih name specified runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Verify not existing artifact with default value id: default continue-on-error: true uses: ./ with: name: not-existing-name - name: Check default run: ${{ steps.default.outcome == 'failure' }} - name: Verify not existing artifact `error` id: error continue-on-error: true uses: ./ with: name: not-existing-name if-not-found: error - name: Check `error` run: ${{ steps.error.outcome == 'failure' }} - name: Verify not existing artifact `warning` id: warning uses: ./ with: name: not-existing-name if-not-found: warn - name: Check `warning` run: ${{ steps.warning.outcome == 'success' }} - name: Verify not existing artifact `ignore` id: ignore uses: ./ with: name: not-existing-name if-not-found: ignore - name: Check `ignore` run: ${{ steps.ignore.outcome == 'success' }} if-not-found-without-name: name: Test `if-not-found` param wih name specified runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Verify not existing artifact with default value id: default continue-on-error: true uses: ./ - name: Check default run: ${{ steps.default.outcome == 'failure' }} - name: Verify not existing artifact `error` id: error continue-on-error: true uses: ./ with: if-not-found: error - name: Check `error` run: ${{ steps.error.outcome == 'failure' }} - name: Verify not existing artifact `warning` id: warning uses: ./ with: if-not-found: warn - name: Check `warning` run: ${{ steps.warning.outcome == 'success' }} - name: Verify not existing artifact `ignore` id: ignore uses: ./ with: if-not-found: ignore - name: Check `ignore` run: ${{ steps.ignore.outcome == 'success' }}