Skip to content

Commit 5dd6a18

Browse files
committed
Add wheel count validation for release workflows
1 parent 767f15f commit 5dd6a18

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ jobs:
386386
CLOUDFLARE_R2_URL: ${{ secrets.CLOUDFLARE_R2_URL }}
387387
CLOUDFLARE_R2_REGION: "auto"
388388
CLOUDFLARE_R2_BUCKET_NAME: "packages"
389+
EXPECTED_WHEEL_COUNT: 9 # 3 Python versions × 3 platforms (ARM skipped on develop)
389390
steps:
390391
# https://github.com/step-security/harden-runner
391392
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -405,9 +406,12 @@ jobs:
405406
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
406407
with:
407408
path: dist
408-
pattern: "*.whl"
409+
pattern: "nautilus_trader-*.whl"
409410
merge-multiple: true
410411

412+
- name: Validate wheel count
413+
run: bash ./scripts/ci/validate-wheel-count.sh "$EXPECTED_WHEEL_COUNT"
414+
411415
# https://github.com/actions/attest-build-provenance
412416
- name: Attest wheel provenance
413417
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
@@ -446,6 +450,7 @@ jobs:
446450
CLOUDFLARE_R2_URL: ${{ secrets.CLOUDFLARE_R2_URL }}
447451
CLOUDFLARE_R2_REGION: "auto"
448452
CLOUDFLARE_R2_BUCKET_NAME: "packages"
453+
EXPECTED_WHEEL_COUNT: 12 # 3 Python versions × 4 platforms
449454
steps:
450455
# https://github.com/step-security/harden-runner
451456
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -465,9 +470,12 @@ jobs:
465470
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
466471
with:
467472
path: dist
468-
pattern: "*.whl"
473+
pattern: "nautilus_trader-*.whl"
469474
merge-multiple: true
470475

476+
- name: Validate wheel count
477+
run: bash ./scripts/ci/validate-wheel-count.sh "$EXPECTED_WHEEL_COUNT"
478+
471479
# https://github.com/actions/attest-build-provenance
472480
- name: Attest wheel provenance
473481
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
@@ -506,6 +514,7 @@ jobs:
506514
CLOUDFLARE_R2_URL: ${{ secrets.CLOUDFLARE_R2_URL }}
507515
CLOUDFLARE_R2_REGION: "auto"
508516
CLOUDFLARE_R2_BUCKET_NAME: "packages"
517+
EXPECTED_WHEEL_COUNT: 12 # 3 Python versions × 4 platforms
509518
steps:
510519
# https://github.com/step-security/harden-runner
511520
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -538,9 +547,12 @@ jobs:
538547
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
539548
with:
540549
path: dist
541-
pattern: "*.whl"
550+
pattern: "nautilus_trader-*.whl"
542551
merge-multiple: true
543552

553+
- name: Validate wheel count
554+
run: bash ./scripts/ci/validate-wheel-count.sh "$EXPECTED_WHEEL_COUNT"
555+
544556
# https://github.com/actions/attest-build-provenance
545557
- name: Attest wheel provenance
546558
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0

scripts/ci/validate-wheel-count.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Validate wheel count matches expected count
5+
# Usage: validate-wheel-count.sh <expected_count>
6+
7+
if [ $# -ne 1 ]; then
8+
echo "Usage: $0 <expected_count>" >&2
9+
exit 1
10+
fi
11+
12+
expected_count=$1
13+
14+
if ! [[ "$expected_count" =~ ^[0-9]+$ ]]; then
15+
echo "ERROR: expected_count must be a positive integer, got: $expected_count" >&2
16+
exit 1
17+
fi
18+
19+
echo "Validating wheel count in dist/ directory..."
20+
21+
wheel_count=$(find dist/ -name "*.whl" -type f | wc -l)
22+
23+
if [ "$wheel_count" -ne "$expected_count" ]; then
24+
echo "ERROR: Expected $expected_count wheels, found $wheel_count" >&2
25+
echo "Downloaded wheels:" >&2
26+
find dist/ -name "*.whl" -type f -ls >&2
27+
exit 1
28+
fi
29+
30+
echo "✓ Validated: Found all $expected_count wheels"

0 commit comments

Comments
 (0)