Skip to content

Commit 6949c4e

Browse files
committed
ci: add DeepSWE image build and sync workflow
1 parent 7f9ac1d commit 6949c4e

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: build-and-sync-deep-swe-images
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
target_registry:
7+
description: "Destination registry/repository prefix (without a trailing slash)"
8+
required: true
9+
default: "eval-repo-prod-registry.cn-beijing.cr.aliyuncs.com/eval"
10+
type: string
11+
force:
12+
description: "Re-copy runtime images and rebuild verifier images that already exist"
13+
required: true
14+
default: false
15+
type: boolean
16+
task_id:
17+
description: "Optional single task directory name for a smoke test; leave blank for all 113 tasks"
18+
required: false
19+
default: ""
20+
type: string
21+
22+
jobs:
23+
deep-swe-images:
24+
name: DeepSWE images (${{ matrix.batch }}/8)
25+
if: ${{ inputs.task_id == '' || matrix.batch == 0 }}
26+
runs-on: ubuntu-24.04
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
batch: [0, 1, 2, 3, 4, 5, 6, 7]
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Authenticate to destination registry
35+
env:
36+
TARGET_REGISTRY: ${{ inputs.target_registry }}
37+
TARGET_USERNAME: ${{ secrets.ALIYUN_USERNAME_CIYUAN }}
38+
TARGET_PASSWORD: ${{ secrets.ALIYUN_PASSWORD_CIYUAN }}
39+
run: |
40+
set -euo pipefail
41+
test -n "$TARGET_USERNAME"
42+
test -n "$TARGET_PASSWORD"
43+
registry_host="${TARGET_REGISTRY%%/*}"
44+
printf '%s' "$TARGET_PASSWORD" | docker login "$registry_host" --username "$TARGET_USERNAME" --password-stdin
45+
46+
- name: Mirror runtime images and build verifier images
47+
env:
48+
BATCH: ${{ matrix.batch }}
49+
BATCH_COUNT: "8"
50+
DATASET_DIR: datasets/deep-swe
51+
TARGET_REGISTRY: ${{ inputs.target_registry }}
52+
TARGET_CREDS: ${{ secrets.ALIYUN_USERNAME_CIYUAN }}:${{ secrets.ALIYUN_PASSWORD_CIYUAN }}
53+
FORCE: ${{ inputs.force }}
54+
TASK_ID: ${{ inputs.task_id }}
55+
run: bash .github/workflows/internal/deep-swe/build-sync-images.sh
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env bash
2+
# Mirror the image Pier uses for each task, then bake that mirrored image into
3+
# the corresponding hidden-test verifier image. The verifier Dockerfiles are
4+
# intentionally not changed in the dataset checkout: their FROM instruction is
5+
# rewritten only in a temporary Dockerfile for this build.
6+
set -euo pipefail
7+
8+
: "${BATCH:?BATCH must be set}"
9+
: "${BATCH_COUNT:?BATCH_COUNT must be set}"
10+
: "${DATASET_DIR:?DATASET_DIR must be set}"
11+
: "${TARGET_REGISTRY:?TARGET_REGISTRY must be set}"
12+
: "${TARGET_CREDS:?TARGET_CREDS must be set}"
13+
14+
force="${FORCE:-false}"
15+
case "$force" in
16+
true|false) ;;
17+
*) echo "FORCE must be true or false, got: $force" >&2; exit 2 ;;
18+
esac
19+
20+
if (( BATCH < 0 || BATCH >= BATCH_COUNT )); then
21+
echo "BATCH must be in [0, $((BATCH_COUNT - 1))], got: $BATCH" >&2
22+
exit 2
23+
fi
24+
25+
task_id_filter="${TASK_ID:-}"
26+
if [[ -n "$task_id_filter" ]]; then
27+
if [[ ! -d "$DATASET_DIR/$task_id_filter" ]]; then
28+
echo "Unknown DeepSWE task_id: $task_id_filter" >&2
29+
exit 2
30+
fi
31+
task_dirs=("$DATASET_DIR/$task_id_filter")
32+
else
33+
mapfile -t task_dirs < <(find "$DATASET_DIR" -mindepth 1 -maxdepth 1 -type d -print | sort)
34+
fi
35+
total="${#task_dirs[@]}"
36+
batch_size=$(( (total + BATCH_COUNT - 1) / BATCH_COUNT ))
37+
start=$(( BATCH * batch_size ))
38+
end=$(( start + batch_size ))
39+
(( end > total )) && end=$total
40+
41+
echo "DeepSWE tasks: $total; batch $BATCH/$BATCH_COUNT: indexes $start..$((end - 1))"
42+
43+
runtime_ok=0
44+
verifier_ok=0
45+
skipped=0
46+
47+
image_exists() {
48+
skopeo inspect "docker://$1" --creds="$TARGET_CREDS" >/dev/null 2>&1
49+
}
50+
51+
for (( index=start; index<end; index++ )); do
52+
task_dir="${task_dirs[$index]}"
53+
task_id="${task_dir##*/}"
54+
task_toml="$task_dir/task.toml"
55+
tests_dir="$task_dir/tests"
56+
57+
test -f "$task_toml"
58+
test -f "$tests_dir/Dockerfile"
59+
60+
# This is Pier's default agent image. It is also the base image declared by
61+
# the task's verifier Dockerfile; checking that prevents a mismatched pair.
62+
source_runtime=$(sed -n 's/^docker_image = "\([^"]*\)"/\1/p' "$task_toml")
63+
test -n "$source_runtime"
64+
test_runtime=$(awk '$1 == "FROM" { print $2; exit }' "$tests_dir/Dockerfile")
65+
if [[ "$source_runtime" != "$test_runtime" ]]; then
66+
echo "[$task_id] task.toml image and tests/Dockerfile base differ" >&2
67+
exit 1
68+
fi
69+
70+
# Keep the original source path below the target prefix. This follows the
71+
# repository's other image-sync jobs and avoids collisions between sources.
72+
runtime_dest="${TARGET_REGISTRY%/}/${source_runtime}"
73+
verifier_dest="${TARGET_REGISTRY%/}/deep-swe-verifier/${task_id}:v1.1"
74+
75+
printf '[%d/%d] %s runtime: ' "$((index + 1))" "$total" "$task_id"
76+
if [[ "$force" == false ]] && image_exists "$runtime_dest"; then
77+
echo 'SKIP'
78+
((skipped+=1))
79+
else
80+
echo 'COPY'
81+
skopeo copy --all "docker://${source_runtime}" "docker://${runtime_dest}" --dest-creds="$TARGET_CREDS"
82+
((runtime_ok+=1))
83+
fi
84+
85+
printf '[%d/%d] %s verifier: ' "$((index + 1))" "$total" "$task_id"
86+
if [[ "$force" == false ]] && image_exists "$verifier_dest"; then
87+
echo 'SKIP'
88+
((skipped+=1))
89+
continue
90+
fi
91+
echo 'BUILD + PUSH'
92+
93+
# Building from the mirrored runtime makes a batch self-contained after the
94+
# copy step, rather than pulling its hidden-test base from public ECR.
95+
temp_dir=$(mktemp -d)
96+
trap 'rm -rf "$temp_dir"' EXIT
97+
awk -v runtime="$runtime_dest" '
98+
$1 == "FROM" { print "FROM " runtime; next }
99+
{ print }
100+
' "$tests_dir/Dockerfile" > "$temp_dir/Dockerfile"
101+
102+
docker pull "$runtime_dest"
103+
docker build --pull --tag "$verifier_dest" --file "$temp_dir/Dockerfile" "$tests_dir"
104+
docker push "$verifier_dest"
105+
# Each task has a different large runtime base. Reclaim it before the next
106+
# task so an Actions runner does not accumulate the full 113-image suite.
107+
docker image rm -f "$verifier_dest" "$runtime_dest" >/dev/null 2>&1 || true
108+
rm -rf "$temp_dir"
109+
trap - EXIT
110+
((verifier_ok+=1))
111+
done
112+
113+
echo "Batch complete: $runtime_ok runtime copies, $verifier_ok verifier builds, $skipped skips"

0 commit comments

Comments
 (0)