From 4da2e4d46a2307e4d7c3083fbdc7142b6000b93e Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 13:43:31 +0200 Subject: [PATCH 1/9] Add cache examples, update to latest actions Closes #2 --- .github/workflows/nvm.yml | 42 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index d923563..1e161dc 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -5,9 +5,47 @@ jobs: runs-on: ubuntu-latest steps: - run: node --version - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: | nvm install --latest-npm --no-progress - echo "::set-env name=PATH::${NVM_BIN}:${PATH}" + echo "$(dirname $(which node))" >> $GITHUB_PATH shell: bash --login {0} - run: node --version + + # Optional: Cache npm dependencies + - name: Get npm cache directory + id: npm-cache-dir + shell: bash + run: echo "dir=$(npm config get cache)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + # Optional: Cache Yarn v1 dependencies + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v4 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + # Optional: Cache pnpm store + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- From e0cbdbdfb98cc5c6e2c2db705d0c006cf93fd8f7 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 16:40:53 +0200 Subject: [PATCH 2/9] Fix cache key name Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> --- .github/workflows/nvm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index 1e161dc..10588a8 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -21,9 +21,9 @@ jobs: id: npm-cache with: path: ${{ steps.npm-cache-dir.outputs.dir }} - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | - ${{ runner.os }}-node- + ${{ runner.os }}-npm- # Optional: Cache Yarn v1 dependencies - name: Get yarn cache directory path From b33d1fab2ccd836a0be809c50fe13e050f5a4b09 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 16:45:51 +0200 Subject: [PATCH 3/9] Change names for consistency Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> --- .github/workflows/nvm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index 10588a8..7d91010 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -26,8 +26,8 @@ jobs: ${{ runner.os }}-npm- # Optional: Cache Yarn v1 dependencies - - name: Get yarn cache directory path - id: yarn-cache-dir-path + - name: Get yarn cache directory + id: yarn-cache-dir run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) From 1706c0d386af2a3d167981a3418c80cf2c7235b0 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 17:45:57 +0200 Subject: [PATCH 4/9] Enable running on PRs --- .github/workflows/nvm.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index 7d91010..ca5025c 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -1,5 +1,9 @@ name: nvm -on: [push] +on: + push: + branches: + - master + pull_request: jobs: run: runs-on: ubuntu-latest From 219c6ee92f90a8618ecec7270167b7b2dd0d7da1 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 17:56:44 +0200 Subject: [PATCH 5/9] Add pnpm/action-setup --- .github/workflows/nvm.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index ca5025c..05afe8c 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -8,6 +8,11 @@ jobs: run: runs-on: ubuntu-latest steps: + # Optional: Set up pnpm + - uses: pnpm/action-setup@v4 + with: + version: latest + - run: node --version - uses: actions/checkout@v4 - run: | From c3ba283cd0517ab5fd94fbfa7df95075b612baab Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 18:01:49 +0200 Subject: [PATCH 6/9] Switch pnpm cache steps to use $GITHUB_OUTPUT --- .github/workflows/nvm.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index 05afe8c..facab96 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -37,24 +37,25 @@ jobs: # Optional: Cache Yarn v1 dependencies - name: Get yarn cache directory id: yarn-cache-dir + shell: bash run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + path: ${{ steps.yarn-cache-dir.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- # Optional: Cache pnpm store - name: Get pnpm store directory + id: pnpm-cache-dir shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - uses: actions/cache@v4 name: Setup pnpm cache with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + path: ${{ steps.pnpm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | - ${{ runner.os }}-pnpm-store- + ${{ runner.os }}-pnpm- From 3f4af212a6b31e2107db034df429371cb82365f2 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Tue, 13 Aug 2024 18:09:17 +0200 Subject: [PATCH 7/9] Switch `which node` to `nvm which node` From the docs: https://github.com/nvm-sh/nvm#:~:text=In%20place%20of,version%20of%20node > In place of a version pointer like "14.7" or "16.3" or "12.22.1", you can use the following special default aliases with `nvm install`, `nvm use`, `nvm run`, `nvm exec`, `nvm which`, etc: > > - `node`: this installs the latest version of [`node`](https://nodejs.org/en/) --- .github/workflows/nvm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index facab96..88a5f8d 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - run: | nvm install --latest-npm --no-progress - echo "$(dirname $(which node))" >> $GITHUB_PATH + echo "$(dirname $(nvm which node))" >> $GITHUB_PATH shell: bash --login {0} - run: node --version From 05a3f7965e06a91aad68dea5674bc3e2a6556941 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 14 Aug 2024 09:34:51 +0200 Subject: [PATCH 8/9] Upgrade to Node.js 20.16.0 --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 72f5135..8ce7030 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14.4.0 +20.16.0 From 7723a26cb09dbd880ee96c1cf24319b2930fe7ce Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 14 Aug 2024 09:38:41 +0200 Subject: [PATCH 9/9] Upgrade to pnpm v9 --- .github/workflows/nvm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nvm.yml b/.github/workflows/nvm.yml index 88a5f8d..4c7d4e7 100644 --- a/.github/workflows/nvm.yml +++ b/.github/workflows/nvm.yml @@ -11,7 +11,7 @@ jobs: # Optional: Set up pnpm - uses: pnpm/action-setup@v4 with: - version: latest + version: 9 - run: node --version - uses: actions/checkout@v4