Created
April 22, 2020 02:20
-
-
Save pzi/9b52c3b485b5cf24fad6460eba6eeda7 to your computer and use it in GitHub Desktop.
GitHub Workflow to cache node_modules and run Jest.
This file contains hidden or 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: Test | |
on: [push] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.16.1] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache Node modules | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
uses: actions/cache@v1 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn-${{ env.cache-name }}- | |
${{ runner.os }}-yarn- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
run: | | |
echo "node version: $(node --version)" | |
echo "npm version: $(npm --version)" | |
echo CI=$CI | |
yarn install --frozen-lockfile | |
- name: Test App | |
run: | | |
echo CI=$CI | |
yarn test | |
env: | |
CI: true # default: true - causes warnings during build to fail the build. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment