Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(e2e): enhance shard selection logic

Steven Enamakel7d147ee9de29
diff --git a/app/scripts/e2e-web-selection.mjs b/app/scripts/e2e-web-selection.mjs
index d963f6b374..f655b2eeac 100644
--- a/app/scripts/e2e-web-selection.mjs
+++ b/app/scripts/e2e-web-selection.mjs
@@ -7,6 +7,9 @@ import { fileURLToPath } from 'node:url';
const appRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const contractPath = path.join(appRoot, 'scripts/e2e-web-selection-contract.json');
+const allowedDiagnosticPaths = new Set([
+ 'test/playwright/specs/aui-tool-result-elements.spec.ts',
+]);
function sortedUnique(paths, label) {
const sorted = [...paths].sort();
@@ -29,6 +32,12 @@ export function classifySpecFiles(discoveredPaths, contract) {
diagnosticEntries.map(entry => entry.path),
'diagnostic inventory'
);
+ const unknownDiagnosticPolicy = diagnostic.filter(file => !allowedDiagnosticPaths.has(file));
+ if (unknownDiagnosticPolicy.length || diagnostic.length !== allowedDiagnosticPaths.size) {
+ throw new Error(
+ `diagnostic inventory differs from the reviewed file allowlist: ${diagnostic.join(', ')}`
+ );
+ }
const unknownDiagnostics = diagnostic.filter(file => !discoveredSet.has(file));
if (unknownDiagnostics.length) {
throw new Error(`stale or unknown diagnostic spec: ${unknownDiagnostics.join(', ')}`);
diff --git a/app/scripts/e2e-web-shards.sh b/app/scripts/e2e-web-shards.sh
index f0e8e4626f..45dd70abac 100755
--- a/app/scripts/e2e-web-shards.sh
+++ b/app/scripts/e2e-web-shards.sh
@@ -7,11 +7,13 @@ cd "$REPO_ROOT"
lane=""
lanes="4"
+selection="all"
list=0
while (($#)); do
case "$1" in
--lane=*) lane="${1#*=}" ;;
--lanes=*) lanes="${1#*=}" ;;
+ --selection=*) selection="${1#*=}" ;;
--list) list=1 ;;
*) echo "unknown argument: $1" >&2; exit 2 ;;
esac
@@ -21,6 +23,21 @@ done
[[ "$lane" =~ ^[1-9][0-9]*$ && "$lanes" =~ ^[1-9][0-9]*$ ]] || { echo "--lane and --lanes must be positive integers" >&2; exit 2; }
(( lane <= lanes )) || { echo "lane $lane exceeds lane count $lanes" >&2; exit 2; }
+selected_paths="$(node app/scripts/e2e-web-selection.mjs "--selection=$selection")" || exit $?
+selected_files=()
+while IFS= read -r file; do
+ [[ -n "$file" ]] && selected_files+=("$file")
+done <<< "$selected_paths"
+(( ${#selected_files[@]} > 0 )) || { echo "$selection selection is empty" >&2; exit 2; }
+
+contains_file() {
+ local wanted="$1" file
+ for file in "${selected_files[@]}"; do
+ [[ "$file" == "$wanted" ]] && return 0
+ done
+ return 1
+}
+
special_files=(
"test/playwright/specs/connections-tab-aliases.spec.ts"
"test/playwright/specs/connections-tab-deeplinks.spec.ts"
@@ -38,21 +55,34 @@ special_titles=(
if (( list )); then
first=1
printf '['
+ assigned=0
+ if [[ "$selection" == diagnostic ]]; then
+ for i in "${!selected_files[@]}"; do
+ if (( i % lanes + 1 == lane )); then
+ (( first )) || printf ','
+ printf '{"kind":"diagnostic-file","index":%d,"file":"%s"}' "$i" "${selected_files[$i]}"
+ first=0
+ assigned=$((assigned + 1))
+ fi
+ done
+ else
for i in "${!special_files[@]}"; do
- if (( i % lanes + 1 == lane )); then
+ if contains_file "${special_files[$i]}" && (( i % lanes + 1 == lane )); then
(( first )) || printf ','
printf '{"kind":"special-file","index":%d,"file":"%s"}' "$i" "${special_files[$i]}"
first=0
+ assigned=$((assigned + 1))
fi
done
for i in "${!special_titles[@]}"; do
unit=$((i + ${#special_files[@]}))
- if (( unit % lanes + 1 == lane )); then
+ if contains_file "test/playwright/specs/skills-search-install.spec.ts" && (( unit % lanes + 1 == lane )); then
escaped="${special_titles[$i]//\\/\\\\}"
escaped="${escaped//\"/\\\"}"
(( first )) || printf ','
printf '{"kind":"special-title","index":%d,"file":"test/playwright/specs/skills-search-install.spec.ts","title":"%s"}' "$unit" "$escaped"
first=0
+ assigned=$((assigned + 1))
fi
done
for ((shard=1; shard<=64; shard++)); do
@@ -60,9 +90,12 @@ if (( list )); then
(( first )) || printf ','
printf '{"kind":"shard","index":%d,"shard":"%d/64"}' "$shard" "$shard"
first=0
+ assigned=$((assigned + 1))
fi
done
+ fi
printf ']\n'
+ (( assigned > 0 )) || { echo "$selection selection assigns no units to lane $lane" >&2; exit 2; }
exit 0
fi
@@ -78,12 +111,12 @@ escape_regex() {
printf '%s' "$1" | sed 's/[][(){}.*+?^$|\\]/\\&/g'
}
-mkdir -p "$workspace_root/lane-$lane/receipts"
-receipt_dir="$workspace_root/lane-$lane/receipts"
+mkdir -p "$workspace_root/selection-$selection/lane-$lane/receipts"
+receipt_dir="$workspace_root/selection-$selection/lane-$lane/receipts"
overall=0
run_unit() {
local unit="$1"; shift
- local workspace="$workspace_root/lane-$lane/$unit"
+ local workspace="$workspace_root/selection-$selection/lane-$lane/$unit"
local receipt="$receipt_dir/$unit.exit"
mkdir -p "$workspace"
workspace="$(cd "$workspace" && pwd)"
@@ -96,20 +129,44 @@ run_unit() {
(( status == 0 )) || overall=1
}
+if [[ "$selection" == diagnostic ]]; then
+ assigned=0
+ for i in "${!selected_files[@]}"; do
+ if (( i % lanes + 1 == lane )); then
+ run_unit "diagnostic-$i" "${selected_files[$i]}"
+ assigned=$((assigned + 1))
+ fi
+ fi
+ (( assigned > 0 )) || { echo "$selection selection assigns no units to lane $lane" >&2; exit 2; }
+else
for i in "${!special_files[@]}"; do
- if (( i % lanes + 1 == lane )); then
+ if contains_file "${special_files[$i]}" && (( i % lanes + 1 == lane )); then
run_unit "special-$i" "${special_files[$i]}"
fi
done
for i in "${!special_titles[@]}"; do
unit=$((i + ${#special_files[@]}))
- if (( unit % lanes + 1 == lane )); then
+ if contains_file "test/playwright/specs/skills-search-install.spec.ts" && (( unit % lanes + 1 == lane )); then
run_unit "special-$unit" test/playwright/specs/skills-search-install.spec.ts -g "$(escape_regex "${special_titles[$i]}")"
fi
done
+shard_files=()
+if [[ "$selection" == required ]]; then
+ for file in "${selected_files[@]}"; do
+ if [[ "$file" != "test/playwright/specs/connections-tab-aliases.spec.ts" && "$file" != "test/playwright/specs/connections-tab-deeplinks.spec.ts" ]]; then
+ shard_files+=("$file")
+ fi
+ done
+fi
+(( ${#shard_files[@]} > 0 || "$selection" == all )) || { echo "$selection selection has no ordinary shard files" >&2; exit 2; }
for ((shard=1; shard<=64; shard++)); do
if (( (shard - 1) % lanes + 1 == lane )); then
- run_unit "shard-$shard" --shard="$shard/64" --grep-invert='Connections (aliases|deep links)|Skills explorer'
+ if [[ "$selection" == all ]]; then
+ run_unit "shard-$shard" --shard="$shard/64" --grep-invert='Connections (aliases|deep links)|Skills explorer'
+ else
+ run_unit "shard-$shard" "${shard_files[@]}" --shard="$shard/64" --grep-invert='Connections (aliases|deep links)|Skills explorer'
+ fi
fi
done
+fi
exit "$overall"