Skip to content

Commit 9a8a3ce

Browse files
tmmampagent
andauthored
chore(zero-swift): run Swift CI steps in parallel jobs (#56)
Swift (macOS) ran macOS tests, docs, API breaks, and iOS Simulator tests in a row (13-14 min), and every Swift PR waited on it. They're now three jobs. Swift (Linux) is split the same way (tests, API breaks, zbugs), and the zero-swift CLI checks no longer hold up the vectors it waits on. The API-break check caches the baseline release's API dumps per tag, which saves building the release on every run. Amp-Thread-ID: https://ampcode.com/threads/T-c513a037-a257-45e0-b9a9-15c15edfe859 Co-authored-by: Amp <amp@ampcode.com>
1 parent b478b81 commit 9a8a3ce

3 files changed

Lines changed: 126 additions & 22 deletions

File tree

‎.github/workflows/swift-macos.yml‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,49 @@ jobs:
4444
run: swift test
4545
- name: Docs
4646
run: scripts/docs.sh
47-
# The Apple-only API, which Linux doesn't build.
47+
48+
# The Apple-only API, which Linux doesn't build. See swift.yml.
49+
api-breaks:
50+
name: Swift API breaks (macOS)
51+
runs-on: macos-26
52+
timeout-minutes: 45
53+
defaults:
54+
run:
55+
working-directory: swift
56+
steps:
57+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
58+
with:
59+
persist-credentials: false
60+
- name: Find the baseline
61+
id: baseline
62+
run: |
63+
tag=$(git ls-remote --tags --refs https://github.com/wevm/zero-swift.git |
64+
sed 's|.*refs/tags/||' | sort -V | tail -1)
65+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
66+
echo "swift=$(swift --version 2>&1 | cksum | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
67+
# The baseline's API dumps, which only change with a release or Xcode.
68+
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
69+
with:
70+
path: api-baseline
71+
key: swift-api-baseline-macos-${{ steps.baseline.outputs.swift }}-${{ steps.baseline.outputs.tag }}
4872
- name: API breaks
49-
run: scripts/api-breaks.sh
73+
env:
74+
BASELINE: ${{ steps.baseline.outputs.tag }}
75+
run: |
76+
API_BREAKS_BASELINE_DIR="$GITHUB_WORKSPACE/api-baseline" \
77+
scripts/api-breaks.sh "$BASELINE"
78+
79+
ios:
80+
name: Swift (iOS Simulator)
81+
runs-on: macos-26
82+
timeout-minutes: 45
83+
defaults:
84+
run:
85+
working-directory: swift
86+
steps:
87+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
88+
with:
89+
persist-credentials: false
5090
- name: Test (iOS Simulator)
5191
run: |
5292
device="$(xcrun simctl list devices available -j |

‎.github/workflows/swift.yml‎

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ jobs:
4141
# writes the seeded fuzz corpora (generated/), which aren't checked in.
4242
- name: Check vectors are current
4343
run: pnpm --filter zero-conformance run test
44+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
45+
with:
46+
name: generated-vectors
47+
path: packages/zero-conformance/generated/
48+
if-no-files-found: error
49+
50+
# Separate from the vectors job, which Swift (Linux) waits on.
51+
cli:
52+
name: zero-swift CLI
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
56+
with:
57+
persist-credentials: false
58+
- uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
59+
with:
60+
version: 11.11.0
61+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
62+
with:
63+
node-version-file: .nvmrc
64+
package-manager-cache: false
65+
- run: pnpm install --frozen-lockfile
4466
# The Swift tests compile the Swift that zero-swift generates, and check
4567
# the Swift ports of apps against the drift vectors it records.
4668
- name: Check generated Swift and drift vectors are current
@@ -50,11 +72,6 @@ jobs:
5072
# The published CLI is a bundle; this keeps it bundling.
5173
- name: Build the zero-swift CLI
5274
run: pnpm --filter zero-swift run build
53-
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
54-
with:
55-
name: generated-vectors
56-
path: packages/zero-conformance/generated/
57-
if-no-files-found: error
5875

5976
linux:
6077
name: Swift (Linux)
@@ -84,21 +101,63 @@ jobs:
84101
# Apple-only; swift-macos.yml checks it.
85102
- name: Docs
86103
run: scripts/docs.sh Zero ZeroTesting
87-
# Fails on a public API break since the last release that no changeset
88-
# declares. The checkout belongs to another user in the container.
104+
105+
# Fails on a public API break since the last release that no changeset
106+
# declares.
107+
api-breaks:
108+
name: Swift API breaks (Linux)
109+
runs-on: ubuntu-latest
110+
container: swift:6.2.4-bookworm
111+
defaults:
112+
run:
113+
working-directory: swift
114+
steps:
115+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
116+
with:
117+
persist-credentials: false
118+
- name: Install system libraries
119+
run: apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev jq
120+
- name: Find the baseline
121+
id: baseline
122+
run: |
123+
tag=$(git ls-remote --tags --refs https://github.com/wevm/zero-swift.git |
124+
sed 's|.*refs/tags/||' | sort -V | tail -1)
125+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
126+
# The baseline's API dumps, which only change with a release.
127+
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
128+
with:
129+
path: api-baseline
130+
key: swift-api-baseline-linux-6.2.4-${{ steps.baseline.outputs.tag }}
131+
# The checkout belongs to another user in the container.
89132
- name: API breaks
133+
env:
134+
BASELINE: ${{ steps.baseline.outputs.tag }}
90135
run: |
91136
git config --global --add safe.directory "$GITHUB_WORKSPACE"
92-
scripts/api-breaks.sh
93-
# zbugs' Swift port, checked against zbugs' TS queries and mutators on
94-
# the samples in drift-samples.ts (the vectors job checks the record is
95-
# current).
96-
- name: zbugs
137+
API_BREAKS_BASELINE_DIR="$GITHUB_WORKSPACE/api-baseline" \
138+
scripts/api-breaks.sh "$BASELINE"
139+
140+
# zbugs' Swift port, checked against zbugs' TS queries and mutators on the
141+
# samples in drift-samples.ts (the cli job checks the record is current).
142+
zbugs:
143+
name: zbugs (Linux)
144+
runs-on: ubuntu-latest
145+
container: swift:6.2.4-bookworm
146+
defaults:
147+
run:
97148
working-directory: apps/zbugs-swift
98-
run: |
99-
swift format lint --strict --recursive Sources Tests Package.swift
100-
swift build --build-tests
101-
swift test --skip-build
149+
steps:
150+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
151+
with:
152+
persist-credentials: false
153+
- name: Install system libraries
154+
run: apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev
155+
- name: Format
156+
run: swift format lint --strict --recursive Sources Tests Package.swift
157+
- name: Build
158+
run: swift build --build-tests
159+
- name: Test
160+
run: swift test --skip-build
102161

103162
e2e:
104163
name: Swift end-to-end (Linux)

‎swift/scripts/api-breaks.sh‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#
66
# scripts/api-breaks.sh [<baseline tag>] default: the mirror's newest tag
77
#
8+
# With API_BREAKS_BASELINE_DIR set, the baseline's API dumps are kept there and
9+
# reused, which saves building the baseline (CI caches it per tag).
10+
#
811
# The digester (`swift package diagnose-api-breaking-changes`) needs the
912
# package at the root of a git repository, so this runs it in a scratch
1013
# repository shaped like the SwiftPM mirror (wevm/zero-swift): the released tag,
@@ -45,15 +48,17 @@ cd "$work"
4548
# them. Stripping `package` declarations from both sides matters: one that
4649
# was public and became `package` reads as removed.
4750
for side in old:$baseline new:HEAD; do
48-
name=${side%%:*} rev=${side#*:}
51+
name=${side%%:*} rev=${side#*:} dir=$dumps/${side%%:*}
52+
# SwiftPM skips dumping a revision whose dumps are already in the directory.
53+
[ "$name" = old ] && dir=${API_BREAKS_BASELINE_DIR:-$dir}
4954
swift package diagnose-api-breaking-changes "$rev" --products $products \
50-
--baseline-dir "$dumps/$name" >"$dumps/$name.log" 2>&1 || true
51-
if ! ls "$dumps/$name"/*/*.json >/dev/null 2>&1; then
55+
--baseline-dir "$dir" >"$dumps/$name.log" 2>&1 || true
56+
if ! ls "$dir"/*/*.json >/dev/null 2>&1; then
5257
echo "Couldn't dump the API at $rev:" >&2
5358
cat "$dumps/$name.log" >&2
5459
exit 1
5560
fi
56-
for dump in "$dumps/$name"/*/*.json; do
61+
for dump in "$dir"/*/*.json; do
5762
jq 'walk(if type == "object" and has("children")
5863
then .children |= map(select(.isInternal != true)) else . end)' \
5964
"$dump" >"$dumps/$name-$(basename "$dump")"

0 commit comments

Comments
 (0)