-
Notifications
You must be signed in to change notification settings - Fork 41
165 lines (140 loc) · 4.44 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# This workflow runs CI tests for the main package and Examples package
name: CI
# Trigger the workflow on push to main, any pull request, or manual dispatch
on:
push:
branches:
- main
pull_request:
branches:
- '*'
workflow_dispatch:
# Ensure only one workflow per ref is running at a time
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
macos:
name: macOS - ${{ matrix.package }} (Xcode ${{ matrix.xcode }})
runs-on: macos-14
strategy:
matrix:
xcode:
- '16.1'
- '16.0'
- '15.4'
package:
- 'main'
- 'Examples'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Select Xcode ${{ matrix.xcode }}
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Print Swift version
run: swift --version
# Set working directory to Examples if testing the examples package
- name: Set working directory
run: |
if [ "${{ matrix.package }}" = "Examples" ]; then
cd Examples
fi
- name: Build package
run: swift build
- name: Run tests
run: swift test
linux:
name: Ubuntu - ${{ matrix.package }} (Swift ${{ matrix.swift }})
runs-on: ubuntu-latest
strategy:
matrix:
swift:
- '6.0'
- '5.10'
- '5.9'
package:
- 'main'
- 'Examples'
container: swift:${{ matrix.swift }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Set working directory to Examples if testing the examples package
- name: Set working directory
run: |
if [ "${{ matrix.package }}" = "Examples" ]; then
cd Examples
fi
- name: Build package
run: swift build
- name: Run tests
run: swift test
windows:
name: Windows - ${{ matrix.package }} (Swift ${{ matrix.swift }})
runs-on: windows-latest
strategy:
matrix:
swift:
- '6.0'
- '5.10'
- '5.9.1' # Macros has been added to Swift on Windows in 5.9.1 version
package:
- 'main'
- 'Examples'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Swift
uses: compnerd/gha-setup-swift@main
with:
branch: swift-${{ matrix.swift }}-release
tag: ${{ matrix.swift }}-RELEASE
# Set working directory to Examples if testing the examples package
- name: Set working directory
run: |
if ("${{ matrix.package }}" -eq "Examples") {
cd Examples
}
- name: Build package
run: swift build
# Looks like tests don't work on Windows
# - name: Run tests
# run: swift test
code-coverage:
name: Gather Code Coverage
needs: macos
runs-on: macos-14
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Select latest Xcode
run: sudo xcode-select -s /Applications/Xcode_15.4.app
- name: Build and test with coverage
run: swift test -Xswiftc -Xfrontend -Xswiftc -dump-macro-expansions --enable-code-coverage
- name: Gather code coverage
run: |
BUILD_PATH=$(swift build --show-bin-path)
xcrun llvm-cov report \
$BUILD_PATH/swift-spyablePackageTests.xctest/Contents/MacOS/swift-spyablePackageTests \
-instr-profile=$BUILD_PATH/codecov/default.profdata \
-ignore-filename-regex=".build|Tests" -use-color
xcrun llvm-cov export -format="lcov" \
$BUILD_PATH/swift-spyablePackageTests.xctest/Contents/MacOS/swift-spyablePackageTests \
-instr-profile=$BUILD_PATH/codecov/default.profdata \
-ignore-filename-regex=".build|Tests" > coverage_report.lcov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage_report.lcov
check-macro-compatibility:
name: Check Macro Compatibility
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Swift Macro Compatibility Check
uses: Matejkob/swift-macro-compatibility-check@v1
with:
run-tests: true
major-versions-only: false