[Snyk] Fix for 1 vulnerabilities #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: artifact-unit-tests | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
runs-on: [ubuntu-latest, windows-latest, macos-latest] | |
fail-fast: false | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set Node.js 12.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12.x | |
# In order to upload & download artifacts from a shell script, certain env variables need to be set that are only available in the | |
# node context. This runs a local action that gets and sets the necessary env variables that are needed | |
- name: Set env variables | |
uses: ./packages/artifact/__tests__/ci-test-action/ | |
# Need root node_modules because certain npm packages like jest are configured for the entire repository and it won't be possible | |
# without these to just compile the artifacts package | |
- name: Install root npm packages | |
run: npm ci | |
- name: Compile artifact package | |
run: | | |
npm ci | |
npm run tsc | |
working-directory: packages/artifact | |
- name: Set artifact file contents | |
run: | | |
echo "::set-env name=non-gzip-artifact-content::hello" | |
echo "::set-env name=gzip-artifact-content::Some large amount of text that has a compression ratio that is greater than 100%. If greater than 100%, gzip is used to upload the file" | |
- name: Create files that will be uploaded | |
run: | | |
mkdir artifact-path | |
echo ${{ env.non-gzip-artifact-content }} > artifact-path/world.txt | |
echo ${{ env.gzip-artifact-content }} > artifact-path/gzip.txt | |
# We're using node -e to call the functions directly available in the @actions/artifact package | |
- name: Upload artifacts using uploadArtifact() | |
run: | | |
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-1',['artifact-path/world.txt'], '${{ github.workspace }}'))" | |
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-2',['artifact-path/gzip.txt'], '${{ github.workspace }}'))" | |
- name: Download artifacts using downloadArtifact() | |
run: | | |
mkdir artifact-1-directory | |
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadArtifact('my-artifact-1','artifact-1-directory'))" | |
mkdir artifact-2-directory | |
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadArtifact('my-artifact-2','artifact-2-directory'))" | |
- name: Verify downloadArtifact() | |
shell: bash | |
run: | | |
packages/artifact/__tests__/test-artifact-file.sh "artifact-1-directory/artifact-path/world.txt" "${{ env.non-gzip-artifact-content }}" | |
packages/artifact/__tests__/test-artifact-file.sh "artifact-2-directory/artifact-path/gzip.txt" "${{ env.gzip-artifact-content }}" | |
- name: Download artifacts using downloadAllArtifacts() | |
run: | | |
mkdir multi-artifact-directory | |
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().downloadAllArtifacts('multi-artifact-directory'))" | |
- name: Verify downloadAllArtifacts() | |
shell: bash | |
run: | | |
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-1/artifact-path/world.txt" "${{ env.non-gzip-artifact-content }}" | |
packages/artifact/__tests__/test-artifact-file.sh "multi-artifact-directory/my-artifact-2/artifact-path/gzip.txt" "${{ env.gzip-artifact-content }}" |