Skip to content

Commit 04b0bbb

Browse files
authored
Merge branch 'master' into removeWeb3
2 parents 9e88621 + d4a7f63 commit 04b0bbb

File tree

2 files changed

+118
-12
lines changed

2 files changed

+118
-12
lines changed

.circleci/config.yml

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ parameters:
4949
type: boolean
5050
default: false
5151

52+
# Timings fetch window (fewer = faster API calls)
53+
timings_limit:
54+
type: integer
55+
default: 1
56+
5257
# Rerun-failed configuration
5358
rerun_failed_history:
5459
type: integer
@@ -154,10 +159,78 @@ jobs:
154159
set -e
155160
tar -cf remix-dist.tar dist/apps/remix-ide dist/apps/remix-ide-e2e dist/apps/remix-ide/assets/js/soljson dist/libs 2>/dev/null || true
156161
gzip -1 remix-dist.tar
162+
- run:
163+
name: Fetch CircleCI timings for shard planning (best effort)
164+
command: |
165+
if [ -n "${CIRCLECI_TOKEN:-}" ]; then
166+
echo "Fetching timings for branch ${CIRCLE_BRANCH:-all}..."
167+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch "${CIRCLE_BRANCH:-}" --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
168+
if [ ! -s timings-current.json ] || [ "$(jq -r '.files | length' timings-current.json 2>/dev/null || echo 0)" -eq 0 ]; then
169+
echo "No timings for current branch; falling back to master"
170+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch master --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
171+
fi
172+
else
173+
echo "CIRCLECI_TOKEN not set; shard planning will use median defaults."
174+
fi
175+
- run:
176+
name: Precompute and cache E2E shard splits
177+
command: |
178+
set -e
179+
PARALLEL=<< pipeline.parameters.e2e_parallelism >>
180+
COMMIT_SHA=${CIRCLE_SHA1:-unknown}
181+
CACHE_PREFIX="reports/shards/cache/${COMMIT_SHA}-shards${PARALLEL}"
182+
mkdir -p "$CACHE_PREFIX" reports/shards
183+
echo "Enumerating enabled test basenames from dist..."
184+
TEST_NAMES=$(find dist/apps/remix-ide-e2e/src/tests -type f \( -name "*.test.js" -o -name "*.spec.js" \) -print0 \
185+
| xargs -0 grep -IL "@disabled" \
186+
| xargs -I {} basename {} \
187+
| sed 's/\.js$//' \
188+
| grep -v metamask)
189+
# Persist full test list for visibility
190+
printf '%s\n' "$TEST_NAMES" > reports/shards/all-tests.txt
191+
COUNT=$(printf '%s\n' "$TEST_NAMES" | wc -l | awk '{print $1}')
192+
echo "Found $COUNT enabled tests. Planning for $PARALLEL shard(s)."
193+
# Generate a manifest (index 0 is arbitrary; manifest includes all bins)
194+
printf '%s\n' "$TEST_NAMES" | node scripts/plan-shards.js \
195+
--shards "$PARALLEL" \
196+
--index 0 \
197+
--timings timings-current.json \
198+
--manifest-out "${CACHE_PREFIX}/manifest.json" \
199+
--verbose > /dev/null || true
200+
# Generate per-shard file lists deterministically
201+
for i in $(seq 0 $((PARALLEL-1))); do
202+
OUT=$(printf '%s\n' "$TEST_NAMES" | node scripts/plan-shards.js --shards "$PARALLEL" --index "$i" --timings timings-current.json)
203+
printf '%s\n' "$OUT" > "${CACHE_PREFIX}/files-$i.txt"
204+
done
205+
echo "Precomputed shard files saved under $CACHE_PREFIX"
206+
- run:
207+
name: Generate shard overview (human + JSON)
208+
command: |
209+
# Build overview.txt and overview.json next to manifest.json
210+
PARALLEL=<< pipeline.parameters.e2e_parallelism >>
211+
COMMIT_SHA=${CIRCLE_SHA1:-unknown}
212+
CACHE_PREFIX="reports/shards/cache/${COMMIT_SHA}-shards${PARALLEL}"
213+
MANIFEST_PATH="${CACHE_PREFIX}/manifest.json"
214+
echo "Looking for manifest at: $MANIFEST_PATH"
215+
if [ -f "$MANIFEST_PATH" ]; then
216+
node scripts/generate-shard-overview.js "$CACHE_PREFIX" timings-current.json || true
217+
else
218+
echo "No manifest found at $MANIFEST_PATH; skipping overview generation."
219+
ls -la "$(dirname "$MANIFEST_PATH")" || true
220+
fi
221+
- save_cache:
222+
key: v1-shards-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.e2e_parallelism >>
223+
paths:
224+
- reports/shards/cache
157225
- persist_to_workspace:
158226
root: .
159227
paths:
160228
- remix-dist.tar.gz
229+
- reports/shards
230+
- store_artifacts:
231+
path: ./reports/shards
232+
- store_artifacts:
233+
path: ./timings-current.json
161234

162235
build-plugin:
163236
docker:
@@ -283,6 +356,9 @@ jobs:
283356
- restore_cache:
284357
keys:
285358
- v1-deps-{{ checksum "yarn.lock" }}
359+
- restore_cache:
360+
keys:
361+
- v1-shards-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.e2e_parallelism >>
286362
- run: yarn
287363
- run:
288364
name: Unpack dist from workspace
@@ -307,12 +383,12 @@ jobs:
307383
command: |
308384
if [ -n "${CIRCLECI_TOKEN:-}" ]; then
309385
echo "Fetching timings for branch ${CIRCLE_BRANCH:-all}..."
310-
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch "${CIRCLE_BRANCH:-}" --limit 30 --json timings-current.json || true
386+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch "${CIRCLE_BRANCH:-}" --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
311387
312388
# If no timings found for this branch (new branch), fall back to master
313389
if [ ! -s timings-current.json ] || [ "$(jq -r '.files | length' timings-current.json 2>/dev/null || echo 0)" -eq 0 ]; then
314390
echo "⚠️ No timings found for branch ${CIRCLE_BRANCH:-current}, falling back to master..."
315-
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch master --limit 30 --json timings-current.json || true
391+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch master --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
316392
fi
317393
else
318394
echo "CIRCLECI_TOKEN not set; skipping timings fetch. Self-split will fall back to median weights."
@@ -359,12 +435,12 @@ jobs:
359435
command: |
360436
if [ -n "${CIRCLECI_TOKEN:-}" ]; then
361437
echo "Fetching timings for branch ${CIRCLE_BRANCH:-all}..."
362-
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch "${CIRCLE_BRANCH:-}" --limit 30 --json timings-current.json || true
438+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch "${CIRCLE_BRANCH:-}" --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
363439
364440
# If no timings found for this branch (new branch), fall back to master
365441
if [ ! -s timings-current.json ] || [ "$(jq -r '.files | length' timings-current.json 2>/dev/null || echo 0)" -eq 0 ]; then
366442
echo "⚠️ No timings found for branch ${CIRCLE_BRANCH:-current}, falling back to master..."
367-
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch master --limit 30 --json timings-current.json || true
443+
yarn ci:timings --slug gh/remix-project-org/remix-project --workflow web --branch master --limit << pipeline.parameters.timings_limit >> --json timings-current.json || true
368444
fi
369445
else
370446
echo "CIRCLECI_TOKEN not set; planning will use median default weights."
@@ -726,6 +802,7 @@ workflows:
726802
scriptparameter: [""]
727803
shard_index: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
728804
vertical_mode: [true]
805+
skip_timings: [true]
729806
- tests-passed:
730807
requires:
731808
- lint

apps/remix-ide/ci/browser_test.sh

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,51 @@ SELF_SPLIT=${SELF_SPLIT:-0}
1818
TIMINGS_JSON=${TIMINGS_JSON:-timings-current.json}
1919
E2E_RETRIES=${E2E_RETRIES:-0} # number of retries on failure per test (0 = no retry)
2020

21+
# Cache key components for deterministic shard reuse (e.g., on CircleCI reruns)
22+
# - Keyed by commit SHA and shard count; includes shard index per file
23+
COMMIT_SHA=${CIRCLE_SHA1:-$(git rev-parse --short=12 HEAD 2>/dev/null || echo unknown)}
24+
SHARD_CACHE_DIR=${SHARD_CACHE_DIR:-reports/shards/cache}
25+
SHARD_CACHE_KEY="${COMMIT_SHA}-shards${PARALLEL_TOTAL}"
26+
SHARD_CACHE_PREFIX="${SHARD_CACHE_DIR}/${SHARD_CACHE_KEY}"
27+
SHARD_CACHE_FILE="${SHARD_CACHE_PREFIX}/files-${PARALLEL_INDEX}.txt"
28+
SHARD_MANIFEST_FILE="${SHARD_CACHE_PREFIX}/manifest.json"
29+
2130
# Build the list of enabled test files
2231
BASE_FILES=$(find dist/apps/remix-ide-e2e/src/tests -type f \( -name "*.test.js" -o -name "*.spec.js" \) -print0 \
2332
| xargs -0 grep -IL "@disabled" \
2433
| xargs -I {} basename {} \
2534
| sed 's/\.js$//' \
2635
| grep -v 'metamask')
2736

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)
37+
# Try cache first (works for both SELF_SPLIT and CircleCI split modes)
38+
mkdir -p "$SHARD_CACHE_PREFIX" reports/shards
39+
if [ -f "$SHARD_CACHE_FILE" ]; then
40+
echo "==> Using cached shard selection: key=$SHARD_CACHE_KEY index=$PARALLEL_INDEX"
41+
TESTFILES=$(cat "$SHARD_CACHE_FILE")
3342
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)
43+
if [ "$SELF_SPLIT" = "1" ]; then
44+
echo "==> Using self shard planner (shards=$PARALLEL_TOTAL index=$PARALLEL_INDEX)"
45+
echo "ENV: CIRCLE_BRANCH=${CIRCLE_BRANCH:-local} CIRCLE_NODE_TOTAL=$PARALLEL_TOTAL CIRCLE_NODE_INDEX=$PARALLEL_INDEX E2E_RETRIES=$E2E_RETRIES"
46+
47+
# Optional: precompute and cache all shard files in one go when requested
48+
if [ "${SHARD_PRECOMPUTE_ALL:-0}" = "1" ] && [ ! -f "$SHARD_MANIFEST_FILE" ]; then
49+
echo "==> Precomputing all shard splits and caching (key=$SHARD_CACHE_KEY)"
50+
for i in $(seq 0 $((PARALLEL_TOTAL-1))); do
51+
OUT=$(printf '%s\n' "$BASE_FILES" | node scripts/plan-shards.js --shards "$PARALLEL_TOTAL" --index "$i" --timings "$TIMINGS_JSON" --manifest-out "$SHARD_MANIFEST_FILE")
52+
printf '%s\n' "$OUT" > "${SHARD_CACHE_PREFIX}/files-$i.txt"
53+
done
54+
TESTFILES=$(cat "$SHARD_CACHE_FILE")
55+
else
56+
TESTFILES=$(printf '%s\n' "$BASE_FILES" | node scripts/plan-shards.js --shards "$PARALLEL_TOTAL" --index "$PARALLEL_INDEX" --timings "$TIMINGS_JSON" --verbose --manifest-out "$SHARD_MANIFEST_FILE")
57+
# Cache the freshly computed list for this index
58+
printf '%s\n' "$TESTFILES" > "$SHARD_CACHE_FILE"
59+
fi
60+
else
61+
echo "==> Using CircleCI timings split"
62+
TESTFILES=$(printf '%s\n' "$BASE_FILES" | circleci tests split --split-by=timings)
63+
# Cache the selection so reruns reuse the same split
64+
printf '%s\n' "$TESTFILES" > "$SHARD_CACHE_FILE"
65+
fi
3766
fi
3867

3968
printf '%s\n' "$TESTFILES" > reports/shards/files-$PARALLEL_INDEX.txt

0 commit comments

Comments
 (0)