-
Notifications
You must be signed in to change notification settings - Fork 5
232 lines (190 loc) · 7.54 KB
/
test.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
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
---
name: Test
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
- ".editorconfig"
pull_request:
branches: [ "**" ]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
- ".editorconfig"
env:
swift-version: '5.10'
jobs:
dev-container:
name: "Dev container: ${{ matrix.cmake_build_type }}"
strategy:
fail-fast: false
matrix:
cmake_build_type: [Debug, Release]
include:
- cmake_build_type: Debug
spm_configuration: debug
HYLO_LLVM_BUILD_TYPE: Debug
- cmake_build_type: Release
spm_configuration: release
HYLO_LLVM_BUILD_TYPE: MinSizeRel
runs-on: ubuntu-latest
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4
with:
submodules: true
show-progress: false
- name: Build and run via SPM
uses: devcontainers/[email protected]
env:
HYLO_LLVM_BUILD_TYPE: ${{ matrix.HYLO_LLVM_BUILD_TYPE }}
with:
runCmd: swift test --parallel -c ${{ matrix.spm_configuration }}
push: never
- name: Build and run via CMake
uses: devcontainers/[email protected]
env:
HYLO_LLVM_BUILD_TYPE: ${{ matrix.HYLO_LLVM_BUILD_TYPE }}
with:
runCmd: >-
cmake -GNinja -S . -B .ninja-build
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR=/opt/llvm-${{ matrix.HYLO_LLVM_BUILD_TYPE }}/lib/cmake/llvm
cmake --build .ninja-build
ctest --parallel --test-dir .ninja-build
push: never
native:
name: "Native: ${{ matrix.os }}/${{ matrix.spm_configuration }}"
strategy:
fail-fast: false
matrix:
# macos-latest is apparently not the latest.
os: [macos-13, ubuntu-latest, windows-latest]
spm_configuration: [debug, release]
include:
- HYLO_LLVM_BUILD_RELEASE: 20240303-215025
- HYLO_LLVM_DOWNLOAD_URL: https://github.com/hylo-lang/llvm-build/releases/download
- HYLO_LLVM_VERSION: 17.0.6
- llvm_package_suffix: .tar.zst
- swift_test_options:
- unpackage_command: tar -x --zstd -f
- spm_configuration: debug
cmake_build_type: Debug
HYLO_LLVM_BUILD_TYPE: Debug
- spm_configuration: release
cmake_build_type: Release
HYLO_LLVM_BUILD_TYPE: MinSizeRel
- os: windows-latest
unpackage_command: 7z x -t7z
llvm_package_suffix: .7z
triple_suffix: unknown-windows-msvc17
- os: ubuntu-latest
triple_suffix: unknown-linux-gnu
- os: macos-13
triple_suffix: apple-darwin23.3.0
- os: ubuntu-latest
spm_configuration: debug
swift_test_options: --enable-code-coverage
runs-on: ${{ matrix.os }}
env:
llvm_url_prefix: ${{ matrix.HYLO_LLVM_DOWNLOAD_URL }}/${{ matrix.HYLO_LLVM_BUILD_RELEASE }}
llvm_package_basename: llvm-${{ matrix.HYLO_LLVM_VERSION }}-x86_64-${{ matrix.triple_suffix }}-${{ matrix.HYLO_LLVM_BUILD_TYPE }}
steps:
- uses: maxim-lobanov/setup-xcode@v1
if: ${{ runner.os == 'macOS' }}
with:
xcode-version: latest-stable
- name: 'Set up swift (non-Windows)'
if: ${{ runner.os != 'Windows' }}
uses: SwiftyLab/setup-swift@latest
with:
swift-version: ${{ env.swift-version }}
- uses: compnerd/gha-setup-vsdevenv@main
- name: Set up swift (Windows)
if: ${{ runner.os == 'Windows' }}
uses: compnerd/[email protected]
with:
branch: swift-${{ env.swift-version }}-release
tag: ${{ env.swift-version }}-RELEASE
- name: Verify swift version
run: swift --version && swift --version | grep -q ${{ env.swift-version }}
shell: bash
- name: Set up latest CMake and Ninja
uses: lukka/get-cmake@latest
- name: Install LLVM
# 7z doesn't support decompressing from a stream or we'd do this all as one statement. Maybe
# we should find a way to use zstd on windows.
run: >-
curl --no-progress-meter -L -O
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}"
${{ env.llvm_url_prefix }}/${{ env.llvm_package_basename }}${{ matrix.llvm_package_suffix }}
${{ matrix.unpackage_command }} ${{ env.llvm_package_basename }}${{ matrix.llvm_package_suffix }}
- name: Checkout (GitHub)
uses: actions/checkout@v4
with:
submodules: true
show-progress: false
path: Swifty-LLVM
- name: Configure (CMake)
# We explicitly point to swiftc in the PATH because otherwise CMake picks up the one in XCode.
run: >-
cmake -GNinja -S . -B .cmake-build
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR=${{ github.workspace }}/${{ env.llvm_package_basename }}/lib/cmake/llvm
${{ runner.os == 'macOS' && '-D CMAKE_Swift_COMPILER=swiftc' || '' }}
working-directory: Swifty-LLVM
- name: Build (CMake)
run: cmake --build Swifty-LLVM/.cmake-build
- name: Test (CMake)
run: ctest -V --test-dir Swifty-LLVM/.cmake-build
- name: Create LLVM pkgconfig file and make it findable
run: >-
set -ex -o pipefail
mkdir pkg-config
PATH="${{ github.workspace }}/${{ env.llvm_package_basename }}/bin:$PATH"
Swifty-LLVM/Tools/make-pkgconfig.sh pkg-config/llvm.pc
echo 'PKG_CONFIG_PATH=${{ github.workspace }}/pkg-config' >> $GITHUB_ENV
shell: bash
- name: CMake => Xcode
if: ${{ runner.os == 'macOS' }}
# We explicitly point to swiftc in the PATH because otherwise CMake picks up the one in XCode.
run: >-
cmake -GXcode -S . -B .xcode-build
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }}
-DBUILD_TESTING=YES
-DLLVM_DIR=${{ github.workspace }}/${{ env.llvm_package_basename }}/lib/cmake/llvm
${{ runner.os == 'macOS' && '-D CMAKE_Swift_COMPILER=swiftc' || '' }}
cd .xcode-build
xcrun xcodebuild -configuration ${{ matrix.spm_configuration }} -scheme SwiftyLLVM -destination 'platform=macOS' test
working-directory: Swifty-LLVM
- name: Build and Test via SPM
if: ${{ runner.os != 'Windows' || env.swift-version != '5.10' }}
run: swift test -v ${{ matrix.swift_test_options }} -c ${{ matrix.spm_configuration }}
working-directory: Swifty-LLVM
- name: Export Coverage
if: ${{ contains(matrix.swift_test_options, '--enable-code-coverage') }}
working-directory: Swifty-LLVM
run: |
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 this command might require a leading xcrun.
llvm-cov export -format="lcov" -instr-profile "$(swift test -c ${{ matrix.spm_configuration }} --show-codecov-path | xargs dirname)"/default.profdata "${bin_params[@]}" > info.lcov
- name: Upload coverage reports to Codecov
if: ${{ contains(matrix.swift_test_options, '--enable-code-coverage') }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
directory: ${{ github.workspace }}/Swifty-LLVM
working-directory: ${{ github.workspace }}/Swifty-LLVM
root_dir: ${{ github.workspace }}/Swifty-LLVM