-
Notifications
You must be signed in to change notification settings - Fork 11
239 lines (218 loc) · 9.68 KB
/
Build-multi-OS.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
233
234
235
236
237
238
239
# This workflow builds, tests, deploys and uploads the MuhRec application on different configrations specified on the matrix.
name: Build MuhRec on multiple platforms
env:
CONAN_HOME: ${{ github.workspace }}/Cache/ # Used by the built-in GH cache action to cache conan dependencies
CACHE_GITHUB: damskii9992 # Used by turtlebrowers conan cache action, if enabled
CACHE_GITHUB_REPO: ConanCache # Used by turtlebrowers conan cache action, if enabled
CONAN_USER_HOME: ${{ github.workspace }}/Cache/ # Used by turtlebrowers conan cache action, if enabled
CONAN_USER_HOME_SHORT: ${{ github.workspace }}/Cache//short # Used by turtlebrowers conan cache action, if enabled
# MACOSX_DEPLOYMENT_TARGET: 10.15 # Can be set to build for older version of MacOS, ignored by other OSs. Currently does not work.
on:
workflow_dispatch:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Build on the following 4 configurations:
# 1. <Windows, Release, 2022 MSVC compiler toolchain>
# 2. <Ubuntu latest, i.e. version 22.04, Release, GCC 11 compiler toolchain>
# 3. <MacOS 13 with x86-64 arch, Release, Clang 14 compiler toolchain>
# 4. <MacOS 14 with arm64 arch, Release, Clang 15 compiler toolchain
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the list.
matrix:
include:
# - os: windows-2022
# c_compiler: cl
# cpp_compiler: cl
# cl: 17
# build_type: Release
# build_root: build-imagingsuite
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
gcc: 11
build_type: Release
build_root: build-imagingsuite/Release
# - os: macos-13
# c_compiler: clang
# cpp_compiler: clang++
# clang: 14
# build_type: Release
# build_root: build-imagingsuite/Release
# - os: macos-14
# c_compiler: clang
# cpp_compiler: clang++
# clang: 15
# build_type: Release
# build_root: build-imagingsuite/Release
steps:
# Checkouts the source code to build the project with the git history
- name: Checkout imagingsuite source code
uses: actions/checkout@v4
with:
path: imagingsuite
fetch-depth: 0
# Checks out the test data repository for the c++ tests with ctest
- name: Checkout neutronimaging/TestData <-- clone https://github.com/neutronimaging/TestData.git
uses: actions/checkout@v4
with:
repository: neutronimaging/TestData
path: TestData
# This action is an alternative to the builtin GitHub Cache action which circumvents storage size and time limits
# It can be used in tandem with the builtin Cache but it has LFS costs
# To use it, change order of actions to GH cache -> this action -> install Qt -> Conan install
# The current order of actions is, for some reason, neseccary to properly run Ronan to compile new libraries
# Requires the used environment variables to be set up properly as well as a bot account with write access and an external cache repo
# - name: Cache Conan modules
# if: steps.github-cache-conan.outputs.cache-hit != 'true'
# id: cache-conan
# uses: turtlebrowser/conan-cache@master
# with:
# bot_name: ${{ secrets.BOT_NAME }}
# bot_token: ${{ secrets.BOT_TOKEN }}
# cache_name: ${{ env.CACHE_GITHUB }}/${{ env.CACHE_GITHUB_REPO }}
# key: ${{ runner.os }}-${{ runner.arch }}
# lfs_limit: 60
# This version of Qt only allows python versions in the range 3.6-3.11
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.5.3'
dir: '${{GITHUB.WORKSPACE}}'
install-deps: 'true'
modules: 'qtcharts'
- name: Conan installation
id: conan
uses: turtlebrowser/get-conan@main
- name: Using the builtin GitHub Cache Action for .conan
id: github-cache-conan
uses: actions/cache@v4
env:
cache-name: cache-conan-modules
with:
path: ${{ env.CONAN_HOME }}
key: ${{ runner.os }}-${{ runner.arch }}
- name: Set QTAPTH environment variable
shell: bash
run: |
echo "QTPATH=${{env.Qt6_DIR}}" >> "$GITHUB_ENV"
- name: Install sse2neon
# Needed to compile ARM programs and not currently available on Conan
if: ${{ ( runner.os == 'macOS' ) && (runner.arch == 'ARM64') }}
run: brew install sse2neon
- name: Build with Conan
working-directory: imagingsuite
shell: bash
run: |
if [ "${RUNNER_OS}" == "Windows" ]; then
conan build . --profile:all profiles/windows_msvc_17_release --build=missing
elif [ "${RUNNER_OS}" == "Linux" ]; then
conan build . --profile:all profiles/linux_gcc_11_release --build=missing
elif [ "${RUNNER_OS}" == "macOS" -a "${RUNNER_ARCH}" == "X64" ]; then
conan build . --profile:all profiles/macos_x64_clang_14_release --build=missing
elif [ "${RUNNER_OS}" == "macOS" -a "${RUNNER_ARCH}" == "ARM64" ]; then
conan build . --profile:all profiles/macos_arm_clang_15_release --build=missing
fi
- name: Qt Deploy
working-directory: build-imagingsuite
shell: bash
run: |
if [ "${RUNNER_OS}" == "Windows" ]; then
cd bin/Release
${QTPATH}/bin/windeployqt muhrec.exe
${QTPATH}/bin/windeployqt imageviewer.exe
elif [ "${RUNNER_OS}" == "macOS" ]; then
cd Release
${QTPATH}/bin/macdeployqt muhrec.app
${QTPATH}/bin/macdeployqt imageviewer.app
fi
- name: Ammend shared libraries runpaths
if: ${{ runner.os == 'Linux' }}
working-directory: build-imagingsuite/Release/lib
shell: bash
run: |
mv libstdc++.so.6 libstdc++.sc.6
patchelf --set-rpath '$ORIGIN' *.so*
mv libstdc++.sc.6 libstdc++.so.6
- name: Test
id: tests
working-directory: ${{ matrix.build_root }}
shell: bash
#Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
#See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# The seperation of module files into seperate folders breaks the ctest test discovery, copy temprarily to the root folder for testing
run: |
if [ "${RUNNER_OS}" == "Windows" ]; then
cp ./bin/Release/PlugIns/Preprocessors/* ./bin/Release/PlugIns/BackProjectors/* ./bin/Release/
elif [ "${RUNNER_OS}" == "Linux" ]; then
cp ./PlugIns/Preprocessors/* ./PlugIns/BackProjectors/* ./lib/
elif [ "${RUNNER_OS}" == "macOS" ]; then
cp ./lib/Preprocessors/* ./lib/BackProjectors/* ./lib/
fi
ctest --build-config ${{ matrix.build_type }}
if [ "${RUNNER_OS}" == "Windows" ]; then
rm ./bin/Release/*Modules.dll ./bin/Release/*Projectors.dll
elif [ "${RUNNER_OS}" == "Linux" ]; then
rm lib/*Modules.so lib/*Projectors.so
elif [ "${RUNNER_OS}" == "macOS" ]; then
rm -r lib/*Modules.dylib lib/*Projectors.dylib
fi
continue-on-error: true
- name: Archive test results
if: steps.tests.outcome == 'failure'
uses: actions/upload-artifact@master
with:
name: ${{runner.os}}-${{runner.arch}}-test-results
path: ${{ matrix.build_root }}/Testing
- name: Compress artifact
shell: bash
working-directory: ${{ matrix.build_root }}
run: |
if [ "${RUNNER_OS}" == "Windows" ]; then
7z a ../MuhRec-${{runner.os}}-${{runner.arch}}.zip "bin/Release/*" -xr!t*.exe -xr!.pyd
elif [ "${RUNNER_OS}" == "Linux" ]; then
zip -r ../../MuhRec-${{runner.os}}-${{runner.arch}}.zip bin/* lib/* PlugIns/* resources/* -x "bin/t*"
cd lib
ls
elif [ "${RUNNER_OS}" == "macOS" -a "${RUNNER_ARCH}" == "X64" ]; then
zip -r ../../MuhRec-${{runner.os}}-${{runner.arch}}.zip lib/* *.app/* -x "lib/*.dylib"
elif [ "${RUNNER_OS}" == "macOS" -a "${RUNNER_ARCH}" == "ARM64" ]; then
zip -r ../../MuhRec-${{runner.os}}-${{runner.arch}}.zip lib/* *.app/* -x "lib/*.dylib" -x "lib/*.h"
fi
- name: Save build artifact Windows
if: ${{ runner.os == 'Windows' }}
uses: actions/upload-artifact@master
with:
name: MuhRec-${{runner.os}}-${{runner.arch}}
path: |
${{ matrix.build_root }}/bin/Release/*
!${{ matrix.build_root }}/bin/Release/t*.exe
!${{ matrix.build_root }}/bin/Release/*.pyd
- name: Save build artifact Linux
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@master
with:
name: MuhRec-${{runner.os}}-${{runner.arch}}
path: |
"${{ github.workspace }}/MuhRec*.zip"
# ${{ matrix.build_root }}/bin/*
# !${{ matrix.build_root }}/bin/t*
# ${{ matrix.build_root }}/PlugIns/*
# ${{ matrix.build_root }}/lib/*
# !${{ matrix.build_root }}/lib/*cpython*
# ${{ matrix.build_root }}/resources/*
- name: Save build artifact MacOS
if: ${{ runner.os == 'macOS' }}
uses: actions/upload-artifact@master
with:
name: MuhRec-${{runner.os}}-${{runner.arch}}
path: |
${{ matrix.build_root }}/*.app/*