Skip to content

Commit d3e2171

Browse files
authored
Swap lerna for Turbo v2 (#7180)
* Add turbo cache * Use newer cache version * install turbo * update scripts * add packageManager as per turbo v2 requirements * Add turbo.json and fix workspace packages glob * Use v1 tag Before this commit, everytime a new gitguardian action version came out, you had to manually change the version from .e.g 1.26 to 1.27 in the yml After this commit, we're using the new feature where gitguardian updates the v1 tag to the latest v1 release, so we're always automatically using the latest version * Rollback to turbo v1 * Allow changesets to create PRs that automatically run their workflows * Add turbo v2
1 parent 7e34238 commit d3e2171

File tree

6 files changed

+281
-1884
lines changed

6 files changed

+281
-1884
lines changed

.github/workflows/cd-integrations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ jobs:
4343
env:
4444
# If you are running into the problem where PRs created by changesets don't run workflows and are stuck forever,
4545
# you can create a PR_CREATOR_TOKEN secret. You need to create a fine-grained PAT with the read & write permissions for "Content" and "Pull requests".
46+
# Needs access to push to main
4647
GITHUB_TOKEN: ${{ secrets.PR_CREATOR_TOKEN || secrets.GITHUB_TOKEN }}
4748
NODE_AUTH_TOKEN: ${{ inputs.enterprise && secrets.VERDACCIO_AUTH_TOKEN || secrets.NPM_RELEASE_TOKEN }}

.github/workflows/ci-integrations.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ jobs:
2020
if: false
2121
runs-on: ubuntu-latest
2222
steps:
23-
- name: Checkout
24-
uses: actions/checkout@v4
23+
- uses: actions/checkout@v4
2524
with:
2625
fetch-depth: 0 # fetch all history so multiple commits can be scanned
27-
- name: GitGuardian scan
28-
uses: GitGuardian/ggshield-action@v1.27.0
26+
- uses: GitGuardian/ggshield-action@v1
2927
with:
3028
args: -v
3129
env:
@@ -77,11 +75,15 @@ jobs:
7775
with:
7876
projectPath: ${{ github.workspace }}
7977

80-
- run: yarn build
81-
82-
- run: yarn lint
78+
- name: Cache turbo build setup
79+
uses: actions/cache@v4
80+
with:
81+
path: .turbo
82+
key: ${{ runner.os }}-turbo-${{ github.sha }}
83+
restore-keys: |
84+
${{ runner.os }}-turbo-
8385
84-
- run: yarn test
86+
- run: yarn ci
8587

8688
- name: Upload test coverage
8789
uses: actions/upload-artifact@v4
@@ -91,6 +93,3 @@ jobs:
9193
path: |
9294
coverage
9395
packages/**/coverage
94-
95-
- name: Lint project
96-
run: yarn lint

lerna.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"private": true,
44
"scripts": {
55
"prepare": "husky install",
6-
"build": "lerna run build",
7-
"test": "lerna run test",
8-
"test:unit": "lerna run test:unit",
9-
"test:integration": "lerna run test:integration",
10-
"lint": "lerna run lint",
6+
"build": "turbo run build",
7+
"test": "turbo run test",
8+
"test:unit": "turbo run test:unit",
9+
"test:integration": "turbo run test:integration",
10+
"lint": "turbo run lint",
11+
"ci": "turbo run build test:unit test:integration lint",
1112
"changesets:version": "yarn changeset version && YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install && yarn prepare:docs",
1213
"changesets:publish": "yarn build && yarn changeset publish",
1314
"prepare:docs": "cd docs && yarn install && yarn api-extract && yarn add-changelogs",
@@ -26,23 +27,24 @@
2627
"cross-env": "^6.0.3",
2728
"husky": "^8.0.3",
2829
"jest": "^27.0.6",
29-
"lerna": "^6.6.2",
3030
"lint-staged": "^13.2.2",
3131
"rimraf": "^5.0.0",
3232
"rollup": "^2.59.0",
3333
"ts-jest": "^27.0.3",
3434
"ts-node": "^8.4.1",
3535
"tslib": "^2.1.0",
36+
"turbo": "^2.0.10-canary.1",
3637
"typescript": "^5",
3738
"webpack-bundle-analyzer": "^3.5.2"
3839
},
3940
"workspaces": {
4041
"packages": [
41-
"packages/!(storefront)",
42+
"packages/*",
4243
"engineering-toolkit/*"
4344
]
4445
},
4546
"engines": {
46-
"node": ">=12.x"
47-
}
47+
"node": ">=18"
48+
},
49+
"packageManager": "yarn@1.22.22"
4850
}

turbo.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://turbo.build/schema.json",
3+
"tasks": {
4+
"build": {
5+
"dependsOn": ["^build"],
6+
"outputs": ["lib/**", "server/**"]
7+
},
8+
"test:unit": {
9+
// Sometimes in unit tests of SDK we refer to the "types" package of the integration
10+
// so this means the dependencies of the packages need to be built
11+
"dependsOn": ["^build"],
12+
"inputs": ["src/**/*.ts", "__tests__/unit/**/*.ts"],
13+
"outputs": ["coverage/**"]
14+
},
15+
"test:integration": {
16+
// Similarly to unit tests, people just freely import stuff from subdeps :(
17+
"dependsOn": ["^build"],
18+
"inputs": ["src/**/*.ts", "__tests__/integration/**/*.ts"],
19+
"outputs": ["coverage/**"],
20+
"env": ["TEST_*"]
21+
},
22+
"lint": {
23+
// ESLint fails the 'is this import statement resolveable?' rule if the
24+
// dependencies of some package aren't built
25+
"dependsOn": ["^build"]
26+
},
27+
"sync-changelog": {
28+
// Changelog is just a text file, just make sure to call npx changesets:version beforehand
29+
"dependsOn": []
30+
},
31+
"sync-api": {
32+
// api-extractor expects a ./lib/api-extractor-data.d.ts file to exist
33+
// so the each package needs to be built before api extraction
34+
"dependsOn": ["build"]
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)