Skip to content

Commit e8f3f32

Browse files
authored
ci: Add Turborepo Support
Adds [Turborepo](https://turborepo.org/) caching support
1 parent a322494 commit e8f3f32

File tree

8 files changed

+145
-23
lines changed

8 files changed

+145
-23
lines changed

.circleci/config.yml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ references:
1717
webpack_cache_key_1: &webpack_cache_key_1 v1-webpack-{{ arch }}-{{ checksum "yarn.lock" }}-{{ .Branch }}-{{ .Revision }}
1818
webpack_cache_key_2: &webpack_cache_key_2 v1-webpack-{{ arch }}-{{ checksum "yarn.lock" }}-{{ .Branch }}
1919

20+
turbo_cache_key_1: &turbo_cache_key_1 v1-turbo-{{ arch }}-{{ checksum "yarn.lock" }}-{{ .Branch }}-{{ epoch }}
21+
turbo_cache_key_2: &turbo_cache_key_2 v1-turbo-{{ arch }}-{{ checksum "yarn.lock" }}-{{ .Branch }}
22+
turbo_cache_key_3: &turbo_cache_key_3 v1-turbo-{{ arch }}-{{ checksum "yarn.lock" }}
23+
2024
restore_yarn_cache: &restore_yarn_cache
2125
restore_cache:
2226
keys:
@@ -41,6 +45,19 @@ references:
4145
- node_modules/.cache
4246
- packages/styleguide/node_modules/.cache
4347

48+
save_turbo_cache: &save_turbo_cache
49+
save_cache:
50+
key: *turbo_cache_key_1
51+
paths:
52+
- node_modules/.cache/turbo
53+
54+
restore_turbo_cache: &restore_turbo_cache
55+
restore_cache:
56+
keys:
57+
- *turbo_cache_key_1
58+
- *turbo_cache_key_2
59+
- *turbo_cache_key_3
60+
4461
save_node_modules: &save_node_modules
4562
persist_to_workspace:
4663
root: ~/repo
@@ -55,12 +72,7 @@ references:
5572
build_all_packages: &build_all_packages
5673
run:
5774
name: Build All Packages
58-
command: yarn build-all
59-
60-
build_changed_packages: &build_changed_packages
61-
run:
62-
name: Build Changed Packages
63-
command: yarn build-changed
75+
command: yarn turbo run build --concurrency=3
6476

6577
set_git_user: &set_git_user
6678
run:
@@ -111,10 +123,12 @@ jobs:
111123
steps:
112124
- checkout
113125
- *restore_node_modules
114-
- *build_changed_packages
126+
- *restore_turbo_cache
127+
- *build_all_packages
128+
- *save_turbo_cache
115129
- run:
116130
name: Verify Packages
117-
command: yarn verify-changed
131+
command: yarn verify
118132

119133
tests:
120134
<<: *default_env
@@ -146,12 +160,13 @@ jobs:
146160
- checkout
147161
- *restore_node_modules
148162
- *set_npm_token
149-
- *build_changed_packages
163+
- *restore_turbo_cache
164+
- *build_all_packages
165+
- *save_turbo_cache
150166
- run:
151167
name: Lerna Publish
152168
command: yarn lerna publish --yes --conventional-commits --changelog-preset conventionalcommits --include-merged-tags --create-release=github
153169

154-
155170
publish_alpha:
156171
<<: *default_env
157172
resource_class: large
@@ -162,7 +177,9 @@ jobs:
162177
- checkout
163178
- *restore_node_modules
164179
- *set_npm_token
165-
- *build_changed_packages
180+
- *restore_turbo_cache
181+
- *build_all_packages
182+
- *save_turbo_cache
166183
- run: npm whoami
167184
- run:
168185
name: lerna publish (alpha)

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ tmp
4444

4545
# Automatic report....json files
4646
report*.json
47+
48+
# Turborepo
49+
.turbo

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This repository is a monorepo that we manage using [Lerna](https://lernajs.io/).
1111
## Local development
1212

1313
1. Run `yarn` in the root directory
14-
1. Run `yarn build-all`
14+
1. Run `yarn build`
1515

1616
### Publishing Modules
1717

@@ -54,6 +54,14 @@ We do that using symlinks (the following instructions assume you have set up and
5454
1. Send a `feat` PR adding that package
5555
1. One merged, message out in our #frontend Slack channel to other client-modules developers to re-run `yarn lerna bootstrap` after they merge from `main`
5656

57+
**Turborepo**
58+
59+
This monorepo uses [Turborepo](https://turborepo.org/) to cache previous builds locally and in CI.
60+
61+
The config for Turborepo is located at [/turbo.json](/turbo.json).
62+
63+
To use Turborepo without extra configuration, if your package needs to be compiled, it should have a task called `build` that compiles it's files and puts them into a directory called `dist` inside the package directory. If you need a more complicated setup, you can read the docs and customize the configuration in `turbo.json`.
64+
5765
### PR Title Guide
5866

5967
Your PR Title should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) Format.
@@ -152,4 +160,3 @@ Optional extra description for your changes.
152160
This goes in the description for your PR, between the `<!--- CHANGELOG-DESCRIPTION -->` comment tags in the PR template.
153161

154162
If you include the text `BREAKING CHANGE:` in your description it will trigger a major version bump. We prefer to use the `feat!:` syntax for breaking changes described above.
155-

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"prettier": "prettier --ignore-path .prettierignore \"./**/*.{js,ts,tsx,json}\"",
1818
"format": "yarn lint:fix && yarn prettier --write",
1919
"format:verify": "yarn prettier --check",
20-
"verify-all": "lerna run verify",
21-
"verify-changed": "lerna run verify --since --include-dependencies",
20+
"verify": "turbo run verify --concurrency=3",
21+
"verify-all": "yarn verify",
2222
"clear-modules": "lerna clean -y && rm -rf node_modules",
23-
"build-all": "lerna run lernaBuildTask",
24-
"build-changed": "lerna run lernaBuildTask --since --include-dependencies",
23+
"build": "turbo run build --concurrency=3",
24+
"build-all": "yarn build",
2525
"start:storybook": "cd ./packages/styleguide && yarn start",
2626
"install:sibling-dependencies": "cd ./packages/codebytes && yarn --focus",
2727
"start": "yarn && yarn start:storybook"
@@ -48,10 +48,10 @@
4848
"lerna": "3.22.1"
4949
},
5050
"devDependencies": {
51-
"@codecademy/webpack-config": "^6.0.0",
5251
"@babel/cli": "7.13.10",
5352
"@babel/core": "7.13.10",
5453
"@babel/preset-typescript": "^7.13.0",
54+
"@codecademy/webpack-config": "^6.0.0",
5555
"@emotion/babel-plugin": "^11.3.0",
5656
"@emotion/jest": "^11.3.0",
5757
"@emotion/react": "^11.4.0",
@@ -102,12 +102,14 @@
102102
"react-dom": "16.13.1",
103103
"react-helmet": "6.1.0",
104104
"react-test-renderer": "16.13.1",
105+
"turbo": "^1.1.2",
105106
"typescript": "4.4.2"
106107
},
107108
"husky": {
108109
"skipCI": false,
109110
"hooks": {
110111
"pre-commit": "lint-staged"
111112
}
112-
}
113+
},
114+
"packageManager": "[email protected]"
113115
}

packages/codebytes/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
"build:clean": "rm -rf dist",
4040
"build:types": "tsc --emitDeclarationOnly",
4141
"build": "yarn build:clean && yarn build:compile && yarn build:types",
42-
"build:watch": "yarn build && onchange ./src -- yarn build:compile && yarn build:types",
43-
"lernaBuildTask": "yarn build"
42+
"build:watch": "yarn build && onchange ./src -- yarn build:compile && yarn build:types"
4443
},
4544
"license": "MIT",
4645
"devDependencies": {

packages/tracking/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
"build:compile": "babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
3030
"build:clean": "rm -rf dist",
3131
"build:types": "tsc --emitDeclarationOnly",
32-
"build": "yarn build:clean && yarn build:compile && yarn build:types",
33-
"lernaBuildTask": "yarn build"
32+
"build": "yarn build:clean && yarn build:compile && yarn build:types"
3433
},
3534
"license": "MIT",
3635
"publishConfig": {

turbo.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"npmClient": "yarn",
3+
"baseBranch": "origin/main",
4+
"pipeline": {
5+
"build": {
6+
"dependsOn": ["^build"]
7+
},
8+
"verify": {
9+
"dependsOn": ["^build"],
10+
"outputs": []
11+
},
12+
"start": {
13+
"cache": false
14+
}
15+
},
16+
"globalDependencies": ["tsconfig.json", "lerna.json", "turbo.json"]
17+
}

yarn.lock

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18086,6 +18086,84 @@ tunnel-agent@^0.6.0:
1808618086
dependencies:
1808718087
safe-buffer "^5.0.1"
1808818088

18089+
18090+
version "1.1.2"
18091+
resolved "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-1.1.2.tgz#b129aaf538821de78d5e2129495c553627174650"
18092+
integrity sha512-rua17HnVvAqAU54gVfiQoH7cfopOqANv+yI6NtxLMD8aFfX2cJ9m8SSvH2v2vCaToNDW6OnTkdqDKQpqIHzbCw==
18093+
18094+
18095+
version "1.1.2"
18096+
resolved "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.1.2.tgz#07a783ad2e3e8af600ae7406cc4062ff56ac0351"
18097+
integrity sha512-otqSQNYDyKg0KqB3NM0BI4oiRPKdJkUE/XBn8dcUS+zeRLrL00XtaM0eSwynZs1tb6zU/Y+SPMSBRygD1TCOnw==
18098+
18099+
18100+
version "1.1.2"
18101+
resolved "https://registry.npmjs.org/turbo-freebsd-64/-/turbo-freebsd-64-1.1.2.tgz#9e22abf04ec2298f205a57b5c9ce14e22844baf3"
18102+
integrity sha512-2nxwVDTAM0DtIQ2i3UOfEsQLF7vp+XZ/b9SKtiHxz710fXvdyuGivYI25axDdcBn8kQ45rnbUnarF1aW8CMGgg==
18103+
18104+
18105+
version "1.1.2"
18106+
resolved "https://registry.npmjs.org/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.1.2.tgz#6095c9012881225a5fdfb55362defa12f24b1f8e"
18107+
integrity sha512-ro1Ah96yzgzyT0BJe1mceAqxPxi0pUwzAvN3IKVpMqi4hYkT3aRbzDCaSxzyC6let2Al/NUsgHnbAv38OF2Xkw==
18108+
18109+
18110+
version "1.1.2"
18111+
resolved "https://registry.npmjs.org/turbo-linux-32/-/turbo-linux-32-1.1.2.tgz#4726e533d6966172b6bc4a960524ec2eb61adaab"
18112+
integrity sha512-HKBsETxQMVaf/DJwMg7pypPbGA6KEu0gEf9C8o2aPJvwMPBYgNsNaU08Xizuh5xzEQTzpbIWfQyqdNgMV4RG3Q==
18113+
18114+
18115+
version "1.1.2"
18116+
resolved "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-1.1.2.tgz#dfe7f3a4c91acecdb84ecab330acee06857e568e"
18117+
integrity sha512-IklKsOklcRHIWkTzKg95BQ6jgJ53kLvRMrp8yqzlvZprkWdiyhAgUxrUTTHOOTce2XA3+jdN2+MwixG44uY2vg==
18118+
18119+
18120+
version "1.1.2"
18121+
resolved "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-1.1.2.tgz#c39b6c50657fa0e82627407c86a5c43f19598e2b"
18122+
integrity sha512-3kS6sk2lOtuBBqkcL+yeGqD1yew4UZ1o7XUcbDD8UPwhF2kAfK7Qs0vTJw4lnO1scjhihkoTrmXM7yozvjf4/w==
18123+
18124+
18125+
version "1.1.2"
18126+
resolved "https://registry.npmjs.org/turbo-linux-arm/-/turbo-linux-arm-1.1.2.tgz#2f51f93a3aa144b8ba25d7b0e3c53ea186a0e9dd"
18127+
integrity sha512-CNbaTvRozq7H/5jpy9OZlzJ6BkeEXF+nF2n9dHiUrbAXd3nq84Qt9odcQJmGnexP19YS9w6l3tIHncX4BgwtqA==
18128+
18129+
18130+
version "1.1.2"
18131+
resolved "https://registry.npmjs.org/turbo-linux-mips64le/-/turbo-linux-mips64le-1.1.2.tgz#f52b7f410ac289d4e539f108679d2324aa5e271e"
18132+
integrity sha512-CDoXVIlW43C6KLgYxe13KkG8h6DswXHxbTVHiZdOwRQ56j46lU+JOVpLoh6wpQGcHvj58VEiypZBRTGVFMeogw==
18133+
18134+
18135+
version "1.1.2"
18136+
resolved "https://registry.npmjs.org/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.1.2.tgz#18d08d3414075d0dcb4be83ca837dda508313996"
18137+
integrity sha512-xPVMHoiOJE/qI63jSOXwYIUFQXLdstxDV6fLnRxvq0QnJNxgTKq+mLUeE8M4LDVh1bdqHLcfk/HmyQ6+X1XVkQ==
18138+
18139+
18140+
version "1.1.2"
18141+
resolved "https://registry.npmjs.org/turbo-windows-32/-/turbo-windows-32-1.1.2.tgz#96033019094bcb091647d6063c3c9b8e83d0acbe"
18142+
integrity sha512-Gj1yvPE0aMDSOxGVSBaecLnwsVDT1xX8U0dtLrg52TYY2jlaci0atjHKr9nTFuX7z8uwAf6PopwdriGoCeT3ng==
18143+
18144+
18145+
version "1.1.2"
18146+
resolved "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-1.1.2.tgz#8eb3f77ab7e04b077752ae2204114c82e5c74697"
18147+
integrity sha512-0Ncx/iKhnKrdAU8hJ+8NUcF9jtFr8KoW5mMWfiFzy+mgUbVKbpzWT2eoGR6zJExedQsRvYOejbEX5iihbnj5bA==
18148+
18149+
turbo@^1.1.2:
18150+
version "1.1.2"
18151+
resolved "https://registry.npmjs.org/turbo/-/turbo-1.1.2.tgz#751b9651dc3ebe469898db76afab6405666ad0ff"
18152+
integrity sha512-3ViHKyAkaBKNKwHASTa1zkVT3tVVhQNLrpxBS7LoN+794ouQUYmy6lf0rTqzG3iTZHtIDwC+piZSdTl4XjEVMg==
18153+
optionalDependencies:
18154+
turbo-darwin-64 "1.1.2"
18155+
turbo-darwin-arm64 "1.1.2"
18156+
turbo-freebsd-64 "1.1.2"
18157+
turbo-freebsd-arm64 "1.1.2"
18158+
turbo-linux-32 "1.1.2"
18159+
turbo-linux-64 "1.1.2"
18160+
turbo-linux-arm "1.1.2"
18161+
turbo-linux-arm64 "1.1.2"
18162+
turbo-linux-mips64le "1.1.2"
18163+
turbo-linux-ppc64le "1.1.2"
18164+
turbo-windows-32 "1.1.2"
18165+
turbo-windows-64 "1.1.2"
18166+
1808918167
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
1809018168
version "0.14.5"
1809118169
resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"

0 commit comments

Comments
 (0)