Skip to content

Commit af12ce3

Browse files
committed
ci: serialize hosted macOS Swift tests
1 parent 156d2e6 commit af12ce3

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2984,6 +2984,7 @@ jobs:
29842984
timeout-minutes: ${{ (github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && 30 || 20 }}
29852985
env:
29862986
HISTORICAL_TARGET: ${{ needs.preflight.outputs.compatibility_target }}
2987+
SWIFT_TEST_EXECUTION: ${{ (github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && 'serial' || 'parallel' }}
29872988
steps:
29882989
- *platform_checkout_step
29892990

@@ -3173,8 +3174,14 @@ jobs:
31733174
- name: Swift test
31743175
run: |
31753176
set -euo pipefail
3177+
swift_test_args=(--package-path apps/macos --enable-code-coverage)
3178+
# Hosted release and retry runs have shown test-process contention;
3179+
# keep the faster first-attempt Blacksmith path parallel.
3180+
if [[ "$SWIFT_TEST_EXECUTION" == "parallel" ]]; then
3181+
swift_test_args+=(--parallel)
3182+
fi
31763183
for attempt in 1 2 3; do
3177-
if swift test --package-path apps/macos --parallel --enable-code-coverage; then
3184+
if swift test "${swift_test_args[@]}"; then
31783185
exit 0
31793186
fi
31803187
echo "swift test failed (attempt $attempt/3). Retrying…"

‎test/scripts/ci-workflow-guards.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,6 +3582,26 @@ describe("ci workflow guards", () => {
35823582
);
35833583
});
35843584

3585+
it("serializes macOS Swift tests only on hosted dispatches and retries", () => {
3586+
const workflow = readCiWorkflow();
3587+
const macosSwift = workflow.jobs["macos-swift"];
3588+
const testStep = macosSwift.steps.find((step: WorkflowStep) => step.name === "Swift test");
3589+
3590+
expect(macosSwift.env.SWIFT_TEST_EXECUTION).toBe(
3591+
"${{ (github.event_name == 'workflow_dispatch' || github.run_attempt > 1) && 'serial' || 'parallel' }}",
3592+
);
3593+
expect(testStep.run).toContain(
3594+
"swift_test_args=(--package-path apps/macos --enable-code-coverage)",
3595+
);
3596+
expect(testStep.run).toContain('if [[ "$SWIFT_TEST_EXECUTION" == "parallel" ]]');
3597+
expect(testStep.run).toContain("swift_test_args+=(--parallel)");
3598+
expect(testStep.run).toContain('swift test "${swift_test_args[@]}"');
3599+
expect(testStep.run).not.toContain(
3600+
"swift test --package-path apps/macos --parallel --enable-code-coverage",
3601+
);
3602+
expect(testStep.run).toContain("for attempt in 1 2 3");
3603+
});
3604+
35853605
it("bounds the Windows Crabbox hydrate main fetch", () => {
35863606
const workflow = readFileSync(".github/workflows/crabbox-hydrate.yml", "utf8");
35873607

0 commit comments

Comments
 (0)