From f3a6d4dd182aae605eea4c079bc9ebcef3600b5c Mon Sep 17 00:00:00 2001 From: TC Date: Wed, 8 Feb 2023 22:20:42 +0100 Subject: [PATCH] Adapt CI to yarn v3 --- .github/workflows/build.yml | 76 ++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7a9cfd9..c6d384ff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,20 +23,40 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Expose yarn config as "$GITHUB_OUTPUT" + id: yarn-config + shell: bash + run: | + echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - id: yarn-cache + # Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325 + # Yarn cache is also reusable between arch and os. + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-download-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} + key: yarn-download-cache-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- + yarn-download-cache- + + # Invalidated on yarn.lock changes + - name: Restore yarn install state + id: yarn-install-state-cache + uses: actions/cache@v3 + with: + path: .yarn/ci-cache/ + key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} - name: Install dependencies - run: yarn --frozen-lockfile + shell: bash + run: | + yarn install --immutable --inline-builds + env: + # CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action. + YARN_ENABLE_GLOBAL_CACHE: "false" # Use local cache folder to keep downloaded archives + YARN_NM_MODE: "hardlinks-local" # Hardlinks-(local|global) reduces io / node_modules size + YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change - name: Test uses: GabrielBB/xvfb-action@v1 @@ -81,20 +101,40 @@ jobs: with: node-version: ${{ env.NODE_VERSION }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Expose yarn config as "$GITHUB_OUTPUT" + id: yarn-config + shell: bash + run: | + echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - id: yarn-cache + # Yarn rotates the downloaded cache archives, @see https://github.com/actions/setup-node/issues/325 + # Yarn cache is also reusable between arch and os. + - name: Restore yarn cache + uses: actions/cache@v3 + id: yarn-download-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} + key: yarn-download-cache-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- + yarn-download-cache- + + # Invalidated on yarn.lock changes + - name: Restore yarn install state + id: yarn-install-state-cache + uses: actions/cache@v3 + with: + path: .yarn/ci-cache/ + key: ${{ runner.os }}-yarn-install-state-cache-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} - name: Install dependencies - run: yarn --frozen-lockfile + shell: bash + run: | + yarn install --immutable --inline-builds + env: + # CI optimizations. Overrides yarnrc.yml options (or their defaults) in the CI action. + YARN_ENABLE_GLOBAL_CACHE: "false" # Use local cache folder to keep downloaded archives + YARN_NM_MODE: "hardlinks-local" # Hardlinks-(local|global) reduces io / node_modules size + YARN_INSTALL_STATE_PATH: .yarn/ci-cache/install-state.gz # Very small speedup when lock does not change - name: Get version run: |