From 5f2d6d51cb1201d8274c7785996150872318702d Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 10 Feb 2023 14:46:16 +0100 Subject: [PATCH 1/3] build: Improve CI cache --- .github/workflows/build.yml | 63 ++++++++++++++++++------------------- .gitignore | 1 + .prettierignore | 1 + nx.json | 3 +- package.json | 2 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5f73684e0ff..8deaf945c82f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,6 @@ env: NX_CACHE_RESTORE_KEYS: | nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }} nx-Linux-${{ github.ref }} - nx-Linux-refs/heads/develop nx-Linux jobs: @@ -212,7 +211,7 @@ jobs: needs.job_get_metadata.outputs.is_release == 'false' && needs.job_get_metadata.outputs.force_skip_cache == 'false' with: - path: node_modules/.cache/nx + path: .nxcache key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT }} # On develop branch, we want to _store_ the cache (so it can be used by other branches), but never _restore_ from it restore-keys: @@ -244,12 +243,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -288,12 +287,12 @@ jobs: # use Node 14 for now. node-version: '14' - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -319,12 +318,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -344,12 +343,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -370,12 +369,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -407,12 +406,12 @@ jobs: with: node-version: ${{ env.DEFAULT_NODE_VERSION }} - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -442,12 +441,12 @@ jobs: with: node-version: ${{ matrix.node }} - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -480,12 +479,12 @@ jobs: with: node-version: ${{ matrix.node }} - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -551,12 +550,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -609,12 +608,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -639,12 +638,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -677,12 +676,12 @@ jobs: with: node-version: ${{ matrix.node }} - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -713,12 +712,12 @@ jobs: with: node-version: ${{ matrix.node }} - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -747,12 +746,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} @@ -810,12 +809,12 @@ jobs: - name: Set up Node uses: volta-cli/action@v4 - name: Check dependency cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_DEPENDENCY_PATHS }} key: ${{ needs.job_build.outputs.dependency_cache_key }} - name: Check build cache - uses: actions/cache@v3 + uses: actions/cache/restore@v3 with: path: ${{ env.CACHED_BUILD_PATHS }} key: ${{ env.BUILD_CACHE_KEY }} diff --git a/.gitignore b/.gitignore index d822f532c8cc..8574a81de0a4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ sentry-node-serverless-*.zip jest/transformers/*.js # node tarballs packages/*/sentry-*.tgz +.nxcache # logs yarn-error.log diff --git a/.prettierignore b/.prettierignore index dd449725e188..f2ddf012c98e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ *.md +.nxcache diff --git a/nx.json b/nx.json index 1020417113c4..a4cbbbcd85da 100644 --- a/nx.json +++ b/nx.json @@ -8,7 +8,8 @@ "build:transpile", "build:types", "lint:eslint" - ] + ], + "cacheDirectory": ".nxcache" } } }, diff --git a/package.json b/package.json index 40dc91097f47..8a2d6c862d1a 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "circularDepCheck": "lerna run circularDepCheck", "clean": "run-p clean:build clean:caches", "clean:build": "lerna run clean", - "clean:caches": "yarn rimraf eslintcache && yarn jest --clearCache", + "clean:caches": "yarn rimraf eslintcache .nxcache && yarn jest --clearCache", "clean:deps": "lerna clean --yes && rm -rf node_modules && yarn", "clean:all": "run-p clean:build clean:caches clean:deps", "codecov": "codecov", From 8b1bcbacb9a4b47aa2c59c5e1da65ee126b47028 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 10 Feb 2023 15:08:34 +0100 Subject: [PATCH 2/3] Do not run yarn install on cache hit --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8deaf945c82f..fe9c60106d7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -172,6 +172,7 @@ jobs: key: ${{ steps.compute_lockfile_hash.outputs.hash }} - name: Install dependencies + if: steps.cache_dependencies.outputs.cache_hit != 'true' run: yarn install --ignore-engines --frozen-lockfile outputs: dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }} From 2f9a703b2f48f160ae150e4d3543319bc21d4850 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 10 Feb 2023 15:53:41 +0100 Subject: [PATCH 3/3] fix typo in auto-release workflow --- .github/workflows/auto-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 4d81c7f233b2..cd82966591ce 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -25,7 +25,7 @@ jobs: # Parse version from head branch text: ${{ github.head_ref }} # match: preprare-release/xx.xx.xx - regex: '^preprare-release\/(\d+\.\d+\.\d+)$' + regex: '^prepare-release\/(\d+\.\d+\.\d+)$' - name: Prepare release uses: getsentry/action-prepare-release@v1