Skip to content

Commit f9054a0

Browse files
Add validation to stage_for_s3.bash to fail on missing files
- Use set -euo pipefail for strict error handling - Validate presence of all 4 Node.js tarballs after download - Validate presence of all 4 fibers binaries from release - Use curl --fail to catch S3 download errors - Verify fibers tarball contains expected package directory - Count processed tarballs and fail if < 4 processed - Fix tar flag: use -xJf for .tar.xz files (was -xzf) - Add detailed progress output Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
1 parent ca685c0 commit f9054a0

1 file changed

Lines changed: 78 additions & 10 deletions

File tree

stage_for_s3.bash

Lines changed: 78 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,78 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Expected files that must be present after downloads
5+
EXPECTED_NODE_TARBALLS=(
6+
"node-*-linux-x64-pc-LATEST.tar.xz"
7+
"node-*-linux-arm64-pc-LATEST.tar.xz"
8+
"node-*-darwin-x64-pc-LATEST.tar.xz"
9+
"node-*-darwin-arm64-pc-LATEST.tar.xz"
10+
)
11+
12+
EXPECTED_FIBERS_BINARIES=(
13+
"linux-x64-*.tar.gz"
14+
"linux-arm64-*.tar.gz"
15+
"darwin-x64-*.tar.gz"
16+
"darwin-arm64-*.tar.gz"
17+
)
18+
19+
check_files_exist() {
20+
local pattern="$1"
21+
local description="$2"
22+
# shellcheck disable=SC2086
23+
if ! ls $pattern 1>/dev/null 2>&1; then
24+
echo "ERROR: Missing expected file matching pattern: $pattern ($description)" >&2
25+
return 1
26+
fi
27+
echo "✓ Found: $pattern"
28+
}
229

330
mkdir stage
4-
cd stage || exit
31+
cd stage || exit 1
532

633
TIMESTAMP=$(date '+%Y%m%d.%H%M')
734

835
echo "Current timestamp is $TIMESTAMP"
36+
echo ""
37+
echo "=== Downloading Node.js release artifacts ==="
938

1039
gh release download -p "*.gz"
1140
gh release download -p "*.xz"
1241

13-
curl "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz
42+
echo ""
43+
echo "=== Validating Node.js tarballs ==="
44+
for pattern in "${EXPECTED_NODE_TARBALLS[@]}"; do
45+
check_files_exist "$pattern" "Node.js tarball"
46+
done
47+
48+
echo ""
49+
echo "=== Validating fibers binaries from release ==="
50+
for pattern in "${EXPECTED_FIBERS_BINARIES[@]}"; do
51+
check_files_exist "$pattern" "fibers binary"
52+
done
53+
54+
echo ""
55+
echo "=== Downloading fibers package from S3 ==="
56+
curl --fail -sS "https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz
57+
58+
if [[ ! -f fibers-5.0.4.tar.gz ]]; then
59+
echo "ERROR: Failed to download fibers package from S3" >&2
60+
exit 1
61+
fi
62+
echo "✓ Downloaded fibers-5.0.4.tar.gz"
63+
1464
tar -xzf fibers-5.0.4.tar.gz
1565

66+
if [[ ! -d package ]]; then
67+
echo "ERROR: fibers tarball did not contain expected 'package' directory" >&2
68+
exit 1
69+
fi
70+
71+
echo ""
72+
echo "=== Extracting fibers binaries into package ==="
1673
find . -name "*.gz" | while read -r a
1774
do
75+
echo " Extracting: $a"
1876
tar -xzf "$a" -C package/bin
1977
rm "$a"
2078
done
@@ -27,6 +85,9 @@ UNIQUE="pc-${TIMESTAMP}-${SHORT_HASH}"
2785

2886
mv temp.tgz "fibers-5.0.4-${UNIQUE}.tgz"
2987

88+
echo ""
89+
echo "=== Processing Node.js tarballs ==="
90+
processed_count=0
3091
for file in *.tar.xz; do
3192
if [[ "$file" == *-LATEST.tar.xz ]]; then
3293
base="${file%-LATEST.tar.xz}"
@@ -43,28 +104,35 @@ for file in *.tar.xz; do
43104

44105
echo "Target Dir: $target_dir"
45106
mkdir "$target_dir"
46-
tar -xzf "$new_name" -C "$target_dir"
47-
mv "$target_dir/usr/local/*" "$target_dir"
48-
rm -fr "$target_dir/usr/local"
107+
tar -xJf "$new_name" -C "$target_dir"
108+
mv "$target_dir/usr/local/"* "$target_dir/"
109+
rm -fr "$target_dir/usr"
49110

50111
tar -cJf "$new_name" "$target_dir"
51112

52113
rm -fr "$target_dir"
53114

54-
echo " Done: Archive now contains:"
115+
echo " Done: Archive now contains:"
55116
tar -tf "$new_name" | head
56-
117+
echo ""
118+
((processed_count++))
57119
else
58120
echo "Warning: Skipped $new_name due to unexpected filename format."
59121
fi
60122
fi
61123
done
62124

125+
if [[ $processed_count -lt 4 ]]; then
126+
echo "ERROR: Expected to process at least 4 Node.js tarballs, but only processed $processed_count" >&2
127+
exit 1
128+
fi
63129

64130
cd ..
65131
mv stage "node-${UNIQUE}"
66132

133+
echo ""
134+
echo "=== SUCCESS ==="
67135
echo "Files are in node-${UNIQUE}, please upload to s3"
68-
69-
70-
136+
echo ""
137+
echo "Final contents:"
138+
ls -la "node-${UNIQUE}/"

0 commit comments

Comments
 (0)