From fc7e71c7e6039c62ef16607ecf2ecd543ae6c919 Mon Sep 17 00:00:00 2001 From: "Marcus R. Brown" Date: Sat, 22 Oct 2022 15:47:01 -0700 Subject: [PATCH] feat(ci): update Yarn caching Simplify dependency caching for Yarn 3+ with Zero Installs. Inspired by actions/setup-node#325 and https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a. --- .github/workflows/ci.yaml | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 248a1d6..78b23e5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,47 +19,34 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0 + - name: Setup Node ${{ env.NODE_VERSION }} uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # tag=v3.5.1 with: node-version: ${{ env.NODE_VERSION }} - - name: Configure + - name: Configure Yarn + id: yarn-config shell: bash run: | npm config set scripts-prepend-node-path true echo "Node $(node --version)" echo "Yarn $(yarn --version)" - - - name: Checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0 - - - name: Get Yarn cache - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn config get cacheFolder)" + echo "yarn enableGlobalCache = $(yarn config get enableGlobalCache)" + echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - name: Use Yarn cache uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # tag=v3.0.11 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: | - **/.eslintcache - **/node_modules - ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} + key: yarn-cache-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-node-${{ env.NODE_VERSION }}-yarn- - - - name: Clear Yarn cache - if: steps.yarn-cache.outputs.cache-hit != 'true' - shell: bash - run: | - rm -rf .eslintcache - rm -rf node_modules - yarn cache clean + yarn-cache- - name: Install dependencies - run: yarn install --immutable + run: yarn install --immutable --inline-builds - name: Run tests run: yarn test