[CI] Fix empty wheel artifact checks - #8434
Conversation
|
@dulinriley is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
|
How do I merge this? I don't see the merge button, and I can't see a way to import it. Is it via pytorchbot? |
|
@claude are there any tests we can add for this change |
|
Claude finished @huydhn's task in 1m 44s —— View job Tests for the wheel-artifact fix
Short answer: yes, but the logic is currently inline shell inside the workflow YAML, which isn't unit-testable as-is. There's no shell-test harness in this repo today (only Option A — Extract to a script + add a test (recommended)Pull the wheel-collection logic into #!/usr/bin/env bash
set -euo pipefail
# Usage: prepare_wheel_artifacts.sh <src_dir> <dest_dir>
src_dir="${1:-dist}"
dest_dir="${2:-${RUNNER_ARTIFACT_DIR}}"
for wheel in "${src_dir}"/*.whl; do
if [[ -f "${wheel}" ]]; then
mv -v "${wheel}" "${dest_dir}/"
fi
doneEach of the 5 workflows then calls the script instead of duplicating the loop (the block is currently identical in Then a #!/usr/bin/env bats
setup() {
SRC="$(mktemp -d)"; DEST="$(mktemp -d)"
}
teardown() { rm -rf "${SRC}" "${DEST}"; }
@test "missing dist dir is a no-op" {
rm -rf "${SRC}"
run .github/scripts/prepare_wheel_artifacts.sh "${SRC}" "${DEST}"
[ "$status" -eq 0 ]
[ -z "$(ls -A "${DEST}")" ]
}
@test "empty dist dir is a no-op (does not move literal *.whl)" {
run .github/scripts/prepare_wheel_artifacts.sh "${SRC}" "${DEST}"
[ "$status" -eq 0 ]
[ -z "$(ls -A "${DEST}")" ]
}
@test "moves wheels, including filenames with spaces" {
touch "${SRC}/torch-2.0.whl" "${SRC}/my package.whl"
run .github/scripts/prepare_wheel_artifacts.sh "${SRC}" "${DEST}"
[ "$status" -eq 0 ]
[ -f "${DEST}/torch-2.0.whl" ]
[ -f "${DEST}/my package.whl" ]
}
@test "propagates a real mv failure" {
touch "${SRC}/torch-2.0.whl"
chmod 000 "${DEST}" # unwritable dest
run .github/scripts/prepare_wheel_artifacts.sh "${SRC}" "${DEST}"
chmod 755 "${DEST}"
[ "$status" -ne 0 ]
}These four cases map 1:1 to your manual test plan (missing / empty / populated / space-in-name / propagated failure). A tiny CI job ( Option B — Keep it inline, add no testIf extraction feels heavier than the fix warrants, it's reasonable to keep the inline loop and rely on the manual verification already in the PR description. Note: GitHub App permissions don't allow me to modify files under |
Let me merge it |
There was a bug in artifact preparation where
find "dist/" -name "*.whl"returned success wheneverdist/existed, even if it contained no wheels. The followingmv dist/*.whlthen failed and obscured the earlier build failure. This was observed in https://github.com/meta-pytorch/monarch/actions/runs/30938873470/job/92093926645.This change iterates over
dist/*.whland moves entries only when[[ -f "${wheel}" ]]succeeds. Missing and emptydist/directories are no-ops, while an actualmverror still fails the artifact preparation step.Test plan:
dist/behavior under Bash, including a wheel filename containing spaces.mvfailure is propagated.