Skip to content

Commit bfaab8e

Browse files
committed
[code-infra] Refactor circle config to be reusable
1 parent 31fca19 commit bfaab8e

File tree

3 files changed

+36
-140
lines changed

3 files changed

+36
-140
lines changed

.circleci/config.yml

Lines changed: 33 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: 2.1
22

3+
orbs:
4+
code-infra: https://raw.githubusercontent.com/mui/mui-public/e8720c89db86b256b0422d1c77fc292f979b892c/.circleci/orbs/code-infra.yml
5+
36
parameters:
47
browserstack-force:
58
description: Whether to force browserstack usage. We have limited resources on browserstack so the pipeline might decide to skip browserstack if this parameter isn't set to true.
@@ -23,11 +26,9 @@ default-job: &default-job
2326
environment:
2427
# expose it globally otherwise we have to thread it from each job to the install command
2528
BROWSERSTACK_FORCE: << pipeline.parameters.browserstack-force >>
26-
REACT_VERSION: << parameters.react-version >>
2729
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
2830
working_directory: /tmp/base-ui
29-
docker:
30-
- image: cimg/node:22.18
31+
executor: code-infra/mui-node
3132

3233
default-context: &default-context
3334
context:
@@ -42,115 +43,30 @@ default-context: &default-context
4243
# restore_cache:
4344
# key: v1-repo-{{ .Branch }}-{{ .Revision }}
4445

45-
commands:
46-
install_js:
47-
parameters:
48-
browsers:
49-
type: boolean
50-
default: false
51-
description: 'Set to true if you intend to any browser (for example with playwright).'
52-
react-version:
53-
description: The version of react to be used
54-
type: string
55-
default: stable
56-
steps:
57-
- run:
58-
name: Set npm registry public signing keys
59-
command: |
60-
echo "export COREPACK_INTEGRITY_KEYS='$(curl https://registry.npmjs.org/-/npm/v1/keys | jq -c '{npm: .keys}')'" >> $BASH_ENV
61-
- when:
62-
condition: << parameters.browsers >>
63-
steps:
64-
- run:
65-
name: Install pnpm package manager
66-
command: corepack enable
67-
- when:
68-
condition:
69-
not: << parameters.browsers >>
70-
steps:
71-
- run:
72-
name: Install pnpm package manager
73-
# See https://stackoverflow.com/a/73411601
74-
command: corepack enable --install-directory ~/bin
75-
- run:
76-
name: View install environment
77-
command: |
78-
node --version
79-
pnpm --version
80-
- run:
81-
name: Install js dependencies
82-
command: |
83-
args=""
84-
if [ -n "$REACT_VERSION" ] && [ "$REACT_VERSION" != "stable" ]; then
85-
args="react@$REACT_VERSION"
86-
fi
87-
if [ -n "$args" ]; then
88-
pnpm dlx @mui/internal-code-infra@canary set-version-overrides --pkg $args
89-
else
90-
pnpm install
91-
fi
92-
9346
jobs:
9447
test_unit:
9548
<<: *default-job
9649
steps:
9750
- checkout
98-
- install_js
51+
- code-infra/install-deps:
52+
package-overrides: react@<< parameters.react-version >>
9953
- run:
10054
name: Run tests on JSDOM
10155
command: pnpm test:jsdom:coverage
102-
- run:
103-
name: Check if coverage report is generated
104-
command: |
105-
if ! [[ -s coverage/lcov.info ]]
106-
then
107-
exit 1
108-
fi
109-
- run:
110-
name: Upload coverage report to Codecov
111-
command: |
112-
curl -Os https://uploader.codecov.io/latest/linux/codecov
113-
chmod +x codecov
114-
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-jsdom"
56+
- code-infra/upload-coverage:
57+
key: << parameters.react-version >>-jsdom
11558
test_lint:
11659
<<: *default-job
11760
steps:
11861
- checkout
119-
- install_js
120-
- run:
121-
name: '`pnpm prettier` changes committed?'
122-
command: |
123-
# #target-branch-reference
124-
if [[ $(git diff --name-status master | grep pnpm-lock) == "" ]];
125-
then
126-
pnpm prettier --check
127-
else
128-
pnpm exec prettier --check . --ignore-path .lintignore
129-
fi
130-
- run:
131-
name: ESLint
132-
command: pnpm eslint:ci
133-
- run:
134-
name: Stylelint
135-
command: pnpm stylelint
136-
- run:
137-
name: Lint Markdown
138-
command: pnpm markdownlint
62+
- code-infra/install-deps
63+
- code-infra/run-linters
13964
test_static:
14065
<<: *default-job
14166
steps:
14267
- checkout
143-
- install_js
144-
- run:
145-
name: '`pnpm dedupe` was run?'
146-
command: |
147-
# #default-branch-switch
148-
if [[ $(git diff --name-status master | grep -E 'pnpm-workspace\.yaml|pnpm-lock.yaml|package\.json') == "" ]];
149-
then
150-
echo "No changes to dependencies detected. Skipping..."
151-
else
152-
pnpm dedupe --check
153-
fi
68+
- code-infra/install-deps
69+
- code-infra/check-static-changes
15470
- run:
15571
name: Generate the documentation
15672
command: pnpm docs:api
@@ -177,7 +93,8 @@ jobs:
17793
resource_class: 'medium+'
17894
steps:
17995
- checkout
180-
- install_js
96+
- code-infra/install-deps:
97+
package-overrides: react@<< parameters.react-version >>
18198
- run:
18299
name: Tests TypeScript definitions
183100
command: pnpm typescript
@@ -197,13 +114,8 @@ jobs:
197114
resource_class: 'medium+'
198115
steps:
199116
- checkout
200-
- install_js
201-
- run:
202-
name: Resolve typescript version
203-
command: |
204-
pnpm update -r typescript@next
205-
# log a patch for maintainers who want to check out this change
206-
git --no-pager diff HEAD
117+
- code-infra/install-deps:
118+
package-overrides: typescript@next
207119
- run:
208120
name: Tests TypeScript definitions
209121
command: pnpm typescript
@@ -225,36 +137,26 @@ jobs:
225137
test_browser:
226138
<<: *default-job
227139
resource_class: 'medium+'
228-
docker:
229-
- image: mcr.microsoft.com/playwright:v1.56.1-noble
140+
executor:
141+
name: code-infra/mui-node-browser
142+
playwright-img-version: v1.56.1-noble
230143
steps:
231144
- checkout
232-
- install_js:
233-
browsers: true
145+
- code-infra/install-deps:
146+
package-overrides: react@<< parameters.react-version >>
234147
- run:
235148
name: Run tests on headless Chromium
236149
command: pnpm test:chromium --coverage
237-
- run:
238-
name: Check if coverage report is generated
239-
command: |
240-
if ! [[ -s coverage/lcov.info ]]
241-
then
242-
exit 1
243-
fi
244-
- run:
245-
name: Upload coverage report to Codecov
246-
command: |
247-
curl -Os https://uploader.codecov.io/latest/linux/codecov
248-
chmod +x codecov
249-
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-browser"
150+
- code-infra/upload-coverage:
151+
key: << parameters.react-version >>-browser
250152
test_regressions:
251153
<<: *default-job
252-
docker:
253-
- image: mcr.microsoft.com/playwright:v1.56.1-noble
154+
executor:
155+
name: code-infra/mui-node-browser
156+
playwright-img-version: v1.56.1-noble
254157
steps:
255158
- checkout
256-
- install_js:
257-
browsers: true
159+
- code-infra/install-deps
258160
- run:
259161
name: Run visual regression tests
260162
command: xvfb-run pnpm test:regressions
@@ -263,12 +165,12 @@ jobs:
263165
command: pnpm test:argos
264166
test_e2e:
265167
<<: *default-job
266-
docker:
267-
- image: mcr.microsoft.com/playwright:v1.56.1-noble
168+
executor:
169+
name: code-infra/mui-node-browser
170+
playwright-img-version: v1.56.1-noble
268171
steps:
269172
- checkout
270-
- install_js:
271-
browsers: true
173+
- code-infra/install-deps
272174
- run:
273175
name: pnpm test:e2e
274176
command: pnpm test:e2e
@@ -277,7 +179,7 @@ jobs:
277179
<<: *default-job
278180
steps:
279181
- checkout
280-
- install_js
182+
- code-infra/install-deps
281183
- run:
282184
name: Build packages
283185
command: pnpm release:build
@@ -293,13 +195,7 @@ jobs:
293195
- run:
294196
name: Verify built packages
295197
command: pnpm -r test:package
296-
- run:
297-
name: create and upload a size snapshot
298-
command: |
299-
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID_ARTIFACTS
300-
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY_ARTIFACTS
301-
export AWS_REGION=$AWS_REGION_ARTIFACTS
302-
pnpm size:snapshot
198+
- code-infra/upload-size-snapshot
303199

304200
workflows:
305201
pipeline:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ To see the latest updates, check out the [releases](https://base-ui.com/react/ov
2929
- **Michał Dudak** (Material UI) [@michaldudak](https://x.com/michaldudak)
3030
- **Marija Najdova** (Material UI + Fluent UI) [@marijanajdova](https://x.com/marijanajdova)
3131
- **Albert Yu** (Material UI) [@mj12albert](https://github.com/mj12albert)
32-
- **Lukas Tyla** (Material UI) [@LukasTy](https://github.com/LukasTy)
32+
- **Lukas Tyla** (Material UI) [@LukasTy](https://github.com/LukasTy)
3333

3434
## License
3535

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"docs:link-check": "pnpm --filter docs link-check",
2121
"docs:generate-llms": "pnpm --filter docs run generate-llms",
2222
"extract-error-codes": "code-infra extract-error-codes --errorCodesPath docs/src/error-codes.json --detection opt-out",
23-
"eslint": "eslint . --cache --report-unused-disable-directives --max-warnings 0 && pnpm -r lint",
24-
"eslint:ci": "eslint . --report-unused-disable-directives --max-warnings 0 && pnpm -r lint",
23+
"eslint": "pnpm -r lint && eslint . --cache --report-unused-disable-directives --max-warnings 0",
24+
"eslint:ci": "pnpm -r lint && eslint . --report-unused-disable-directives --max-warnings 0",
2525
"stylelint": "stylelint --reportInvalidScopeDisables --reportNeedlessDisables \"docs/**/*.{js,ts,tsx}\" \"**/*.css\" --ignore-path .lintignore",
2626
"markdownlint": "markdownlint-cli2 \"**/*.{md,mdx}\"",
2727
"valelint": "pnpm vale sync && git ls-files | grep -h \".md$\" | xargs pnpm vale --filter='.Level==\"error\"'",

0 commit comments

Comments
 (0)