Skip to content

Commit

Permalink
Use actions/setup-node cache (#145)
Browse files Browse the repository at this point in the history
* Use actions/setup-node cache

* Set actions/setup-node version to 3.4.1

* Set actions/setup-node version to 3.5.1

* Revert version change

* Set cache to 'yarn'

* Run prepare for a single Node version

* Add --immutable-cache to build, lint, test jobs

* Replace one more use of cache
  • Loading branch information
Mrtenz committed Nov 14, 2022
1 parent 5721b28 commit 243ce67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 49 deletions.
46 changes: 9 additions & 37 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,13 @@ jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
YARN_CACHE_DIR: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
YARN_VERSION: ${{ steps.yarn-version.outputs.YARN_VERSION }}
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Get Yarn cache directory
run: echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT"
id: yarn-version
- name: Cache Yarn dependencies
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --immutable

Expand All @@ -49,12 +33,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Restore Yarn dependencies
uses: actions/cache@v3
with:
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
- run: yarn --immutable
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn build
- name: Require clean working directory
shell: bash
Expand All @@ -78,12 +58,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Restore Yarn dependencies
uses: actions/cache@v3
with:
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
- run: yarn --immutable
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn lint
- name: Validate RC changelog
if: ${{ startsWith(github.head_ref, 'release/') }}
Expand Down Expand Up @@ -113,12 +89,8 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Restore Yarn dependencies
uses: actions/cache@v3
with:
path: ${{ needs.prepare.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ needs.prepare.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}-${{ matrix.node-version }}
- run: yarn --immutable
cache: 'yarn'
- run: yarn --immutable --immutable-cache
- run: yarn test
- name: Require clean working directory
shell: bash
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,11 @@ jobs:
run: exit 1
- name: Checkout the repository
uses: actions/checkout@v3
- name: Setup Node.js
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Get Yarn cache directory
run: echo "YARN_CACHE_DIR=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT"
id: yarn-cache-dir
- name: Get Yarn version
run: echo "YARN_VERSION=$(yarn --version)" >> "$GITHUB_OUTPUT"
id: yarn-version
- name: Cache yarn dependencies
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir.outputs.YARN_CACHE_DIR }}
key: yarn-cache-${{ runner.os }}-${{ steps.yarn-version.outputs.YARN_VERSION }}-${{ hashFiles('yarn.lock') }}
cache: 'yarn'
- name: Install npm dependencies
run: yarn --immutable
- name: Run build script
Expand Down

0 comments on commit 243ce67

Please sign in to comment.