2020-05-07 19:03:20 +00:00
|
|
|
name: cache-unit-tests
|
2020-05-12 16:37:03 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2020-07-21 15:33:05 +00:00
|
|
|
- main
|
2020-05-12 16:37:03 +00:00
|
|
|
paths-ignore:
|
|
|
|
- '**.md'
|
|
|
|
pull_request:
|
|
|
|
paths-ignore:
|
|
|
|
- '**.md'
|
2020-05-07 19:03:20 +00:00
|
|
|
|
|
|
|
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
|
2023-01-03 15:38:50 +00:00
|
|
|
uses: actions/setup-node@v3
|
2020-05-07 19:03:20 +00:00
|
|
|
with:
|
|
|
|
node-version: 12.x
|
|
|
|
|
2020-05-12 16:37:03 +00:00
|
|
|
# In order to save & restore cache from a shell script, certain env variables need to be set that are only available in the
|
2020-05-07 19:03:20 +00:00
|
|
|
# node context. This runs a local action that gets and sets the necessary env variables that are needed
|
|
|
|
- name: Set env variables
|
|
|
|
uses: ./packages/cache/__tests__/__fixtures__/
|
|
|
|
|
|
|
|
# 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 cache package
|
|
|
|
- name: Install root npm packages
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: Compile cache package
|
|
|
|
run: |
|
|
|
|
npm ci
|
|
|
|
npm run tsc
|
|
|
|
working-directory: packages/cache
|
|
|
|
|
|
|
|
- name: Generate files in working directory
|
|
|
|
shell: bash
|
2020-05-15 16:18:50 +00:00
|
|
|
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} test-cache
|
2020-05-07 19:03:20 +00:00
|
|
|
|
|
|
|
- name: Generate files outside working directory
|
|
|
|
shell: bash
|
2020-05-15 16:18:50 +00:00
|
|
|
run: packages/cache/__tests__/create-cache-files.sh ${{ runner.os }} ~/test-cache
|
2020-05-07 19:03:20 +00:00
|
|
|
|
|
|
|
# We're using node -e to call the functions directly available in the @actions/cache package
|
|
|
|
- name: Save cache using saveCache()
|
|
|
|
run: |
|
|
|
|
node -e "Promise.resolve(require('./packages/cache/lib/cache').saveCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'))"
|
|
|
|
|
2020-07-10 15:09:32 +00:00
|
|
|
- name: Delete cache folders before restoring
|
2020-06-19 18:43:38 +00:00
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
rm -rf test-cache
|
|
|
|
rm -rf ~/test-cache
|
|
|
|
|
2020-07-10 15:09:32 +00:00
|
|
|
- name: Restore cache using restoreCache() with http-client
|
|
|
|
run: |
|
|
|
|
node -e "Promise.resolve(require('./packages/cache/lib/cache').restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}',[],{useAzureSdk: false}))"
|
|
|
|
|
|
|
|
- name: Verify cache restored with http-client
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} test-cache
|
|
|
|
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
|
|
|
|
|
|
|
|
- name: Delete cache folders before restoring
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
rm -rf test-cache
|
|
|
|
rm -rf ~/test-cache
|
|
|
|
|
|
|
|
- name: Restore cache using restoreCache() with Azure SDK
|
2020-05-07 19:03:20 +00:00
|
|
|
run: |
|
|
|
|
node -e "Promise.resolve(require('./packages/cache/lib/cache').restoreCache(['test-cache','~/test-cache'],'test-${{ runner.os }}-${{ github.run_id }}'))"
|
|
|
|
|
2020-07-10 15:09:32 +00:00
|
|
|
- name: Verify cache restored with Azure SDK
|
2020-05-07 19:03:20 +00:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2020-05-15 16:18:50 +00:00
|
|
|
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} test-cache
|
2020-06-19 18:43:38 +00:00
|
|
|
packages/cache/__tests__/verify-cache-files.sh ${{ runner.os }} ~/test-cache
|