-
Notifications
You must be signed in to change notification settings - Fork 10
287 lines (240 loc) · 10.1 KB
/
Copy pathtest.yml
File metadata and controls
287 lines (240 loc) · 10.1 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
---
name: Test
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
- ".editorconfig"
pull_request:
branches: [ "**" ]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
- ".editorconfig"
env:
spm-build-options: -Xswiftc -enable-testing --explicit-target-dependency-import-check error
spm-test-options: --parallel
swift-version: '6.3'
HYLO_LLVM_BUILD_RELEASE: 20260521-114955
HYLO_LLVM_VERSION: '20.1.6'
jobs:
line-length:
name: "Line length"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Check max line length of 100 characters
run: "! grep -rnE --include=*.swift --exclude-dir=cmake.* --exclude-dir=.build '.{101,}' ."
dev-container:
name: "Ubuntu dev container/${{matrix.build-system}}/${{ matrix.cmake_build_type }}"
strategy:
fail-fast: false
matrix:
cmake_build_type: [Debug, Release]
build-system: [cmake, spm]
include:
- spm_configuration: debug
cmake_build_type: Debug
more-spm-test-options: --enable-code-coverage
HYLO_LLVM_BUILD_TYPE: Debug
- spm_configuration: release
cmake_build_type: Release
HYLO_LLVM_BUILD_TYPE: MinSizeRel
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
show-progress: false
- name: Initialize Dev Container
uses: devcontainers/ci@v0.3
with:
runCmd: uname -a # Just print OS information
push: never
- name: Build and run via CMake
uses: devcontainers/ci@v0.3
if: ${{ matrix.build-system == 'cmake' }}
env:
HYLO_LLVM_BUILD_TYPE: ${{ matrix.HYLO_LLVM_BUILD_TYPE }}
with:
runCmd: >
set -exu # fail fast, print commands before executing, treat unset variables as an error
LLVM_DIR="$(llvm-config --prefix)/lib/cmake/llvm"
[ -f "$LLVM_DIR/LLVMConfig.cmake" ] ||
(echo "LLVMConfig.cmake not found in '$LLVM_DIR'. Available files are:";
ls "$LLVM_DIR";
exit 1)
cmake -GNinja -S . -B .cmake-build
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR="$LLVM_DIR"
cmake --build .cmake-build
ctest --output-on-failure --parallel --test-dir .cmake-build
push: never
- name: Build and Test via SPM
if: ${{ matrix.build-system == 'spm' }}
uses: devcontainers/ci@v0.3
with: # todo make pipe fail if first command fails
runCmd: |
/usr/bin/llvm-cov --version
swift test -c ${{ matrix.spm_configuration }} ${{ env.spm-build-options }} ${{ env.spm-test-options }} ${{ matrix.more-spm-test-options }}
push: never
- name: Export Coverage
uses: devcontainers/ci@v0.3
if: ${{ matrix.build-system == 'spm' && contains(matrix.more-spm-test-options, '--enable-code-coverage') }}
with:
runCmd: |
shopt -s nullglob
dot_os=(.build/${{ matrix.spm_configuration }}/*.build/*.o .build/${{ matrix.spm_configuration }}/*.build/**/*.o)
bin_params=("${dot_os[0]}")
for o in "${dot_os[@]:1}"; do
bin_params+=("-object" "${o}")
done
# Note: on mac using llvm-cov from Xcode might require a leading xcrun.
/usr/bin/llvm-cov export -format="lcov" -instr-profile "$(swift test -c ${{ matrix.spm_configuration }} --show-codecov-path | xargs dirname)"/default.profdata "${bin_params[@]}" > info.lcov
push: never
- name: Upload coverage reports to Codecov
if: ${{ matrix.build-system == 'spm' && contains(matrix.more-spm-test-options, '--enable-code-coverage') }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
native-spm:
name: "SPM: ${{ matrix.os }}/${{ matrix.spm_configuration }}${{ matrix.cross_compilation && '/cross' || '' }}"
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04, windows-2025]
spm_configuration: [debug, release]
cross_compilation: [true, false]
include:
- spm_configuration: debug
HYLO_LLVM_BUILD_TYPE: Debug
- spm_configuration: release
HYLO_LLVM_BUILD_TYPE: MinSizeRel
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
show-progress: false
path: Swifty-LLVM
- name: Set up LLVM
uses: hylo-lang/get-llvm@6a49368ad6b8b735b444d4b9840b0bc466e7875a # v0.4.0
id: get-llvm
with:
llvmVersion: ${{ env.HYLO_LLVM_VERSION }}
llvmBuildRelease: ${{ env.HYLO_LLVM_BUILD_RELEASE }}
llvmBuildConfig: ${{ matrix.HYLO_LLVM_BUILD_TYPE }}
addToPkgConfigPath: true
addToPath: true
- name: Set up specific Xcode version
uses: maxim-lobanov/setup-xcode@v1
if: ${{ runner.os == 'macOS' }}
with:
xcode-version: '26.0.1'
- name: Set up swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ env.swift-version }}
- name: Download Recent Visual Studio and Windows SDK
uses: compnerd/gha-setup-vsdevenv@main
with:
winsdk: "10.0.26100.0"
# Note: The GitHub windows-2025 runner has only a very old version of the Windows SDK available by default.
# Swift is said to require version 10.0.22621.0: https://forums.swift.org/t/swiftpm-plugin-doesnt-work-with-the-latest-visual-studio-version/78183/14
# That no longer works, so we had to upgrade to 10.0.26100.0.
# See also: https://github.com/swiftlang/swift/issues/88237
- name: SPM Cache Setup
uses: actions/cache@v4.2.4
with:
path: Swifty-LLVM/.build
key: ${{ matrix.os }}-${{ matrix.spm_configuration }}-spm-${{ hashFiles('Swifty-LLVM/**/Package.resolved') || 'no-dependencies' }}
restore-keys: |
${{ matrix.os }}-${{ matrix.spm_configuration }}-spm-
- name: Build and Test via SPM
run: swift test -v ${{ matrix.swift_test_options }} ${{ matrix.cross_compilation && '-Xswiftc -DSWIFTY_LLVM_CROSS_COMPILATION_ENABLED' || '' }} -c ${{ matrix.spm_configuration }}
working-directory: Swifty-LLVM
native-cmake:
name: "CMake: ${{ matrix.os }}/${{ matrix.cmake_build_type }}/${{ matrix.cmake_generator }}"
strategy:
fail-fast: false
matrix:
os: [macos-15, ubuntu-24.04, windows-2025]
cmake_build_type: [Debug, Release]
cmake_generator: [Ninja, Xcode] # TODO: add back XCode generator after switching to macos-15: https://github.com/hylo-lang/hylo/issues/1730
exclude:
- os: ubuntu-24.04
cmake_generator: Xcode
- os: windows-2025
cmake_generator: Xcode
include:
- cmake_build_type: Debug
HYLO_LLVM_BUILD_TYPE: Debug
- cmake_build_type: Release
HYLO_LLVM_BUILD_TYPE: MinSizeRel
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
show-progress: false
path: Swifty-LLVM
- name: Set up LLVM
uses: hylo-lang/get-llvm@6a49368ad6b8b735b444d4b9840b0bc466e7875a # v0.4.0
id: get-llvm
with:
llvmVersion: ${{ env.HYLO_LLVM_VERSION }}
llvmBuildRelease: ${{ env.HYLO_LLVM_BUILD_RELEASE }}
llvmBuildConfig: ${{ matrix.HYLO_LLVM_BUILD_TYPE }}
addToPkgConfigPath: true
addToPath: true
- name: Set up specific Xcode version
uses: maxim-lobanov/setup-xcode@v1
if: ${{ runner.os == 'macOS' }}
with:
xcode-version: '26.0.1'
- name: Set up latest CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: latest
- name: Set up swift
uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ env.swift-version }}
- name: Download Recent Visual Studio and Windows SDK
uses: compnerd/gha-setup-vsdevenv@main
with:
winsdk: "10.0.26100.0"
# Note: The GitHub windows-2025 runner has only a very old version of the Windows SDK available by default.
# Swift is said to require version 10.0.22621.0: https://forums.swift.org/t/swiftpm-plugin-doesnt-work-with-the-latest-visual-studio-version/78183/14
# That no longer works, so we had to upgrade to 10.0.26100.0.
# See also: https://github.com/swiftlang/swift/issues/88237
- name: Configure (CMake)
# We explicitly point to swiftc in the PATH because otherwise CMake picks up the one in XCode.
shell: bash
run: >
set -exu # fail fast, print commands before executing, treat unset variables as an error
LLVM_DIR="${{ steps.get-llvm.outputs.llvmCmakeDirectory }}"
[ -f "$LLVM_DIR/LLVMConfig.cmake" ] ||
(echo "LLVMConfig.cmake not found in '$LLVM_DIR'. Available files are:";
ls "$LLVM_DIR";
exit 1)
cmake -G '${{ matrix.cmake_generator }}'
-S .
-B .cmake-build
${{ matrix.cmake_generator != 'Xcode' && format('-DCMAKE_BUILD_TYPE={0}', matrix.cmake_build_type) || '' }}
-DBUILD_TESTING=YES
-DLLVM_DIR="$LLVM_DIR"
${{ runner.os == 'macOS' && '-DCMAKE_Swift_COMPILER=swiftc -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)' || '' }}
working-directory: Swifty-LLVM
- name: Build (CMake)
run: cmake --build Swifty-LLVM/.cmake-build ${{ matrix.cmake_generator == 'Xcode' && format('--config {0}', matrix.cmake_build_type) || '' }}
- name: Test (CMake)
run: ctest --output-on-failure --parallel --test-dir Swifty-LLVM/.cmake-build ${{ matrix.cmake_generator == 'Xcode' && format('-C {0}', matrix.cmake_build_type) || '' }}