Skip to content

Commit f5decdf

Browse files
committed
build: Update to lerna 6 & use nx cache for build
1 parent 7316b85 commit f5decdf

File tree

33 files changed

+2150
-1603
lines changed

33 files changed

+2150
-1603
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ jobs:
120120
changed_browser: ${{ steps.changed.outputs.browser }}
121121
changed_browser_integration: ${{ steps.changed.outputs.browser_integration }}
122122
changed_any_code: ${{ steps.changed.outputs.any_code }}
123+
is_master: ${{ github.ref == 'refs/heads/master' }}
124+
is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }}
125+
force_skip_cache:
126+
${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci-skip-cache') }}
123127

124128
job_install_deps:
125129
name: Install Dependencies
@@ -139,14 +143,19 @@ jobs:
139143
- name: Compute dependency cache key
140144
id: compute_lockfile_hash
141145
run: echo "hash=${{ hashFiles('yarn.lock') }}" >> "$GITHUB_OUTPUT"
146+
147+
# When the `ci-skip-cache` label is added to a PR, we always want to skip dependency cache
142148
- name: Check dependency cache
143149
uses: actions/cache@v3
144150
id: cache_dependencies
151+
if: needs.job_get_metadata.outputs.force_skip_cache == 'false'
145152
with:
146153
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
147154
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
155+
148156
- name: Install dependencies
149-
if: steps.cache_dependencies.outputs.cache-hit == ''
157+
if:
158+
steps.cache_dependencies.outputs.cache-hit == '' || needs.job_get_metadata.outputs.force_skip_cache == 'true'
150159
run: yarn install --ignore-engines --frozen-lockfile
151160
outputs:
152161
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
@@ -174,6 +183,27 @@ jobs:
174183
with:
175184
path: ${{ env.CACHED_BUILD_PATHS }}
176185
key: ${{ env.BUILD_CACHE_KEY }}
186+
187+
- name: NX cache
188+
uses: actions/cache@v3
189+
# Disable cache when:
190+
# - on master
191+
# - on release branches
192+
# - when PR has `ci-skip-cache` label
193+
if: |
194+
needs.job_get_metadata.outputs.is_master == 'false' &&
195+
needs.job_get_metadata.outputs.is_release == 'false' &&
196+
needs.job_get_metadata.outputs.force_skip_cache == 'false'
197+
with:
198+
path: node_modules/.cache/nx
199+
key: nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
200+
# GH will use the first restore-key it finds that matches
201+
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
202+
restore-keys: |
203+
nx-${{ runner.os }}-${{ github.ref }}-${{ env.HEAD_COMMIT }}
204+
nx-${{ runner.os }}-${{ github.ref }}
205+
nx-${{ runner.os }}
206+
177207
- name: Build packages
178208
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
179209
# packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
@@ -232,7 +262,7 @@ jobs:
232262
timeout-minutes: 15
233263
runs-on: ubuntu-20.04
234264
# Size Check will error out outside of the context of a PR
235-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
265+
if: github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_master == 'true'
236266
steps:
237267
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
238268
uses: actions/checkout@v3
@@ -258,7 +288,7 @@ jobs:
258288
- name: Check bundle sizes
259289
uses: getsentry/size-limit-action@v5
260290
# Don't run size check on release branches - at that point, we're already committed
261-
if: ${{ !startsWith(github.ref, 'refs/heads/release/') }}
291+
if: needs.job_get_metadata.outputs.is_release == false
262292
with:
263293
github_token: ${{ secrets.GITHUB_TOKEN }}
264294
skip_step: build
@@ -320,7 +350,7 @@ jobs:
320350
needs: [job_get_metadata, job_build]
321351
runs-on: ubuntu-20.04
322352
# Build artifacts are only needed for releasing workflow.
323-
if: startsWith(github.ref, 'refs/heads/release/')
353+
if: needs.job_get_metadata.outputs.is_release
324354
steps:
325355
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
326356
uses: actions/checkout@v3
@@ -339,7 +369,7 @@ jobs:
339369
path: ${{ env.CACHED_BUILD_PATHS }}
340370
key: ${{ env.BUILD_CACHE_KEY }}
341371
- name: Pack
342-
run: yarn build:npm
372+
run: yarn build:tarball
343373
- name: Archive artifacts
344374
uses: actions/[email protected]
345375
with:

docs/new-sdk-release-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This page serves as a checklist of what to do when releasing a new SDK for the f
2121
- [ ] Make sure that the `LICENSE` file exists and has the correct license (We default to the `MIT` license)
2222
- [ ] Also check, that the same license is mentioned in `package.json`
2323

24-
- [ ] Make sure that the tarball (`yarn build:npm`) has all the necessary contents
24+
- [ ] Make sure that the tarball (`yarn build:tarball`) has all the necessary contents
2525

2626
For basic SDKs, this means that the tarball has at least these files:
2727

lerna.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"lerna": "3.4.0",
32
"version": "7.29.0",
4-
"packages": "packages/*",
3+
"packages": ["packages/*"],
54
"npmClient": "yarn",
6-
"useWorkspaces": true
5+
"useWorkspaces": true,
6+
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
77
}

nx.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"tasksRunnerOptions": {
3+
"default": {
4+
"runner": "nx/tasks-runners/default",
5+
"options": {
6+
"cacheableOperations": [
7+
"build:bundle",
8+
"build:pack",
9+
"build:tarball",
10+
"build:types"
11+
]
12+
}
13+
}
14+
},
15+
"targetDefaults": {
16+
"build:bundle": {
17+
"dependsOn": [],
18+
"outputs": [
19+
"{projectRoot}/build/bundles"
20+
]
21+
},
22+
"build:tarball": {
23+
"dependsOn": [
24+
"build:pack"
25+
],
26+
"outputs": []
27+
},
28+
"build:pack": {
29+
"dependsOn": [
30+
"build:pack:uncached",
31+
"^build:pack",
32+
"^build:pack:uncached"
33+
],
34+
"outputs": [
35+
"{projectRoot}/build/npm",
36+
"{projectRoot}/build/esm",
37+
"{projectRoot}/build/cjs"
38+
]
39+
},
40+
"build:types": {
41+
"dependsOn": [
42+
"^build:types"
43+
],
44+
"outputs": [
45+
"{projectRoot}/build/types",
46+
"{projectRoot}/build/npm/types"
47+
]
48+
}
49+
},
50+
"targets": {
51+
"@sentry/serverless": {
52+
"build:bundle": {
53+
"dependsOn": [],
54+
"outputs": [
55+
"{projectRoot}/build/aws"
56+
]
57+
}
58+
}
59+
}
60+
}

package.json

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
{
22
"private": true,
33
"scripts": {
4-
"build": "node ./scripts/verify-packages-versions.js && yarn run-p build:rollup build:types build:bundle && yarn build:extras",
5-
"build:bundle": "yarn ts-node scripts/ensure-bundle-deps.ts && yarn lerna run --parallel build:bundle",
6-
"build:dev": "run-p build:types build:rollup",
7-
"build:dev:filter": "lerna run --stream --concurrency 1 --sort build:dev --include-filtered-dependencies --include-filtered-dependents --scope",
8-
"build:extras": "lerna run --parallel build:extras",
9-
"build:rollup": "lerna run --parallel build:rollup",
10-
"build:types": "lerna run --stream build:types",
11-
"build:watch": "lerna run --parallel build:watch",
12-
"build:dev:watch": "lerna run --parallel build:dev:watch",
4+
"build": "node ./scripts/verify-packages-versions.js && run-s build:types build:pack build:bundle",
5+
"build:bundle": "lerna run build:bundle",
6+
"build:dev": "run-s build:types build:pack",
7+
"build:dev:filter": "lerna run build:dev --include-filtered-dependencies --include-filtered-dependents --scope",
8+
"build:pack": "lerna run build:pack",
9+
"build:types": "lerna run build:types",
10+
"build:watch": "lerna run build:watch",
11+
"build:dev:watch": "lerna run build:dev:watch",
1312
"build:types:watch": "ts-node scripts/build-types-watch.ts",
14-
"build:npm": "lerna run --parallel build:npm",
15-
"circularDepCheck": "lerna run --parallel circularDepCheck",
13+
"build:tarball": "lerna run build:tarball",
14+
"circularDepCheck": "lerna run circularDepCheck",
1615
"clean": "run-p clean:build clean:caches",
17-
"clean:build": "lerna run --parallel clean",
16+
"clean:build": "lerna run clean",
1817
"clean:caches": "yarn rimraf eslintcache && yarn jest --clearCache",
1918
"clean:deps": "lerna clean --yes && rm -rf node_modules && yarn",
2019
"clean:all": "run-p clean:build clean:caches clean:deps",
2120
"codecov": "codecov",
22-
"fix": "lerna run --parallel fix",
23-
"link:yarn": "lerna exec --parallel yarn link",
24-
"lint": "lerna run --parallel lint",
25-
"lint:eslint": "lerna run --parallel lint:eslint",
21+
"fix": "lerna run fix",
22+
"link:yarn": "lerna exec yarn link",
23+
"lint": "lerna run lint",
24+
"lint:eslint": "lerna run lint:eslint",
2625
"postpublish": "lerna run --stream --concurrency 1 postpublish",
27-
"test": "lerna run --ignore @sentry-internal/browser-integration-tests --ignore @sentry-internal/node-integration-tests --stream --concurrency 1 --sort test",
28-
"test-ci": "ts-node ./scripts/test.ts",
29-
"test-ci-browser": "cross-env TESTS_SKIP=node ts-node ./scripts/test.ts",
30-
"test-ci-node": "cross-env TESTS_SKIP=browser ts-node ./scripts/test.ts",
26+
"test": "lerna run --ignore @sentry-internal/* test",
27+
"test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*",
28+
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
3129
"postinstall": "patch-package"
3230
},
3331
"volta": {
@@ -87,7 +85,7 @@
8785
"jsdom": "^19.0.0",
8886
"karma-browserstack-launcher": "^1.5.1",
8987
"karma-firefox-launcher": "^1.1.0",
90-
"lerna": "3.13.4",
88+
"lerna": "^6.0.3",
9189
"madge": "4.0.2",
9290
"magic-string": "^0.27.0",
9391
"mocha": "^6.1.4",
@@ -116,5 +114,5 @@
116114
"@types/express-serve-static-core": "4.17.30"
117115
},
118116
"version": "0.0.0",
119-
"dependencies": {}
117+
"name": "sentry-javascript"
120118
}

packages/angular/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@
4141
"zone.js": "^0.11.8"
4242
},
4343
"scripts": {
44-
"build": "yarn build:ngc",
45-
"build:ngc": "ng build --prod",
44+
"build": "yarn build:pack",
45+
"build:pack": "ng build --prod",
4646
"build:dev": "run-s build",
47-
"build:extras": "yarn build",
48-
"build:watch": "run-p build:ngc:watch",
49-
"build:ngc:watch": "ng build --prod --watch",
50-
"build:npm": "npm pack ./build",
47+
"build:watch": "run-p build:pack:watch",
48+
"build:pack:watch": "ng build --prod --watch",
49+
"build:tarball": "npm pack ./build",
5150
"circularDepCheck": "madge --circular src/index.ts",
5251
"clean": "rimraf build coverage sentry-angular-*.tgz",
5352
"fix": "run-s fix:eslint fix:prettier",

packages/browser/package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@
4444
"webpack": "^4.30.0"
4545
},
4646
"scripts": {
47-
"build": "run-p build:rollup build:bundle build:types",
48-
"build:bundle": "yarn ts-node ../../scripts/ensure-bundle-deps.ts && yarn rollup --config rollup.bundle.config.js",
49-
"build:dev": "run-p build:rollup build:types",
50-
"build:rollup": "rollup -c rollup.npm.config.js",
47+
"build": "run-p build:pack build:bundle build:types",
48+
"build:bundle": "rollup --config rollup.bundle.config.js",
49+
"build:pack": "rollup -c rollup.npm.config.js",
5150
"build:types": "tsc -p tsconfig.types.json",
52-
"build:watch": "run-p build:rollup:watch build:bundle:watch build:types:watch",
51+
"build:watch": "run-p build:pack:watch build:bundle:watch build:types:watch",
5352
"build:bundle:watch": "rollup --config rollup.bundle.config.js --watch",
54-
"build:dev:watch": "run-p build:rollup:watch build:types:watch",
55-
"build:rollup:watch": "rollup -c rollup.npm.config.js --watch",
53+
"build:pack:watch": "rollup -c rollup.npm.config.js --watch",
5654
"build:types:watch": "tsc -p tsconfig.types.json --watch",
57-
"build:npm": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm",
55+
"build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm",
5856
"circularDepCheck": "madge --circular src/index.ts",
5957
"clean": "rimraf build coverage .rpt2_cache sentry-browser-*.tgz",
6058
"fix": "run-s fix:eslint fix:prettier",

packages/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
"tslib": "^1.9.3"
2222
},
2323
"scripts": {
24-
"build": "run-p build:rollup build:types",
24+
"build": "run-p build:pack build:types",
2525
"build:dev": "run-s build",
26-
"build:rollup": "rollup -c rollup.npm.config.js",
26+
"build:pack": "rollup -c rollup.npm.config.js",
2727
"build:types": "tsc -p tsconfig.types.json",
28-
"build:watch": "run-p build:rollup:watch build:types:watch",
28+
"build:watch": "run-p build:pack:watch build:types:watch",
2929
"build:dev:watch": "run-s build:watch",
30-
"build:rollup:watch": "rollup -c rollup.npm.config.js --watch",
30+
"build:pack:watch": "rollup -c rollup.npm.config.js --watch",
3131
"build:types:watch": "tsc -p tsconfig.types.json --watch",
32-
"build:npm": "ts-node ../../scripts/prepack.ts && npm pack ./build",
32+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
3333
"circularDepCheck": "madge --circular src/index.ts",
3434
"clean": "rimraf build coverage sentry-core-*.tgz",
3535
"fix": "run-s fix:eslint fix:prettier",

packages/e2e-tests/publish-packages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as path from 'path';
66
const repositoryRoot = path.resolve(__dirname, '../..');
77

88
// Create tarballs
9-
childProcess.execSync('yarn build:npm', { encoding: 'utf8', cwd: repositoryRoot, stdio: 'inherit' });
9+
childProcess.execSync('yarn build:tarball', { encoding: 'utf8', cwd: repositoryRoot, stdio: 'inherit' });
1010

1111
// Get absolute paths of all the packages we want to publish to the fake registry
1212
const packageTarballPaths = glob.sync('packages/*/sentry-*.tgz', {

packages/ember/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"scripts": {
2020
"build": "ember build --environment=production",
21-
"build:npm": "ember ts:precompile && npm pack && ember ts:clean",
21+
"build:tarball": "ember ts:precompile && npm pack && ember ts:clean",
2222
"clean": "yarn rimraf sentry-ember-*.tgz",
2323
"lint": "run-p lint:js lint:hbs lint:ts",
2424
"lint:hbs": "ember-template-lint .",

packages/eslint-config-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"clean": "yarn rimraf sentry-internal-eslint-config-sdk-*.tgz",
4040
"lint": "prettier --check \"**/*.js\"",
4141
"fix": "prettier --write \"**/*.js\"",
42-
"build:npm": "npm pack",
42+
"build:tarball": "npm pack",
4343
"circularDepCheck": "madge --circular src/index.js"
4444
},
4545
"volta": {

packages/eslint-plugin-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
3434
"lint:prettier": "prettier --check \"{src,test}/**/*.js\"",
3535
"test": "mocha test --recursive",
36-
"build:npm": "npm pack",
36+
"build:tarball": "npm pack",
3737
"circularDepCheck": "madge --circular src/index.js"
3838
},
3939
"volta": {

packages/gatsby/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@
3535
"react": "^18.0.0"
3636
},
3737
"scripts": {
38-
"build": "run-p build:rollup build:types && yarn build:extras",
38+
"build": "run-p build:pack build:types",
3939
"build:dev": "run-s build",
40-
"build:extras": "yarn build:plugin",
4140
"build:plugin": "tsc -p tsconfig.plugin.json",
41+
"build:pack": "run-p build:rollup build:plugin",
4242
"build:rollup": "rollup -c rollup.npm.config.js",
4343
"build:types": "tsc -p tsconfig.types.json",
44-
"build:watch": "run-p build:rollup:watch build:types:watch",
44+
"build:watch": "run-p build:pack:watch build:types:watch",
4545
"build:dev:watch": "run-s build:watch",
46-
"build:rollup:watch": "rollup -c rollup.npm.config.js --watch",
46+
"build:pack:watch": "rollup -c rollup.npm.config.js --watch",
4747
"build:types:watch": "tsc -p tsconfig.types.json --watch",
48-
"build:npm": "ts-node ../../scripts/prepack.ts && npm pack ./build",
48+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
4949
"circularDepCheck": "madge --circular src/index.ts",
5050
"clean": "rimraf build coverage *.d.ts sentry-gatsby-*.tgz",
5151
"fix": "run-s fix:eslint fix:prettier",

packages/hub/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
"tslib": "^1.9.3"
2323
},
2424
"scripts": {
25-
"build": "run-p build:rollup build:types",
25+
"build": "run-p build:pack build:types",
2626
"build:dev": "run-s build",
27-
"build:rollup": "rollup -c rollup.npm.config.js",
27+
"build:pack": "rollup -c rollup.npm.config.js",
2828
"build:types": "tsc -p tsconfig.types.json",
29-
"build:watch": "run-p build:rollup:watch build:types:watch",
29+
"build:watch": "run-p build:pack:watch build:types:watch",
3030
"build:dev:watch": "run-s build:watch",
31-
"build:rollup:watch": "rollup -c rollup.npm.config.js --watch",
31+
"build:pack:watch": "rollup -c rollup.npm.config.js --watch",
3232
"build:types:watch": "tsc -p tsconfig.types.json --watch",
33-
"build:npm": "ts-node ../../scripts/prepack.ts && npm pack ./build",
33+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
3434
"circularDepCheck": "madge --circular src/index.ts",
3535
"clean": "rimraf build coverage sentry-hub-*.tgz",
3636
"fix": "run-s fix:eslint fix:prettier",

0 commit comments

Comments
 (0)