2020-04-28 15:45:21 +02:00
|
|
|
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
|
2023-12-13 01:21:23 +01:00
|
|
|
uses: actions/checkout@v4
|
2020-04-28 15:45:21 +02:00
|
|
|
|
2023-12-13 01:21:23 +01:00
|
|
|
- name: Setup Node 20
|
|
|
|
uses: actions/setup-node@v4
|
2020-04-28 15:45:21 +02:00
|
|
|
with:
|
2023-12-13 01:21:23 +01:00
|
|
|
node-version: 20.x
|
2023-01-04 23:30:33 +01:00
|
|
|
cache: 'npm'
|
2020-04-28 15:45:21 +02:00
|
|
|
|
|
|
|
- name: npm install
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
- name: Compile
|
|
|
|
run: npm run build
|
|
|
|
|
|
|
|
- name: Lint
|
|
|
|
run: npm run lint
|
|
|
|
|
|
|
|
- name: Format
|
2023-12-13 01:21:23 +01:00
|
|
|
run: npm run format-check
|
2020-04-28 15:45:21 +02:00
|
|
|
|
|
|
|
- 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
|
2023-12-13 01:21:23 +01:00
|
|
|
|
2020-04-28 15:45:21 +02:00
|
|
|
- name: Upload artifact A
|
2023-12-14 21:10:05 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2020-04-28 15:45:21 +02:00
|
|
|
with:
|
2023-12-13 01:38:16 +01:00
|
|
|
name: Artifact-A-${{ matrix.runs-on }}
|
2020-04-28 15:45:21 +02:00
|
|
|
path: path/to/artifact-A
|
|
|
|
|
|
|
|
- name: Upload artifact B
|
2023-12-14 21:10:05 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2020-04-28 15:45:21 +02:00
|
|
|
with:
|
2023-12-13 01:38:16 +01:00
|
|
|
name: Artifact-B-${{ matrix.runs-on }}
|
2020-04-28 15:45:21 +02:00
|
|
|
path: path/to/artifact-B
|
|
|
|
|
|
|
|
# Test downloading a single artifact
|
|
|
|
- name: Download artifact A
|
|
|
|
uses: ./
|
|
|
|
with:
|
2023-12-13 01:38:16 +01:00
|
|
|
name: Artifact-A-${{ matrix.runs-on }}
|
2020-04-28 15:45:21 +02:00
|
|
|
path: some/new/path
|
|
|
|
|
2020-07-30 12:01:38 +02:00
|
|
|
# Test downloading an artifact using tilde expansion
|
|
|
|
- name: Download artifact A
|
|
|
|
uses: ./
|
|
|
|
with:
|
2023-12-13 01:38:16 +01:00
|
|
|
name: Artifact-A-${{ matrix.runs-on }}
|
2020-07-30 12:01:38 +02:00
|
|
|
path: ~/some/path/with/a/tilde
|
|
|
|
|
2020-04-28 15:45:21 +02:00
|
|
|
- name: Verify successful download
|
|
|
|
run: |
|
2020-07-30 12:01:38 +02:00
|
|
|
$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))
|
2020-04-28 15:45:21 +02:00
|
|
|
{
|
2020-07-30 12:01:38 +02:00
|
|
|
Write-Error "Expected files do not exist"
|
2020-04-28 15:45:21 +02:00
|
|
|
}
|
2020-07-30 12:01:38 +02:00
|
|
|
if(!((Get-Content $file1) -ceq "Lorem ipsum dolor sit amet") -or !((Get-Content $file2) -ceq "Lorem ipsum dolor sit amet"))
|
2020-04-28 15:45:21 +02:00
|
|
|
{
|
2020-07-30 12:01:38 +02:00
|
|
|
Write-Error "File contents of downloaded artifacts are incorrect"
|
2020-04-28 15:45:21 +02:00
|
|
|
}
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
# Test downloading both artifacts at once
|
|
|
|
- name: Download all Artifacts
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
path: some/other/path
|
|
|
|
|
|
|
|
- name: Verify successful download
|
|
|
|
run: |
|
2023-12-13 01:38:16 +01:00
|
|
|
$fileA = "some/other/path/Artifact-A-${{ matrix.runs-on }}/file-A.txt"
|
|
|
|
$fileB = "some/other/path/Artifact-B-${{ matrix.runs-on }}/file-B.txt"
|
2020-04-28 15:45:21 +02:00
|
|
|
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
|