Skip to content

Commit

Permalink
build: Improve CI cache (#7141)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Feb 14, 2023
1 parent 2c514ed commit d604022
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
64 changes: 32 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -173,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 }}
Expand Down Expand Up @@ -212,7 +212,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:
Expand Down Expand Up @@ -244,12 +244,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 }}
Expand Down Expand Up @@ -288,12 +288,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 }}
Expand All @@ -319,12 +319,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 }}
Expand All @@ -344,12 +344,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 }}
Expand All @@ -370,12 +370,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 }}
Expand Down Expand Up @@ -407,12 +407,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 }}
Expand Down Expand Up @@ -442,12 +442,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 }}
Expand Down Expand Up @@ -480,12 +480,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 }}
Expand Down Expand Up @@ -553,12 +553,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 }}
Expand Down Expand Up @@ -611,12 +611,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 }}
Expand All @@ -641,12 +641,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 }}
Expand Down Expand Up @@ -679,12 +679,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 }}
Expand Down Expand Up @@ -715,12 +715,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 }}
Expand Down Expand Up @@ -749,12 +749,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 }}
Expand Down Expand Up @@ -812,12 +812,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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sentry-node-serverless-*.zip
jest/transformers/*.js
# node tarballs
packages/*/sentry-*.tgz
.nxcache

# logs
yarn-error.log
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.md
.nxcache
3 changes: 2 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build:transpile",
"build:types",
"lint:eslint"
]
],
"cacheDirectory": ".nxcache"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d604022

Please sign in to comment.