Skip to content

Commit 9b7ccdc

Browse files
authored
Merge pull request #6132 from ethereum/pipelineoptim
Pipelineoptim
2 parents 68b798c + 2c1f55d commit 9b7ccdc

File tree

7 files changed

+182
-46
lines changed

7 files changed

+182
-46
lines changed

.circleci/config.yml

Lines changed: 106 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
version: 2.1
22
parameters:
3+
run_all_tests:
4+
type: boolean
5+
default: false
6+
run_pr_tests:
7+
type: boolean
8+
default: false
9+
run_file_tests:
10+
type: string
11+
default: ""
12+
run_metamask_tests:
13+
type: boolean
14+
default: false
315
run_flaky_tests:
416
type: boolean
5-
default: false
17+
default: false
18+
resource_class:
19+
type: enum
20+
enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge"]
21+
default: "xlarge"
622
web:
723
type: boolean
824
default: true
9-
run_metamask_tests:
10-
type: boolean
11-
default: false
1225
orbs:
1326
browser-tools: circleci/[email protected]
1427
node: circleci/[email protected]
@@ -18,9 +31,7 @@ jobs:
1831
build:
1932
docker:
2033
- image: cimg/node:20.0.0-browsers
21-
22-
resource_class:
23-
xlarge
34+
resource_class: << pipeline.parameters.resource_class >>
2435
working_directory: ~/remix-project
2536
steps:
2637
- run: sudo apt update && sudo apt install zstd
@@ -62,8 +73,7 @@ jobs:
6273
build-plugin:
6374
docker:
6475
- image: cimg/node:20.0.0-browsers
65-
resource_class:
66-
xlarge
76+
resource_class: << pipeline.parameters.resource_class >>
6777
working_directory: ~/remix-project
6878
parameters:
6979
plugin:
@@ -83,15 +93,12 @@ jobs:
8393
- persist_to_workspace:
8494
root: .
8595
paths:
86-
- "persist"
87-
96+
- "persist"
8897
lint:
8998
docker:
9099
- image: cimg/node:20.0.0-browsers
91-
resource_class:
92-
xlarge
100+
resource_class: << pipeline.parameters.resource_class >>
93101
working_directory: ~/remix-project
94-
95102
steps:
96103
- checkout
97104
- restore_cache:
@@ -105,10 +112,8 @@ jobs:
105112
remix-libs:
106113
docker:
107114
- image: cimg/node:20.0.0-browsers
108-
resource_class:
109-
xlarge
115+
resource_class: << pipeline.parameters.resource_class >>
110116
working_directory: ~/remix-project
111-
112117
steps:
113118
- checkout
114119
- attach_workspace:
@@ -128,17 +133,46 @@ jobs:
128133
- run: node dist/libs/remix-tests/bin/remix-tests ./libs/remix-tests/tests/examples_0/assert_ok_test.sol
129134
- run: yarn run test:libs
130135

136+
137+
check-flaky-or-pr-tests:
138+
docker:
139+
- image: cimg/node:24.3.0
140+
working_directory: ~/remix-project
141+
parameters:
142+
pattern:
143+
type: string
144+
steps:
145+
- checkout
146+
- run: node apps/remix-ide-e2e/src/buildGroupTests.js
147+
- run:
148+
name: Check for enabled tests matching tag
149+
command: |
150+
PATTERN="<< parameters.pattern >>"
151+
if [ -z "$PATTERN" ]; then
152+
echo "❌ Tag parameter is empty!"
153+
exit 2
154+
fi
155+
echo "🔍 Searching for enabled tests with .$PATTERN extension..."
156+
if grep -IRiL "'@disabled': \?true" "./apps/remix-ide-e2e/src/tests" | grep "${PATTERN}"; then
157+
echo "✅ Found enabled .$PATTERN tests."
158+
exit 0
159+
else
160+
echo "⚠️ No enabled .$PATTERN tests found. Skipping workflow."
161+
exit 1
162+
fi
163+
131164
remix-ide-browser:
132165
docker:
133166
- image: cimg/node:20.19.0-browsers
134-
resource_class:
135-
xlarge
167+
resource_class: << pipeline.parameters.resource_class >>
136168
working_directory: ~/remix-project
137169
parameters:
138170
browser:
139171
type: string
140172
script:
141173
type: string
174+
scriptparameter:
175+
type: string
142176
job:
143177
type: string
144178
jobsize:
@@ -199,7 +233,7 @@ jobs:
199233
install-chromedriver: false
200234
- run: yarn install_webdriver
201235
- run: firefox --version
202-
- run: ./apps/remix-ide/ci/<< parameters.script >> << parameters.browser >> << parameters.jobsize >> << parameters.job >>
236+
- run: ./apps/remix-ide/ci/<< parameters.script >> << parameters.browser >> << parameters.jobsize >> << parameters.job >> << parameters.scriptparameter >>
203237
- store_test_results:
204238
path: ./reports/tests
205239
- store_artifacts:
@@ -217,8 +251,7 @@ jobs:
217251
remix-test-plugins:
218252
docker:
219253
- image: cimg/node:20.17.0-browsers
220-
resource_class:
221-
xlarge
254+
resource_class: << pipeline.parameters.resource_class >>
222255
working_directory: ~/remix-project
223256
parameters:
224257
plugin:
@@ -253,8 +286,7 @@ jobs:
253286
predeploy:
254287
docker:
255288
- image: cimg/node:20.0.0-browsers
256-
resource_class:
257-
xlarge
289+
resource_class: << pipeline.parameters.resource_class >>
258290
working_directory: ~/remix-project
259291
steps:
260292
- checkout
@@ -297,20 +329,65 @@ jobs:
297329

298330
workflows:
299331

332+
run_file_tests:
333+
when: << pipeline.parameters.run_file_tests >>
334+
jobs:
335+
- check-flaky-or-pr-tests:
336+
pattern: << pipeline.parameters.run_file_tests >>
337+
- build:
338+
requires:
339+
- check-flaky-or-pr-tests
340+
- remix-ide-browser:
341+
requires:
342+
- build
343+
matrix:
344+
parameters:
345+
browser: ["chrome"]
346+
script: ["singletest.sh"]
347+
job: ["nogroup"]
348+
jobsize: ["1"]
349+
parallelism: [1]
350+
scriptparameter: [<< pipeline.parameters.run_file_tests >>]
351+
352+
run_pr_tests:
353+
when: << pipeline.parameters.run_pr_tests >>
354+
jobs:
355+
- check-flaky-or-pr-tests:
356+
pattern: "\\.pr"
357+
- build:
358+
requires:
359+
- check-flaky-or-pr-tests
360+
- remix-ide-browser:
361+
requires:
362+
- build
363+
matrix:
364+
parameters:
365+
browser: ["chrome"]
366+
script: ["singletest.sh"]
367+
job: ["nogroup"]
368+
jobsize: ["1"]
369+
parallelism: [1]
370+
scriptparameter: ["\\.pr"]
371+
300372
run_flaky_tests:
301373
when: << pipeline.parameters.run_flaky_tests >>
302374
jobs:
303-
- build
375+
- check-flaky-or-pr-tests:
376+
pattern: "\\.flaky"
377+
- build:
378+
requires:
379+
- check-flaky-or-pr-tests
304380
- remix-ide-browser:
305381
requires:
306382
- build
307383
matrix:
308384
parameters:
309385
browser: ["chrome", "firefox"]
310-
script: ["flaky.sh"]
386+
script: ["singletest.sh"]
311387
job: ["nogroup"]
312388
jobsize: ["1"]
313389
parallelism: [5]
390+
scriptparameter: ["\\.flaky"]
314391

315392
run_metamask_tests:
316393
when: << pipeline.parameters.run_metamask_tests >>
@@ -327,7 +404,7 @@ workflows:
327404
jobsize: ["1"]
328405
parallelism: [1]
329406
web:
330-
when: << pipeline.parameters.web >>
407+
when: << pipeline.parameters.run_all_tests >>
331408
jobs:
332409
- build
333410
- build-plugin:
@@ -363,6 +440,7 @@ workflows:
363440
job: ["0","1","2","3","4","5","6","7","8","9"]
364441
jobsize: ["10"]
365442
parallelism: [15]
443+
scriptparameter: [""]
366444
- remix-ide-browser:
367445
requires:
368446
- build
@@ -374,6 +452,7 @@ workflows:
374452
job: ["0"]
375453
jobsize: ["10"]
376454
parallelism: [1]
455+
scriptparameter: [""]
377456
filters:
378457
branches:
379458
only: [/.*metamask.*/, 'master', 'remix_live', 'remix_beta']

apps/remix-ide-e2e/CIRCLE_CI.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
3+
# CircleCI Parameters and Workflows Overview
4+
5+
This project uses **CircleCI pipeline parameters** to control workflows and resources dynamically. Below is a description of the main parameters and their purpose:
6+
7+
## ✅ Boolean Parameters
8+
9+
These are used to enable or disable specific workflows:
10+
11+
- **`run_all_tests`**
12+
When `true`, runs the full suite of tests.
13+
- **`run_pr_tests`**
14+
When `true`, runs tests tagged with `#pr` or `#PR`.
15+
- **`run_flaky_tests`**
16+
When `true`, runs tests tagged with `#flaky`.
17+
- **`run_metamask_tests`**
18+
When `true`, runs only the MetaMask-related tests.
19+
- **`windows`, `mac`, `linux`**
20+
Used to selectively run OS-specific builds or tests.
21+
22+
## ✅ String Parameters
23+
24+
- **`run_file_tests`**
25+
Specifies a specific filename or pattern to run targeted tests.
26+
- **`keyword`**
27+
A custom keyword string. When specified, the workflow searches for test files containing this keyword in their filenames. This is used by the `run_custom_keyword_tests` workflow to trigger tests selectively.
28+
29+
## ✅ Enum Parameter
30+
31+
- **`resource_class`**
32+
Controls the compute size used for jobs.
33+
Allowed values:
34+
- `medium`
35+
- `large`
36+
- `xlarge` (default)
37+
- `2xlarge`
38+
39+
This parameter is applied across jobs to adjust resource allocation dynamically. For example, you can trigger a pipeline with:
40+
```
41+
resource_class=2xlarge
42+
```
43+
to speed up builds on more powerful machines.
44+

apps/remix-ide-e2e/src/buildGroupTests.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ fs.readdirSync(testFolder).forEach(file => {
1515
if (!file.includes('group')) {
1616
const content = fs.readFileSync(testFolder + file, 'utf8')
1717
const matches = content.match(/group\d+/g)
18-
createFlakyTestFiles(file, content)
18+
createTaggedTestFiles(file, content)
1919
createFiles(file, matches)
2020
}
2121
})
2222

23-
function createFiles(file, matches, flaky = false) {
23+
function createFiles(file, matches, tag = false) {
2424
if (matches) {
2525
const unique = matches.filter(onlyUnique)
2626
unique.map((group) => {
2727
const rewrite = source.replace('#groupname', group).replace('#file', file.replace('.ts', ''))
2828
const extension = file.split('.')
2929
extension.shift()
3030
let filename
31-
if (!flaky) {
31+
if (!tag) {
3232
filename = `${testFolder}${file.split('.').shift()}_${group}.${extension.join('.')}`
3333
} else {
34-
filename = `${testFolder}${file.split('.').shift()}_${group}.flaky.ts`
34+
filename = `${testFolder}${file.split('.').shift()}_${group}.${tag.toLowerCase()}.ts`
3535
}
3636
fs.writeFileSync(filename, rewrite)
3737
})
@@ -42,14 +42,17 @@ function onlyUnique(value, index, self) {
4242
return self.indexOf(value) === index
4343
}
4444

45-
function createFlakyTestFiles(file, text) {
45+
function createTaggedTestFiles(file, text) {
4646
const lines = text.split('\n')
47-
lines.forEach((line, index) => {
48-
// if line contains #flaky
49-
if (line.includes('#flaky')) {
47+
lines.forEach((line) => {
48+
if (line.includes('#flaky') || line.includes('#pr') || line.includes('#PR')) {
5049
const matches = line.match(/group\d+/g)
51-
const unique = matches.filter(onlyUnique)
52-
createFiles(file, matches, true)
50+
if (matches) {
51+
const tags = line.match(/#(flaky|pr|PR)/gi).map(t => t.replace('#', '').toLowerCase());
52+
tags.forEach(tag => {
53+
createFiles(file, matches, tag);
54+
});
55+
}
5356
}
5457
})
5558
}

apps/remix-ide/ci/browser_test.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ sleep 5
1717
node apps/remix-ide/ci/splice_tests.js $2 $3
1818
TESTFILES=$(node apps/remix-ide/ci/splice_tests.js $2 $3 | grep -v 'metamask' | circleci tests split --split-by=timings)
1919
for TESTFILE in $TESTFILES; do
20-
npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1 || npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1 || TEST_EXITCODE=1
20+
if ! npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1; then
21+
if ! npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1; then
22+
TEST_EXITCODE=1
23+
break
24+
fi
25+
fi
2126
done
2227

2328
echo "$TEST_EXITCODE"
24-
if [ "$TEST_EXITCODE" -eq 1 ]
25-
then
29+
# Fail the test early and cancel the workflow
30+
if [ "$TEST_EXITCODE" -eq 1 ]; then
31+
echo "❌ Test failed. Attempting to cancel the workflow..."
32+
curl -s -X POST \
33+
-H "Authorization: Basic $FAIL_FAST_TOKEN" \
34+
-H "Content-Type: application/json" \
35+
"https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel"
2636
exit 1
2737
fi

apps/remix-ide/ci/flaky.sh renamed to apps/remix-ide/ci/singletest.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
set -e
44

5-
TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.flaky" | sort )
5+
TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "${4}" | sort )
66

77
# count test files
8-
fileCount=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "\.flaky" | wc -l )
8+
fileCount=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep "${4}" | wc -l )
99
# if fileCount is 0
1010
if [ $fileCount -eq 0 ]
1111
then
12-
echo "No flaky tests found"
12+
echo "No flaky or PR tests found"
1313
exit 0
1414
fi
1515

0 commit comments

Comments
 (0)