@@ -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
0 commit comments