Skip to content

Commit 7db54d2

Browse files
authored
Update for Swift 6.3, with some heavy cleanup
1 parent 91bcaa2 commit 7db54d2

1 file changed

Lines changed: 37 additions & 103 deletions

File tree

.github/workflows/run-unit-tests.yml

Lines changed: 37 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ on:
1212
required: false
1313
default: ''
1414
description: "Apply a --filter to the tests that will be run."
15-
with_testing:
16-
type: boolean
17-
required: false
18-
default: true
19-
description: "Set to 'true' to enable compilation for testing and @testable imports. Defaults to 'true'."
2015
with_release_mode_testing:
2116
type: boolean
2217
required: false
@@ -104,7 +99,6 @@ permissions:
10499
contents: read
105100
env:
106101
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
107-
WITH_TESTING: ${{ inputs.with_testing && '-Xswiftc -enable-testing' || '' }}
108102
PACKAGE_ROOT: ${{ inputs.package_root != '' && format('--package-path={0}', inputs.package_root) || '' }}
109103
BASELINES: ${{ inputs.package_root || '.' }}/.api-breakage
110104
EXTRA_FLAGS: ${{ inputs.extra_flags || '--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable' }}
@@ -151,69 +145,59 @@ jobs:
151145
path: ${{ env.BASELINES }}
152146
key: api-breakage-${{ github.sha }}
153147

148+
determine-linux-matrix:
149+
if: ${{ !(github.event.pull_request.draft || false) }}
150+
runs-on: ubuntu-latest
151+
outputs:
152+
matrix: ${{ steps.gen-matrix.outputs.matrix }}
153+
env:
154+
RELEASE_TESTING: ${{ inputs.with_release_mode_testing && '1' || '0' }}
155+
steps:
156+
- id: gen-matrix
157+
shell: bash
158+
run: |
159+
echo "matrix=$(jq -nc --arg with_release "${RELEASE_TESTING}" '{ "swift-config": [
160+
{ "image": "swift:6.1-noble", "build-mode": "debug" },
161+
{ "image": "swift:6.2-noble", "build-mode": "debug" },
162+
{ "image": "swift:6.3-noble", "build-mode": "debug" },
163+
{ "image": "swiftlang/swift:nightly-main-noble", "build-mode": "debug" }
164+
] | if $with_release == "1" then . + [
165+
{ "image": "swift:6.3-noble", "build-mode": "release" }
166+
] else . end }')" >> "${GITHUB_OUTPUT}"
167+
154168
linux-unit:
155169
if: ${{ !(github.event.pull_request.draft || false) }}
170+
needs: determine-linux-matrix
156171
strategy:
157172
fail-fast: false
158-
matrix:
159-
swift-config:
160-
- { image: "swift:6.0-noble", "build-mode": "debug" }
161-
- { image: "swift:6.1-noble", "build-mode": "debug" }
162-
- { image: "swift:6.2-noble", "build-mode": "debug" }
163-
- { image: "swift:6.2-noble", "build-mode": "release" }
164-
- { image: "swiftlang/swift:nightly-6.3-noble", "build-mode": "debug" }
165-
- { image: "swiftlang/swift:nightly-6.3-noble", "build-mode": "release" }
173+
matrix: ${{ fromJSON(needs.determine-linux-matrix.outputs.matrix) }}
166174
runs-on: ubuntu-latest
167175
container: ${{ matrix.swift-config.image }}
168176
timeout-minutes: 60
169177
steps:
170178
- name: Install curl and zstd
171179
run: apt-get update -yq && apt-get install -y curl zstd
172180
- name: Check out code
173-
if: ${{ matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing }}
174181
uses: actions/checkout@v6
175-
- name: Check Swift compatibility
176-
id: swift-check
177-
if: ${{ matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing }}
178-
uses: vapor/ci/.github/actions/check-compatible-swift@main
179-
with:
180-
package_root: ${{ inputs.package_root }}
181-
- name: Strip flags incompatible with 6.0
182-
if: ${{ matrix.swift-config.image == 'swift:6.0-noble' && steps.swift-check.outputs.swift-compatible == 'true' && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
183-
shell: bash
184-
run: |
185-
echo "EXTRA_FLAGS=$(echo "${EXTRA_FLAGS}" | sed -Ee "s/--(dis|en)able-experimental-prebuilts//g")" >>"${GITHUB_ENV}"
186-
echo "ENABLE_ALL_TRAITS=" >>"${GITHUB_ENV}"
187-
- name: Restore .build
188-
# If cache-restore is causing the CI to fail, use 'Enable debug logging' on a re-run to disable the step.
189-
if: ${{ runner.debug != '1' && steps.swift-check.outputs.swift-compatible == 'true' && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
190-
id: "restore-cache"
191-
uses: actions/cache/restore@v5
182+
- name: Cache .build
183+
uses: actions/cache@v5
192184
with:
193-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
185+
path: "${{ inputs.package_root || '.' }}/.build"
194186
key: "${{ matrix.swift-config.image }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
195187
restore-keys: "${{ matrix.swift-config.image }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-"
196188
- name: Run unit tests
197-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
198189
run: |
199190
swift test \
200191
-c ${{ matrix.swift-config.build-mode }} \
201-
${WITH_TESTING} \
202192
${PACKAGE_ROOT} \
203193
${WITH_TSAN} \
204194
${WARNINGS_AS_ERRORS} \
205195
${WITH_COVERAGE} \
206196
${TEST_FILTER} \
207197
${ENABLE_ALL_TRAITS} \
208198
${EXTRA_FLAGS}
209-
- name: Cache .build
210-
if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && steps.swift-check.outputs.swift-compatible == 'true' && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
211-
uses: actions/cache/save@v5
212-
with:
213-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
214-
key: "${{ matrix.swift-config.image }}-${{ matrix.swift-config.build-mode }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
215199
- name: Upload coverage data
216-
if: ${{ inputs.with_coverage && (steps.swift-check.outputs.swift-compatible == 'true') && (matrix.swift-config.build-mode == 'debug' || inputs.with_release_mode_testing) }}
200+
if: inputs.with_coverage
217201
uses: vapor/swift-codecov-action@v0.3
218202
with:
219203
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
@@ -239,22 +223,13 @@ jobs:
239223
xcode-version: ${{ matrix.xcode-version }}
240224
- name: Check out code
241225
uses: actions/checkout@v6
242-
- name: Check Swift compatibility
243-
id: swift-check
244-
uses: vapor/ci/.github/actions/check-compatible-swift@main
245-
with:
246-
package_root: ${{ inputs.package_root }}
247-
- name: Restore .build
248-
# If cache-restore is causing the CI to fail, use 'Enable debug logging' on a re-run to disable the step.
249-
if: ${{ runner.debug != '1' && steps.swift-check.outputs.swift-compatible == 'true' }}
250-
id: restore-cache
251-
uses: actions/cache/restore@v5
226+
- name: Cache .build
227+
uses: actions/cache@v5
252228
with:
253-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
229+
path: "${{ inputs.package_root || '.' }}/.build"
254230
key: "${{ matrix.xcode-version }}-${{ matrix.macos-version }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
255231
restore-keys: "${{ matrix.xcode-version }}-${{ matrix.macos-version }}-build-${{ runner.os }}-"
256232
- name: Run unit tests
257-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
258233
run: |
259234
swift test \
260235
${PACKAGE_ROOT} \
@@ -263,14 +238,8 @@ jobs:
263238
${TEST_FILTER} \
264239
${ENABLE_ALL_TRAITS} \
265240
${EXTRA_FLAGS}
266-
- name: Cache .build
267-
if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && steps.swift-check.outputs.swift-compatible == 'true' }}
268-
uses: actions/cache/save@v5
269-
with:
270-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
271-
key: "${{ matrix.xcode-version }}-${{ matrix.macos-version }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
272241
- name: Upload coverage data
273-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' && inputs.with_coverage }}
242+
if: inputs.with_coverage
274243
uses: vapor/swift-codecov-action@v0.3
275244
with:
276245
codecov_token: ${{ secrets.CODECOV_TOKEN || '' }}
@@ -283,13 +252,13 @@ jobs:
283252
fail-fast: false
284253
matrix:
285254
swift-version:
286-
- 6.0
287255
- 6.1
288256
- 6.2
257+
- 6.3
289258
include:
290-
- { swift-version: 6.0, swift-branch: swift-6.0.3-release, swift-tag: 6.0.3-RELEASE }
291259
- { swift-version: 6.1, swift-branch: swift-6.1.3-release, swift-tag: 6.1.3-RELEASE }
292-
- { swift-version: 6.2, swift-branch: swift-6.2.3-release, swift-tag: 6.2.3-RELEASE }
260+
- { swift-version: 6.2, swift-branch: swift-6.2.4-release, swift-tag: 6.2.4-RELEASE }
261+
- { swift-version: 6.3, swift-branch: swift-6.3-release, swift-tag: 6.3-RELEASE }
293262
runs-on: windows-latest
294263
timeout-minutes: 60
295264
steps:
@@ -301,34 +270,19 @@ jobs:
301270
update-sdk-modules: true
302271
- name: Check out code
303272
uses: actions/checkout@v6
304-
- name: Check Swift compatibility
305-
id: swift-check
306-
uses: vapor/ci/.github/actions/check-compatible-swift@main
307-
with:
308-
package_root: ${{ inputs.package_root }}
309-
- name: Restore .build
310-
# If cache-restore is causing the CI to fail, use 'Enable debug logging' on a re-run to disable the step.
311-
if: ${{ runner.debug != '1' && steps.swift-check.outputs.swift-compatible == 'true' }}
312-
id: "restore-cache"
313-
uses: actions/cache/restore@v5
273+
- name: Cache .build
274+
uses: actions/cache@v5
314275
with:
315-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
276+
path: "${{ inputs.package_root || '.' }}/.build"
316277
key: "${{ matrix.swift-tag }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
317278
restore-keys: "${{ matrix.swift-tag }}-build-${{ runner.os }}-"
318279
- name: Run unit tests
319-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
320280
run: |
321281
$params = @();
322282
$params += ($env:WARNINGS_AS_ERRORS -split ' ');
323283
$params += ($env:ENABLE_ALL_TRAITS -split ' ');
324284
$params += ($env:EXTRA_FLAGS -split ' ')
325285
swift test $env:PACKAGE_ROOT $env:TEST_FILTER @params
326-
- name: Cache .build
327-
if: ${{ steps.restore-cache.outputs.cache-hit != 'true' && steps.swift-check.outputs.swift-compatible == 'true' }}
328-
uses: actions/cache/save@v5
329-
with:
330-
path: "${{ inputs.package_root != '' && format('{0}/.build', inputs.package_root) || '.build' }}"
331-
key: "${{ matrix.swift-tag }}-build-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.event.after }}"
332286
333287
ios-unit:
334288
if: ${{ !(github.event.pull_request.draft || false) && inputs.ios_scheme_name != '' }}
@@ -387,13 +341,7 @@ jobs:
387341
version="$(echo "$sdk_info" | cut -f1)"
388342
checksum="$(echo "$sdk_info" | cut -f2)"
389343
swift sdk install "https://download.swift.org/$(echo $tag | tr [A-Z] [a-z])/static-sdk/$tag/${tag}_static-linux-${version}.artifactbundle.tar.gz" --checksum "$checksum"
390-
- name: Check Swift compatibility
391-
id: swift-check
392-
uses: vapor/ci/.github/actions/check-compatible-swift@main
393-
with:
394-
package_root: ${{ inputs.package_root }}
395344
- name: Build
396-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
397345
run: swift build --swift-sdk x86_64-swift-linux-musl ${PACKAGE_PATH} ${EXTRA_FLAGS} ${EXTRA_MUSL_FLAGS} ${WARNINGS_AS_ERRORS} ${ENABLE_ALL_TRAITS}
398346

399347
wasm:
@@ -414,42 +362,28 @@ jobs:
414362
checksum="$(curl -s https://www.swift.org/api/v1/install/releases.json | \
415363
jq -r --arg tag "$tag" '.[] | select(.tag == $tag).platforms[] | select(.platform == "wasm-sdk").checksum // empty')"
416364
swift sdk install https://download.swift.org/$(echo $tag | tr [A-Z] [a-z])/wasm-sdk/$tag/"$tag"_wasm.artifactbundle.tar.gz --checksum $checksum
417-
- name: Check Swift compatibility
418-
id: swift-check
419-
uses: vapor/ci/.github/actions/check-compatible-swift@main
420-
with:
421-
package_root: ${{ inputs.package_root }}
422365
- name: Build
423-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
424366
run: |
425367
tag="$(swiftc --version | grep -Po '(?<=\().+(?=\))')"
426368
swift build --swift-sdk "$tag"_wasm ${PACKAGE_PATH} ${EXTRA_FLAGS} ${WARNINGS_AS_ERRORS} ${ENABLE_ALL_TRAITS}
427369
428370
android-unit:
429371
if: ${{ !(github.event.pull_request.draft || false) && inputs.with_android }}
430-
env:
431-
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
432372
strategy:
433373
fail-fast: false
434374
matrix:
435375
swift-version:
436376
- 6.1
437377
- 6.2
378+
- 6.3
438379
runs-on: ubuntu-latest
439380
timeout-minutes: 60
440381
steps:
441382
- name: Ensure zstd is available
442383
run: sudo apt-get update -yq && sudo apt-get install -yq zstd
443384
- name: Check out code
444385
uses: actions/checkout@v6
445-
- name: Check Swift compatibility
446-
id: swift-check
447-
uses: vapor/ci/.github/actions/check-compatible-swift@main
448-
with:
449-
package_root: ${{ inputs.package_root }}
450-
assume-installed-version: ${{ matrix.swift-version }}
451386
- name: Run unit tests
452-
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
453387
uses: skiptools/swift-android-action@v2
454388
with:
455389
swift-version: ${{ matrix.swift-version }}

0 commit comments

Comments
 (0)