Skip to content

Commit 8a22f81

Browse files
authored
Refine workflows (#12)
* Refine workflows * Refine again * Find simulator differently * Temp disable other checks * Ensure we found a simulator * Format * Re-enable * Naming * Cancel a currently running workflow from the same PR, branch or tag * Job naming * Refine swift version * Run tests only if there is a test target on Linux * Install jq * Quiet * Let tests run * Disable concurrency constraints * Conditional run tests on apple platforms * Only install not update * Fix * Try caching APIT * Try again * Again * Dont APT cache * Re-enable all * Try wasm tests * Wasm debug * Verbose only debug * Verify SDK * Fix configur * Fix SDK root * Fix standard lib * Re-introduce --static-swift-stdlib * --experimental-swift-sdk * Experimental SDK * Use right test target * Use --experimental-swift-sdk for all build operations * Fix WASM tests * Re-enable all tests * Conditional run WASM tests * Conditional run windows tests * Enable testing for WASM in release mode * Remove Run step * Generalize
1 parent 8e552b5 commit 8a22f81

File tree

8 files changed

+225
-149
lines changed

8 files changed

+225
-149
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Check Workflows
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
schedule:
8+
# ┌───────────── minute (0 - 59)
9+
# │ ┌───────────── hour (0 - 23)
10+
# │ │ ┌───────────── day of the month (1 - 31)
11+
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
12+
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
13+
# * * * * *
14+
- cron: "0 0 * * *"
15+
16+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
17+
# concurrency: # cancel a currently running workflow from the same PR, branch or tag
18+
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
# cancel-in-progress: true
20+
21+
jobs:
22+
check-validate:
23+
name: Validate
24+
uses: ./.github/workflows/validate.yml
25+
26+
check-linux:
27+
name: Linux
28+
uses: ./.github/workflows/spm-linux.yml
29+
30+
check-macos:
31+
name: macOS
32+
uses: ./.github/workflows/spm-macos.yml
33+
34+
check-windows:
35+
name: Windows
36+
uses: ./.github/workflows/spm-windows.yml
37+
38+
check-wasm:
39+
name: Wasm
40+
uses: ./.github/workflows/spm-wasm.yml
41+
with:
42+
test_target_name: shared-actionsPackageTests
43+
44+
check-ios:
45+
name: iOS
46+
uses: ./.github/workflows/xcodebuild.yml
47+
with:
48+
target_platform: iOS
49+
scheme: shared-actions-Package
50+
51+
check-tvOS:
52+
name: tvOS
53+
uses: ./.github/workflows/xcodebuild.yml
54+
with:
55+
target_platform: tvOS
56+
scheme: shared-actions-Package

.github/workflows/_selftest.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/ci-iOS.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/ci-linux.yml renamed to .github/workflows/spm-linux.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@ name: Linux
22

33
on:
44
workflow_call:
5-
inputs:
6-
swift_build_dir:
7-
type: string
8-
description: "Specify a custom build directory path (default .build)"
9-
default: ".build"
10-
spm_cache_dir:
11-
type: string
12-
description: "Specify a custom SPM cache directory path (default ~/Library/Caches/org.swift.swiftpm)"
13-
default: "~/Library/Caches/org.swift.swiftpm"
5+
6+
env:
7+
RUN_TESTS: true
148

159
jobs:
16-
Linux-SPM:
17-
name: SPM Linux
10+
SPM-Linux:
11+
name: Linux Swift ${{ matrix.swift_version }} [${{ matrix.build_config }}]
1812
timeout-minutes: 30
1913
runs-on: ubuntu-latest
2014
strategy:
21-
fail-fast: false
15+
fail-fast: true
2216
matrix:
2317
swift_version: # https://hub.docker.com/_/swift/tags
24-
- "latest"
18+
- "6.0.3"
2519
- "5.10.1"
2620
build_config:
2721
- debug
@@ -44,18 +38,26 @@ jobs:
4438
restore-keys: |
4539
${{ runner.os }}-spm-
4640
41+
- name: Prepare
42+
run: |
43+
if [ ! -x "$(command -v jq)" ]; then
44+
apt update -qy
45+
apt install jq -qy
46+
fi
47+
TARGET_TYPES=$(swift package describe --type json | jq '.targets[].type')
48+
HAS_TESTS=$(echo $TARGET_TYPES | grep -q "test" && echo true || echo false)
49+
echo "Package has tests: $HAS_TESTS"
50+
echo "RUN_TESTS=$HAS_TESTS" >> $GITHUB_ENV
51+
4752
- name: Build
4853
run: |
4954
swift build -c ${{ matrix.build_config }}
5055
5156
- name: Test
57+
if: env.RUN_TESTS == 'true'
5258
run: |
5359
swift test -c ${{ matrix.build_config }}
5460
55-
- name: Run
56-
run: |
57-
swift run -c ${{ matrix.build_config }} shared-actions
58-
5961
- name: Upload failure artifacts
6062
if: failure()
6163
uses: actions/upload-artifact@v4

.github/workflows/ci-macos.yml renamed to .github/workflows/spm-macos.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
name: macOS
1+
name: SPM macOS
22

33
on:
44
workflow_call:
55

6+
env:
7+
RUN_TESTS: true
8+
69
jobs:
7-
macos-SPM:
8-
name: SPM macOS
10+
SPM-macOS:
11+
name: macOS Xcode ${{ matrix.config.xcode }} [${{ matrix.build_config }}]
912
timeout-minutes: 30
1013
runs-on: ${{ matrix.config.os }}
1114
strategy:
@@ -37,18 +40,22 @@ jobs:
3740
- name: Select Xcode ${{ matrix.config.xcode }}
3841
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.config.xcode }}.app
3942

43+
- name: Prepare
44+
run: |
45+
TARGET_TYPES=$(swift package describe --type json | jq '.targets[].type')
46+
HAS_TESTS=$(echo $TARGET_TYPES | grep -q "test" && echo true || echo false)
47+
echo "Package has tests: $HAS_TESTS"
48+
echo "RUN_TESTS=$HAS_TESTS" >> $GITHUB_ENV
49+
4050
- name: Build
4151
run: |
4252
swift build -c ${{ matrix.build_config }}
4353
4454
- name: Test
55+
if: env.RUN_TESTS == 'true'
4556
run: |
4657
swift test -c ${{ matrix.build_config }}
4758
48-
- name: Run
49-
run: |
50-
swift run -c ${{ matrix.build_config }} shared-actions
51-
5259
- name: Upload failure artifacts
5360
if: failure()
5461
uses: actions/upload-artifact@v4

.github/workflows/ci-wasm.yml renamed to .github/workflows/spm-wasm.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
name: WASM
1+
name: SPM Wasm
22

33
on:
44
workflow_call:
5+
inputs:
6+
test_target_name:
7+
description: "Test target name"
8+
required: true
9+
type: string
10+
11+
env:
12+
RUN_TESTS: true
513

614
jobs:
7-
WASM-SPM:
8-
name: SPM Wasm
15+
SPM-Wasm:
16+
name: Wasm Swift ${{ matrix.swift_version }} [${{ matrix.build_config }}]
917
timeout-minutes: 30
1018
runs-on: ubuntu-latest
1119
strategy:
12-
fail-fast: false
20+
fail-fast: true
1321
matrix:
1422
swift_version: # https://github.com/swiftwasm/swift-sdk-index/tree/main/v1/builds
15-
- "6.0.3-RELEASE"
23+
- "6.0.3"
1624
build_config:
1725
- debug
1826
- release
@@ -24,7 +32,7 @@ jobs:
2432
id: setup-swiftwasm
2533
uses: swiftwasm/setup-swiftwasm@v2
2634
with:
27-
tag: "swift-${{ matrix.swift_version }}"
35+
tag: "swift-${{ matrix.swift_version }}-RELEASE"
2836
target: "wasm32-unknown-wasi"
2937

3038
- name: Setup wasmtime
@@ -49,19 +57,26 @@ jobs:
4957
restore-keys: |
5058
${{ runner.os }}-spm-
5159
60+
- name: Prepare
61+
run: |
62+
if [ ! -x "$(command -v jq)" ]; then
63+
apt update -qy
64+
apt install jq -qy
65+
fi
66+
TARGET_TYPES=$(swift package describe --type json | jq '.targets[].type')
67+
HAS_TESTS=$(echo $TARGET_TYPES | grep -q "test" && echo true || echo false)
68+
echo "Package has tests: $HAS_TESTS"
69+
echo "RUN_TESTS=$HAS_TESTS" >> $GITHUB_ENV
70+
5271
- name: Build
5372
run: |
5473
swift build -c ${{ matrix.build_config }} --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib
5574
56-
# - name: Test
57-
# run: |
58-
# swift build -c ${{ matrix.build_config }} --vv --build-tests --triple wasm32-unknown-wasi --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib
59-
# wasmtime .build/${{ matrix.build_config }}/SharedActionsTests.wasm
60-
61-
- name: Run
75+
- name: Test
76+
if: env.RUN_TESTS == 'true'
6277
run: |
63-
swift build -c ${{ matrix.build_config }} --swift-sdk "${{ steps.setup-swiftwasm.outputs.swift-sdk-id }}" --static-swift-stdlib --product shared-actions
64-
wasmtime .build/${{ matrix.build_config }}/shared-actions.wasm
78+
swift build -c ${{ matrix.build_config }} --build-tests -Xswiftc -enable-testing --experimental-swift-sdk ${{ steps.setup-swiftwasm.outputs.swift-sdk-id }} --static-swift-stdlib
79+
wasmtime --dir . .build/${{ matrix.build_config }}/${{ inputs.test_target_name }}.wasm
6580
6681
- name: Upload failure artifacts
6782
if: failure()

0 commit comments

Comments
 (0)