Last active
October 14, 2025 07:43
-
-
Save belgattitude/042f9caf10d029badbde6cf9d43e400a to your computer and use it in GitHub Desktop.
Revisions
-
belgattitude revised this gist
Oct 14, 2025 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -152,16 +152,17 @@ runs: ### Workflow action To use it in a workflow (please be sure to set package-manager-cache to false in setup/node >= 5) ```yml steps: - uses: actions/checkout@v5 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} package-manager-cache: false - name: 📥 Monorepo install uses: ./.github/actions/yarn-nm-install -
belgattitude revised this gist
May 24, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -131,7 +131,7 @@ runs: - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v4 with: path: ${{ inputs.cwd }}/.yarn/ci-cache key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} @@ -271,7 +271,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v4 - name: Cleanup run: | -
belgattitude revised this gist
May 24, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.2.1 - 25-05-2024 - fix a missing action/cache not upraded to v4 # # - 1.2.0 - 01-05-2024 - action/cache upraded to v4 # # - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # @@ -114,7 +115,7 @@ runs: - name: ♻️ Restore node_modules if: inputs.cache-node-modules == 'true' id: yarn-nm-cache uses: actions/cache@v4 with: path: ${{ inputs.cwd }}/**/node_modules key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} -
belgattitude revised this gist
May 1, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.2.0 - 01-05-2024 - action/cache upraded to v4 # # - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # -
belgattitude revised this gist
May 1, 2024 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Although @setup/node as a [built-in cache option](https://github.com/actions/set ### Requirements Yarn 3+/4+ with [nodeLinker: node-modules](https://yarnpkg.com/configuration/yarnrc#nodeLinker). (Not using yarn ? see the corresponding [pnpm 7/8+ action gist](https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31)) ### Structure @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.2.0 - 01-05-2024 - action/cache upraded to v4 # - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # @@ -102,7 +103,7 @@ runs: echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT - name: ♻️ Restore yarn cache uses: actions/cache@v4 id: yarn-download-cache with: path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} @@ -121,7 +122,7 @@ runs: - name: ♻️ Restore global npm cache folder if: inputs.cache-npm-cache == 'true' id: npm-global-cache uses: actions/cache@v4 with: path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }} key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} @@ -154,10 +155,10 @@ To use it in the workflows ```yml steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} -
belgattitude revised this gist
Jul 22, 2023 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -59,13 +59,13 @@ inputs: required: false default: '.' cache-prefix: description: 'Add a specific cache-prefix' required: false default: 'default' cache-npm-cache: description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)' required: false default: 'true' cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false @@ -77,7 +77,7 @@ inputs: enable-corepack: description: 'Enable corepack' required: false default: 'true' runs: using: 'composite' @@ -99,6 +99,7 @@ runs: echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT - name: ♻️ Restore yarn cache uses: actions/cache@v3 @@ -139,13 +140,12 @@ runs: run: yarn install --immutable --inline-builds env: # Overrides/align yarnrc.yml options (v3, v4) for a CI context YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only) YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present # Other environment variables HUSKY: '0' # By default do not run HUSKY install ``` ### Workflow action -
belgattitude revised this gist
Jul 22, 2023 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.1.0 - 22-07-2023 - Option to enable npm global cache folder. # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # # - 1.0.2 - 02-06-2023 - install-state default to false # @@ -61,6 +62,10 @@ inputs: description: "Add a specific cache-prefix" required: false default: 'default' cache-npm-cache: description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)' required: false default: 'true' cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false @@ -112,6 +117,14 @@ runs: path: ${{ inputs.cwd }}/**/node_modules key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore global npm cache folder if: inputs.cache-npm-cache == 'true' id: npm-global-cache uses: actions/cache@v3 with: path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }} key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache -
belgattitude revised this gist
Jul 15, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,7 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # # - 1.0.2 - 02-06-2023 - install-state default to false # # - 1.0.1 - 29-05-2023 - cache-prefix doc # -
belgattitude revised this gist
Jul 15, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.4 - 15-07-2023 - Fix corepack was always enabled. # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # # - 1.0.2 - 02-06-2023 - install-state default to false # # - 1.0.1 - 29-05-2023 - cache-prefix doc # @@ -78,7 +79,7 @@ runs: steps: - name: ⚙️ Enable Corepack if: inputs.enable-corepack == 'true' shell: bash working-directory: ${{ inputs.cwd }} run: corepack enable -
belgattitude revised this gist
Jul 5, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -126,8 +126,8 @@ runs: env: # Overrides/align yarnrc.yml options (v3, v4) for a CI context YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only) YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present # Other environment variables HUSKY: '0' # By default do not run HUSKY install -
belgattitude revised this gist
Jul 5, 2023 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.3 - 05-07-2023 - YARN_ENABLE_MIRROR to false (speed up cold start) # # - 1.0.2 - 02-06-2023 - install-state default to false # # - 1.0.1 - 29-05-2023 - cache-prefix doc # # - 1.0.0 - 27-05-2023 - new input: cache-prefix # @@ -124,8 +125,9 @@ runs: run: yarn install --immutable --inline-builds env: # Overrides/align yarnrc.yml options (v3, v4) for a CI context YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present # Other environment variables HUSKY: '0' # By default do not run HUSKY install -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -111,7 +111,7 @@ runs: key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -111,7 +111,7 @@ runs: key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: ${{ (inputs.cache-install-state == 'true') && (inputs.cache-node-modules == 'true') }} id: yarn-install-state-cache uses: actions/cache@v3 with: -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -43,6 +43,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.2 - 02-06-2023 - install-state default to false # # - 1.0.1 - 29-05-2023 - cache-prefix doc # # - 1.0.0 - 27-05-2023 - new input: cache-prefix # ######################################################################################## @@ -65,7 +66,7 @@ inputs: cache-install-state: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'false' enable-corepack: description: 'Enable corepack' required: false -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -155,7 +155,9 @@ Be sure that your `.yarnrc.yml` sets the `nodeLinker: node-modules` parameter: ```yaml nodeLinker: node-modules #compressionLevel: 0 # Will give 10%-30% install speed up, but takes more space locally # This line can be ommited if corepack is enabled (requires the packageManager field in package.json) yarnPath: .yarn/releases/yarn-3.6.0.cjs # or 4.0.0-rc.45 (rc's seems quite stable imho)... ``` -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -156,7 +156,7 @@ Be sure that your `.yarnrc.yml` sets the `nodeLinker: node-modules` parameter: nodeLinker: node-modules # This line can be omiited with corepack enabled in this case set the packageManager field in package.json yarnPath: .yarn/releases/yarn-3.6.0.cjs # or 4.0.0-rc.45 (rc's seems quite stable imho)... ``` -
belgattitude revised this gist
Jun 2, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # uses: ./.github/actions/yarn-nm-install # # with: # # enable-corepack: false # (default = 'false') # # cwd: ${{ github.workspace }}/apps/my-app # (default = '.') # # cache-prefix: add cache key prefix # (default = 'default') # # cache-node-modules: false # (default = 'false') # # cache-install-state: false # (default = 'false') # -
belgattitude revised this gist
May 29, 2023 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # with: # # enable-corepack: false # (default = 'false') # # cwd: ${{ github.workspace/apps/strapi }} # (default = '.') # # cache-prefix: add cache key prefix # (default = 'default') # # cache-node-modules: false # (default = 'false') # # cache-install-state: false # (default = 'false') # # # @@ -173,12 +173,13 @@ yarnPath: .yarn/releases/yarn-4.0.0-rc.44.cjs # or 3.5.1 (rc are really stable i ``` | Parameter | Default | Comment | |----------------------|-----------|-------------------------------------------------------| | cwd | '.' | Run the install in a specific folder. | | enable-corepack | `false` | Activate corepack. | | cache-prefix | `default` | Allows to have multiple distinct install. | | cache-node-modules | `false` | Cache node-modules (only for exceptional use-cases) | | cache-install-state | `false` | Only useful is cache-node-modules is activated | This action always caches the `yarn config get cacheFolder` to avoid fetching archives -
belgattitude revised this gist
May 29, 2023 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,15 +33,17 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # - name: 📥 Monorepo install # # uses: ./.github/actions/yarn-nm-install # # with: # # enable-corepack: false # (default = 'false') # # cwd: ${{ github.workspace/apps/strapi }} # (default = '.') # # cache-prefix: add cacge key prefix # (default = 'default') # # cache-node-modules: false # (default = 'false') # # cache-install-state: false # (default = 'false') # # # # Reference: # # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.1 - 29-05-2023 - cache-prefix doc # # - 1.0.0 - 27-05-2023 - new input: cache-prefix # ######################################################################################## -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -40,6 +40,9 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # # # Reference: # # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # # # # Versions: # # - 1.0.0 - 27-05-2023 - new input: cache-prefix # ######################################################################################## name: 'Monorepo install (yarn)' @@ -49,6 +52,10 @@ inputs: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false default: '.' cache-prefix: description: "Add a specific cache-prefix" required: false default: 'default' cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false @@ -88,25 +95,25 @@ runs: id: yarn-download-cache with: path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} restore-keys: | yarn-download-cache-${{ inputs.cache-prefix }}- - name: ♻️ Restore node_modules if: inputs.cache-node-modules == 'true' id: yarn-nm-cache uses: actions/cache@v3 with: path: ${{ inputs.cwd }}/**/node_modules key: yarn-nm-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: path: ${{ inputs.cwd }}/.yarn/ci-cache key: yarn-install-state-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: 📥 Install dependencies shell: bash -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -167,9 +167,9 @@ yarnPath: .yarn/releases/yarn-4.0.0-rc.44.cjs # or 3.5.1 (rc are really stable i | Parameter | Default | Comment | |----------------------|---------|-------------------------------------------------------| | cwd | '.' | Run the install in a specific folder | | enable-corepack | `false` | Activate corepack | | cache-node-modules | `false` | Cache node-modules (only for exceptional use-cases) | | cache-install-state | `false` | Only useful is cache-node-modules is activated | This action always caches the `yarn config get cacheFolder` to avoid fetching archives -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -189,7 +189,7 @@ Link: https://github.com/belgattitude/compare-package-managers#-install-speed In some circumstances, you might archieve better install time by caching the `node_modules` folder as well. This will impact the `yarn link step`. The link step is where yarn runs postinstalls (node-gyp, download binaries...). But be aware that the time saved by doing this creates an overhead for the cache fetch/compression/persist (@action/cache has more to deal with). Use this option with care and in exceptional circumstances (ie you have multiple dependendent steps that run install). Also remember that the node_modules folder does not have the same portability/reliability than the recommended yarn cache folder. To get an idea of the performance gains, see this table: | Command | Mean [s] | Min [s] | Max [s] | Relative | -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,9 +6,6 @@ Although @setup/node as a [built-in cache option](https://github.com/actions/set Yarn 3+ with [nodeLinker: node-modules](https://yarnpkg.com/configuration/yarnrc#nodeLinker). (Not using yarn ? see the corresponding [pnpm 7/8+ action gist](https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31)) ### Structure -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 57 additions and 30 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -48,10 +48,10 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste name: 'Monorepo install (yarn)' description: 'Run yarn install with node_modules linker and cache enabled' inputs: cwd: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false default: '.' cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false @@ -60,10 +60,10 @@ inputs: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'true' enable-corepack: description: 'Enable corepack' required: false default: 'false' runs: using: 'composite' @@ -142,30 +142,69 @@ To use it in the workflows uses: ./.github/actions/yarn-nm-install ``` ### Yarn config Be sure that your `.yarnrc.yml` sets the `nodeLinker: node-modules` parameter: ```yaml nodeLinker: node-modules # This line can be omiited with corepack enabled in this case set the packageManager field in package.json yarnPath: .yarn/releases/yarn-4.0.0-rc.44.cjs # or 3.5.1 (rc are really stable imho)... ``` ### Input parameters ```yml - name: 📥 Monorepo install uses: ./.github/actions/yarn-nm-install with: cwd: '.' enable-corepack: false cache-node-modules: true cache-install-state: true ``` | Parameter | Default | Comment | |----------------------|---------|-------------------------------------------------------| | cwd | '.' | Run the install in a specific folder | | enable-corepack | 'false' | Activate corepack | | cache-node-modules | 'false' | Cache node-modules (only for exceptional use-cases) | | cache-install-state | 'false' | Only useful is cache-node-modules is activated | This action always caches the `yarn config get cacheFolder` to avoid fetching archives from the npm repository. Depending on the number of your dependencies, this generally gives a 2x overall improvement. It affects the `yarn fetch step` and protects from npm outages as well. An example of speed gain could be: | CI Scenario | Install | CI fetch cache | Total | Cache size | CI persist cache | |-------------------------|--------:|---------------:|--------:|-----------:|-----------------:| | yarn4 with cache | 34s | 3s | **37s** | 201Mb | *(±5s)* | | yarn4 without cache | 83s | N/A | **83s** | N/A | N/A | Link: https://github.com/belgattitude/compare-package-managers#-install-speed In some circumstances, you might archieve better install time by caching the `node_modules` folder as well. This will impact the `yarn link step`. The link step is where yarn runs postinstalls (node-gyp, download binaries...). But be aware that the time saved by doing this creates an overhead for the cache fetch/compression/persist (@action/cache has more to deal with). Use this option with care and in exceptional circumstances (ie you have multiple dependendent steps that run install). Also remember that the node_modules folder does not have the same portability/reliability than the recommended yarn cache folder. To get an idea of the performance gains, see this issure: | Command | Mean [s] | Min [s] | Max [s] | Relative | |:-------------------------------------------|---------------:|--------:|--------:|------------:| | `yarnCache:on - installState:off - nm:off` | 22.717 ± 0.225 | 22.510 | 22.957 | 5.95 ± 0.25 | | `yarnCache:on - installState:on - nm:off` | 21.350 ± 0.216 | 21.185 | 21.595 | 5.59 ± 0.24 | | `yarnCache:on - installState:off - nm:on` | 11.676 ± 0.041 | 11.647 | 11.722 | 3.06 ± 0.13 | | `yarnCache:on - installState:on - nm:on` | 3.820 ± 0.156 | 3.645 | 3.946 | 1.00 | Link: https://github.com/belgattitude/compare-package-managers#compare-yarn-options ### Results @@ -228,17 +267,5 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` -
belgattitude revised this gist
May 27, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,8 +37,8 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # uses: ./.github/actions/yarn-nm-install # # with: # # enable-corepack: false # (default) # # cache-node-modules: false # (default) # # cache-install-state: false # (default) # # cwd: ${{ github.workspace/apps/strapi }} # (default = '.') # # # # Reference: # @@ -104,7 +104,7 @@ runs: key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: -
belgattitude revised this gist
May 20, 2023 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # uses: ./.github/actions/yarn-nm-install # # with: # # enable-corepack: false # (default) # # cache-install-state: true # (default) # # cache-node-modules: false # (default) # # cwd: ${{ github.workspace/apps/strapi }} # (default = '.') # # # @@ -59,7 +59,7 @@ inputs: cache-install-state: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'true' cwd: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false @@ -104,7 +104,7 @@ runs: key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: -
belgattitude revised this gist
May 20, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,11 +55,11 @@ inputs: cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false default: 'false' cache-install-state: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'false' cwd: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false -
belgattitude revised this gist
May 6, 2023 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -55,11 +55,11 @@ inputs: cache-node-modules: description: 'Cache node_modules, might speed up link step (invalidated lock/os/node-version/branch)' required: false default: 'true' cache-install-state: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'true' cwd: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false @@ -91,7 +91,7 @@ runs: id: yarn-download-cache with: path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }} key: yarn-download-cache-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} restore-keys: | yarn-download-cache- @@ -101,15 +101,15 @@ runs: uses: actions/cache@v3 with: path: ${{ inputs.cwd }}/**/node_modules key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: path: ${{ inputs.cwd }}/.yarn/ci-cache key: yarn-install-state-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }} - name: 📥 Install dependencies shell: bash @@ -122,6 +122,7 @@ runs: YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present # Other environment variables HUSKY: '0' # By default do not run HUSKY install ``` ### Workflow action -
belgattitude revised this gist
May 6, 2023 . 1 changed file with 9 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -39,7 +39,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # enable-corepack: false # (default) # # cache-install-state: false # (default) # # cache-node-modules: false # (default) # # cwd: ${{ github.workspace/apps/strapi }} # (default = '.') # # # # Reference: # # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # @@ -76,14 +76,14 @@ runs: run: corepack enable - name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT" id: yarn-config shell: bash working-directory: ${{ inputs.cwd }} env: YARN_ENABLE_GLOBAL_CACHE: 'false' run: | echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT - name: ♻️ Restore yarn cache @@ -99,18 +99,16 @@ runs: if: inputs.cache-node-modules == 'true' id: yarn-nm-cache uses: actions/cache@v3 with: path: ${{ inputs.cwd }}/**/node_modules key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} - name: ♻️ Restore yarn install state if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 with: path: ${{ inputs.cwd }}.yarn/ci-cache key: yarn-install-state-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} - name: 📥 Install dependencies @@ -119,12 +117,11 @@ runs: run: yarn install --immutable --inline-builds env: # Overrides/align yarnrc.yml options (v3, v4) for a CI context YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present # Other environment variables HUSKY: '0' # By default do not run HUSKY install ``` ### Workflow action -
belgattitude revised this gist
May 6, 2023 . 1 changed file with 12 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -39,6 +39,7 @@ Create a file in `.github/actions/yarn-nm-install/action.yml` and paste # enable-corepack: false # (default) # # cache-install-state: false # (default) # # cache-node-modules: false # (default) # # cwd: ${{ github.workspace }} # (default = '.') # # # # Reference: # # - latest: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a # @@ -59,7 +60,10 @@ inputs: description: 'Cache yarn install state, might speed up resolution step when node-modules cache is activated (invalidated lock/os/node-version/branch)' required: false default: 'false' cwd: description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()" required: false default: '.' runs: using: 'composite' @@ -68,16 +72,18 @@ runs: - name: ⚙️ Enable Corepack if: ${{ inputs.enable-corepack }} == 'true' shell: bash working-directory: ${{ inputs.cwd }} run: corepack enable - name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT" id: yarn-config shell: bash working-directory: ${{ inputs.cwd }} env: YARN_ENABLE_GLOBAL_CACHE: "false" run: | echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT echo "CURRENT_NODE_VERSION="node-$(node --version)" >> $GITHUB_OUTPUT echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT - name: ♻️ Restore yarn cache @@ -93,6 +99,7 @@ runs: if: inputs.cache-node-modules == 'true' id: yarn-nm-cache uses: actions/cache@v3 working-directory: ${{ inputs.cwd }} with: path: '**/node_modules' key: yarn-nm-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} @@ -101,12 +108,14 @@ runs: if: inputs.cache-install-state == 'true' && inputs.cache-node-modules == 'true' id: yarn-install-state-cache uses: actions/cache@v3 working-directory: ${{ inputs.cwd }} with: path: .yarn/ci-cache key: yarn-install-state-cache-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ steps.yarn-config.outputs.CURRENT_BRANCH }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }} - name: 📥 Install dependencies shell: bash working-directory: ${{ inputs.cwd }} run: yarn install --immutable --inline-builds env: # Overrides/align yarnrc.yml options (v3, v4) for a CI context @@ -116,7 +125,6 @@ runs: # Other environment variables HUSKY: '0' # By default do not run HUSKY install ``` ### Workflow action
NewerOlder