Skip to content

Commit 0e31a81

Browse files
authored
Merge pull request #6476 from remix-project-org/feat/nx-cloud/setup
CI Refactor Optimize Money Saving
2 parents 1c15139 + 7a14547 commit 0e31a81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3447
-405
lines changed

.circleci/config.yml

Lines changed: 465 additions & 238 deletions
Large diffs are not rendered by default.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
v20.19.0

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ yarn run serve:production
8686
```
8787
Production build will be served by default to `http://localhost:8080/` or `http://127.0.0.1:8080/`
8888

89+
## Nx Cloud caching
90+
91+
This repo uses Nx Cloud to speed up builds and keep CI deterministic via remote caching.
92+
93+
- Configuration: `nx.json` uses the Nx Cloud runner and reads the token from the `NX_CLOUD_ACCESS_TOKEN` environment variable.
94+
- CI: CircleCI jobs automatically use `--cloud` when the token is present; for forked PRs (no secrets), they fall back to local-only caching. Build logs are stored under `logs/nx-build.log`.
95+
- Verifying locally: run the same target twice; the second run should print “Nx read the output from the cache”. Example: `nx run remix-ide:build` and run it again.
96+
- Insights: View cache analytics and run details at https://nx.app (links appear in Nx output when the token is configured).
97+
8998
## Docker:
9099

91100
Prerequisites:

apps/contract-verification/webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ module.exports = composePlugins(withNx(), (config) => {
4343
// add public path
4444
config.output.publicPath = '/'
4545

46-
// set filename
47-
config.output.filename = `[name].plugin-contract-verification.${versionData.timestamp}.js`
48-
config.output.chunkFilename = `[name].plugin-contract-verification.${versionData.timestamp}.js`
46+
// set deterministic filenames for better caching
47+
config.output.filename = `[name].plugin-contract-verification.[contenthash].js`
48+
config.output.chunkFilename = `[name].plugin-contract-verification.[contenthash].js`
4949

5050
// add copy & provide plugin
5151
config.plugins.push(

apps/quick-dapp/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"executor": "@nrwl/webpack:webpack",
1010
"outputs": ["{options.outputPath}"],
1111
"defaultConfiguration": "development",
12-
"dependsOn": ["install"],
1312
"options": {
1413
"compiler": "babel",
1514
"outputPath": "dist/apps/quick-dapp",
@@ -40,6 +39,7 @@
4039
},
4140
"install": {
4241
"executor": "nx:run-commands",
42+
"cache": false,
4343
"options": {
4444
"commands": [
4545
"cd apps/quick-dapp && yarn"

apps/remix-dapp/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"executor": "@nrwl/webpack:webpack",
1010
"outputs": ["{options.outputPath}"],
1111
"defaultConfiguration": "development",
12-
"dependsOn": ["install"],
1312
"options": {
1413
"compiler": "babel",
1514
"outputPath": "dist/apps/remix-dapp",
@@ -39,6 +38,7 @@
3938
},
4039
"install": {
4140
"executor": "nx:run-commands",
41+
"cache": false,
4242
"options": {
4343
"commands": [
4444
"cd apps/remix-dapp && yarn"

apps/remix-ide-e2e/src/tests/staticAnalysis.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
.click('*[data-id="treeViewLitreeViewItemcontracts/2_Owner.sol"]')
4040
.clickLaunchIcon('solidity')
4141
.click('*[id="compileBtn"]')
42+
.saveScreenshot('./reports/screenshots/compile2_Owner.png')
4243
.pause(10000)
4344
.clickLaunchIcon('solidityStaticAnalysis')
4445
.useXpath()
@@ -57,10 +58,12 @@ module.exports = {
5758
.pause(1000)
5859
.waitForElementVisible('span#ssaRemixtab')
5960
.click('span#ssaRemixtab')
60-
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '388')
61+
.waitForElementContainsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '384')
62+
6163
.click('label[id="headingshowLibWarnings"]')
6264
.pause(1000)
63-
.assert.containsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '3')
65+
.waitForElementContainsText('span#ssaRemixtab > *[data-id="RemixStaticAnalysisErrorCount', '3')
66+
6467
.end()
6568
}
6669
}

apps/remix-ide/.travis.yml

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

apps/remix-ide/ci/browser_test.sh

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,71 @@ set -e
44

55

66

7-
BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}}
7+
BUILD_ID=${CIRCLE_BUILD_NUM:-local}
88
echo "$BUILD_ID"
99
TEST_EXITCODE=0
10-
npx ganache &
11-
npx http-server -p 9090 --cors='*' ./node_modules &
12-
yarn run serve:production &
10+
npx ganache > /dev/null 2>&1 &
11+
npx http-server -p 9090 --cors='*' ./node_modules > /dev/null 2>&1 &
12+
yarn run serve:production > /dev/null 2>&1 &
1313
sleep 5
1414

15-
# grep -IRiL "@disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | xargs -I {} basename {} .test.js | grep -E "\b[${2}]"
16-
# TESTFILES=$(grep -IRiL "@disabled" "dist/apps/remix-ide-e2e/src/tests" | grep "\.spec\|\.test" | xargs -I {} basename {} .test.js | grep -E "\b[$2]" | circleci tests split --split-by=timings )
17-
node apps/remix-ide/ci/splice_tests.js $2 $3
18-
TESTFILES=$(node apps/remix-ide/ci/splice_tests.js $2 $3 | grep -v 'metamask' | circleci tests split --split-by=timings)
15+
PARALLEL_TOTAL=${CIRCLE_NODE_TOTAL:-1}
16+
PARALLEL_INDEX=${CIRCLE_NODE_INDEX:-0}
17+
SELF_SPLIT=${SELF_SPLIT:-0}
18+
TIMINGS_JSON=${TIMINGS_JSON:-timings-current.json}
19+
E2E_RETRIES=${E2E_RETRIES:-0} # number of retries on failure per test (0 = no retry)
20+
21+
# Build the list of enabled test files
22+
BASE_FILES=$(find dist/apps/remix-ide-e2e/src/tests -type f \( -name "*.test.js" -o -name "*.spec.js" \) -print0 \
23+
| xargs -0 grep -IL "@disabled" \
24+
| xargs -I {} basename {} \
25+
| sed 's/\.js$//' \
26+
| grep -v 'metamask')
27+
28+
if [ "$SELF_SPLIT" = "1" ]; then
29+
echo "==> Using self shard planner (shards=$PARALLEL_TOTAL index=$PARALLEL_INDEX)"
30+
echo "ENV: CIRCLE_BRANCH=${CIRCLE_BRANCH:-local} CIRCLE_NODE_TOTAL=$PARALLEL_TOTAL CIRCLE_NODE_INDEX=$PARALLEL_INDEX E2E_RETRIES=$E2E_RETRIES"
31+
mkdir -p reports/shards
32+
TESTFILES=$(printf '%s\n' "$BASE_FILES" | node scripts/plan-shards.js --shards "$PARALLEL_TOTAL" --index "$PARALLEL_INDEX" --timings "$TIMINGS_JSON" --verbose --manifest-out reports/shards/manifest-$PARALLEL_INDEX.json)
33+
else
34+
echo "==> Using CircleCI timings split"
35+
mkdir -p reports/shards
36+
TESTFILES=$(printf '%s\n' "$BASE_FILES" | circleci tests split --split-by=timings)
37+
fi
38+
39+
printf '%s\n' "$TESTFILES" > reports/shards/files-$PARALLEL_INDEX.txt
40+
COUNT=$(printf '%s\n' "$TESTFILES" | wc -l | awk '{print $1}')
41+
echo "==> Shard $PARALLEL_INDEX selected $COUNT test files"
42+
echo "==> Preview (first 20):"
43+
printf '%s\n' "$TESTFILES" | head -n 20
44+
echo "==> Preview (last 10):"
45+
printf '%s\n' "$TESTFILES" | tail -n 10
46+
echo "==> Full list (for grepability):"
47+
printf '%s\n' "$TESTFILES"
48+
49+
# If this batch includes remixd (slither) tests, prepare pip3/slither toolchain on-demand
50+
printf '%s\n' "$TESTFILES" | ./apps/remix-ide/ci/setup_slither_if_needed.sh
1951
for TESTFILE in $TESTFILES; do
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
52+
echo "Running test: ${TESTFILE}.js (retries on fail: $E2E_RETRIES)"
53+
attempt=0
54+
while true; do
55+
if npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-${1}.js dist/apps/remix-ide-e2e/src/tests/${TESTFILE}.js --env=$1; then
56+
# success
57+
break
58+
fi
59+
# failure
60+
if [ "$attempt" -lt "$E2E_RETRIES" ]; then
61+
attempt=$((attempt+1))
62+
echo "Retrying ${TESTFILE}.js (attempt $attempt of $E2E_RETRIES)"
63+
continue
64+
else
2265
TEST_EXITCODE=1
2366
break
2467
fi
68+
done
69+
# Stop the shard loop on permanent failure
70+
if [ "$TEST_EXITCODE" -eq 1 ]; then
71+
break
2572
fi
2673
done
2774

apps/remix-ide/ci/browser_test_plugin.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
BUILD_ID=${CIRCLE_BUILD_NUM:-${TRAVIS_JOB_NUMBER}}
5+
BUILD_ID=${CIRCLE_BUILD_NUM:-local}
66
echo "$BUILD_ID"
77
TEST_EXITCODE=0
88

@@ -14,6 +14,8 @@ yarn run serve:production &
1414
sleep 5
1515

1616
TESTFILES=$(grep -IRiL "\'@disabled\': \?true" "dist/apps/remix-ide-e2e/src/tests" | grep $1 | sort | circleci tests split )
17+
# Prepare slither toolchain if remixd tests are present
18+
printf '%s\n' "$TESTFILES" | ./apps/remix-ide/ci/setup_slither_if_needed.sh
1719
for TESTFILE in $TESTFILES; do
1820
npx nightwatch --config dist/apps/remix-ide-e2e/nightwatch-chrome.js $TESTFILE --env=chrome || TEST_EXITCODE=1
1921
done

0 commit comments

Comments
 (0)