-
Notifications
You must be signed in to change notification settings - Fork 91
294 lines (260 loc) · 10.6 KB
/
ResInsightWithCache.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
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
288
289
290
291
292
293
name: ResInsight Build With Cache
on:
push:
pull_request:
schedule:
# Every day at 1am to make sure we have a build cache for the current date
# build cache is
- cron: '0 1 * * *'
env:
BUILD_TYPE: Release
BUILDCACHE_VERSION: 0.27.6
BUILDCACHE_DIR: ${{ github.workspace }}/buildcache_dir
BUILDCACHE_ACCURACY: SLOPPY
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest MSVC",
os: windows-2022,
cc: "cl",
cxx: "cl",
vcpkg-response-file: vcpkg_x64-windows.txt,
vcpkg-triplet: x64-windows,
build-python-module: true,
execute-unit-tests: true,
unity-build: true,
publish-to-pypi: false,
}
- {
name: "Ubuntu Latest gcc",
os: ubuntu-20.04,
cc: "gcc",
cxx: "g++",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
build-python-module: true,
execute-unit-tests: true,
unity-build: false,
publish-to-pypi: true,
}
- {
name: "Ubuntu Latest clang",
os: ubuntu-20.04,
cc: "clang",
cxx: "clang++",
vcpkg-response-file: vcpkg_x64-linux.txt,
vcpkg-triplet: x64-linux,
build-python-module: true,
execute-unit-tests: true,
unity-build: false,
publish-to-pypi: false,
}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Get Python executable path
shell: bash
id: python-path
run: echo "PYTHON_EXECUTABLE=$(python -c 'import sys; import pathlib; print (pathlib.PurePath(sys.executable).as_posix())')" >> $GITHUB_OUTPUT
- name: Print Python path
run: echo "${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r GrpcInterface/Python/requirements.txt
- name: Use CMake
uses: lukka/get-cmake@latest
- name: Use MSVC (Windows)
uses: ilammy/msvc-dev-cmd@v1
- name: Download buildcache
id: buildcache-download
shell: cmake -P {0}
run: |
if ("${{ runner.os }}" STREQUAL "Windows")
set(buildcache_suffix "windows.zip")
elseif ("${{ runner.os }}" STREQUAL "macOS")
set(buildcache_suffix "macos.zip")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(buildcache_suffix "linux.tar.gz")
endif()
set(buildcache_version $ENV{BUILDCACHE_VERSION})
set(buildcache_url "https://github.com/mbitsnbites/buildcache/releases/download/v${buildcache_version}/buildcache-${buildcache_suffix}")
file(DOWNLOAD "${buildcache_url}" ./buildcache.zip)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./buildcache.zip)
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(
COMMAND chmod +x buildcache/bin/buildcache
)
endif()
- name: Get current time
uses: josStorer/[email protected]
id: current-time
with:
format: YYYY-MM-DD
- name: Print time stamp
run: echo "timestamp ${{ steps.current-time.outputs.formattedTime }}"
- name: Cache Buildcache
id: cache-buildcache
uses: actions/cache@v3
with:
path: ${{ env.BUILDCACHE_DIR }}
key: ${{ matrix.config.os }}-${{ matrix.config.cc }}-cache-v02-${{ steps.current-time.outputs.formattedTime }}
- name: Create Folder for buildcache
run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force
shell: pwsh
- name: Add buildcache to system path
run: echo "${{github.workspace}}/buildcache/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
shell: pwsh
- name: Set apt mirror
# see https://github.com/actions/runner-images/issues/7048
if: ${{contains( matrix.config.os, 'ubuntu') }}
run: |
# make sure there is a `\t` between URL and `priority:*` attributes
printf 'http://azure.archive.ubuntu.com/ubuntu priority:1\n' | sudo tee /etc/apt/mirrors.txt
curl http://mirrors.ubuntu.com/mirrors.txt | sudo tee --append /etc/apt/mirrors.txt
sudo sed -i 's/http:\/\/azure.archive.ubuntu.com\/ubuntu\//mirror+file:\/etc\/apt\/mirrors.txt/' /etc/apt/sources.list
- name: Install Linux dependencies
if: ${{contains( matrix.config.os, 'ubuntu') }}
run: |
sudo apt-get update --option="APT::Acquire::Retries=3"
sudo apt-get install --option="APT::Acquire::Retries=3" libxkbcommon-x11-0 libgl1-mesa-dev mesa-common-dev libglfw3-dev libglu1-mesa-dev libhdf5-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: 5.12.12
dir: "${{ github.workspace }}/Qt/"
cache: true
- name: Restore from cache and install vcpkg
uses: lukka/run-vcpkg@v7
id: runvcpkg
with:
vcpkgArguments: "@${{ github.workspace }}/${{ matrix.config.vcpkg-response-file }}"
vcpkgDirectory:
"${{ github.workspace }}/ThirdParty/vcpkg"
appendedCacheKey: ${{ matrix.config.os }}-${{ matrix.config.cxx }}-cache-key-v2
- name: Cache dynamic version of OpenSSL (Linux)
if: ${{contains( matrix.config.os, 'ubuntu_disabled') }}
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/ThirdParty/vcpkg/installed/x64-linux-dynamic
key: ${{ matrix.config.os }}-vcpkg-x64-linux-dynamic_v05
- name: Install dynamic version of OpenSSL (Linux)
if: ${{contains( matrix.config.os, 'ubuntu') }}
run: |
$VCPKG_ROOT/vcpkg install --overlay-triplets=${{ github.workspace }}/ThirdParty/vcpkg-custom-triplets --triplet x64-linux-dynamic openssl
- name: Configure
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
execute_process(
COMMAND cmake
-S .
-B cmakebuild
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-D CMAKE_INSTALL_PREFIX=cmakebuild/install
-D RESINSIGHT_BUNDLE_OPENSSL=true
-D RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS=true
-D RESINSIGHT_TREAT_WARNINGS_AS_ERRORS=true
-D RESINSIGHT_ENABLE_PRECOMPILED_HEADERS=false
-D RESINSIGHT_ENABLE_UNITY_BUILD=${{ matrix.config.unity-build }}
-D RESINSIGHT_ENABLE_GRPC=${{ matrix.config.build-python-module }}
-D RESINSIGHT_GRPC_PYTHON_EXECUTABLE=${{ steps.python-path.outputs.PYTHON_EXECUTABLE }}
-D RESINSIGHT_GRPC_DOWNLOAD_PYTHON_MODULE=true
-D RESINSIGHT_ENABLE_HDF5=false
-D RESINSIGHT_BUILD_LIBS_FROM_SOURCE=false
-D CMAKE_TOOLCHAIN_FILE=ThirdParty/vcpkg/scripts/buildsystems/vcpkg.cmake
-G Ninja
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
execute_process(
COMMAND cmake --build cmakebuild --target install
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Stats for buildcache
run: ${{ github.workspace }}/buildcache/bin/buildcache -s
- name: Run Unit Tests
if: matrix.config.execute-unit-tests
shell: bash
run: |
cmakebuild/ApplicationExeCode/ResInsight --unittest
- name: (Python) Check types using mypy
if: matrix.config.build-python-module
shell: bash
run: |
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pip install mypy types-protobuf
cd GrpcInterface/Python/rips
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m mypy *.py generated/generated_classes.py
- name: Run pytest
if: matrix.config.build-python-module
env:
RESINSIGHT_EXECUTABLE: ${{ runner.workspace }}/ResInsight/cmakebuild/ApplicationExeCode/ResInsight
run: |
cd GrpcInterface/Python
python setup.py sdist
cd rips
${{ steps.python-path.outputs.PYTHON_EXECUTABLE }} -m pytest --console
- name: Upload python distribution folder
if: matrix.config.publish-to-pypi
uses: actions/upload-artifact@v3
with:
name: python-distribution
path: GrpcInterface/Python/dist
- name: Upload Windows install artifact
if: ${{contains( matrix.config.os, 'windows') }}
uses: actions/upload-artifact@v3
with:
name: ResInsight-${{ matrix.config.name }}
path: ${{ runner.workspace }}/ResInsight/cmakebuild/install
pypi-publish:
name: Upload release to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/rips
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# If this is a tagged release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- name: Download python distribution folder
uses: actions/download-artifact@v3
with:
name: python-distribution
path: dist
- name: Display structure of downloaded files
run: ls -R
- name: Publish Python package to pypi
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
uses: pypa/gh-action-pypi-publish@release/v1
# uncomment the two lines below to publish to test PyPi
# with:
# repository-url: https://test.pypi.org/legacy/