-
Notifications
You must be signed in to change notification settings - Fork 5
175 lines (173 loc) · 6.32 KB
/
ci.yaml
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
name: CI
on:
pull_request:
branches: ["main"]
push:
branches: ["main"]
jobs:
format-check:
name: Format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++ programs
uses: jidicula/[email protected]
with:
clang-format-version: '14'
debug-build:
runs-on: ubuntu-latest
env:
snapshot_version: v1.3.0
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install OpenMP
run: sudo apt update && sudo apt install -y libomp-dev
- name: Install GDAL
run: sudo apt update && sudo apt install libgdal-dev
- name: Install doxygen
run: |
sudo apt update
sudo apt install doxygen
- name: Install Python build dependencies
run: |
pip install -r ${{github.workspace}}/docs/requirements.txt
- name: Cache snapshot data
id: cache-snapshots-debug
uses: actions/cache@v4
with:
path: test/snapshots
key: snapshots-${{ env.snapshot_version }}
- name: Download and extract snapshot data
if: steps.cache-snapshots-debug.outputs.cache-hit != 'true'
working-directory: test/snapshots
shell: bash
run: |
curl -L -o snapshot_data.tar.gz \
"https://github.com/TopoToolbox/snapshot_data/releases/download/$snapshot_version/snapshot_data.tar.gz"
tar -xzf snapshot_data.tar.gz
shasum -c --status sha256sum.txt
- name: Configure
run: >
cmake -B ${{github.workspace}}/build/debug
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DTT_BUILD_TESTS=ON
-DBUILD_SHARED_LIBS=OFF
-DTT_SANITIZE=ON
-DTT_BUILD_DOCS=ON
- name: Build library
run: cmake --build ${{github.workspace}}/build/debug --config Debug
- name: Test
run: ctest --test-dir ${{github.workspace}}/build/debug -C Debug --output-on-failure
- name: Upload test snapshot artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: snapshot_test_output
path: ${{github.workspace}}/build/debug/test/snapshots/
release-build:
runs-on: ${{ matrix.os }}
env:
snapshot_version: v1.3.0
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
c_compiler: [gcc, clang, cl]
include:
- c_compiler: gcc
cpp_compiler: g++
- c_compiler: clang
cpp_compiler: clang++
- c_compiler: cl
cpp_compiler: cl
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: macos-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install OpenMP on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt-get install -y libomp-dev
- name: Install OpenMP on macOS
if: matrix.os == 'macos-latest'
run: brew install libomp
- name: Set OpenMP_ROOT on macOS
if: matrix.os == 'macos-latest'
run: echo "OpenMP_ROOT=$(brew --prefix)/opt/libomp" >> $GITHUB_ENV
- name: Install GDAL on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt update && sudo apt install libgdal-dev
## TODO: Install GDAL on Windows and macos
- name: Install ninja on windows
uses: seanmiddleditch/gha-setup-ninja@master
if: matrix.os == 'windows-latest'
- name: Set up MSVC
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- name: Set environment variables on Windows
if: matrix.os == 'windows-latest'
run: |
echo "CMAKE_GENERATOR=Ninja" >> "$env:GITHUB_ENV" &&
echo "CMAKE_CONFIGURATION_TYPES=Release" >> "$env:GITHUB_ENV"
- name: Cache snapshot data
if: matrix.os == 'ubuntu-latest'
id: cache-snapshots-release
uses: actions/cache@v4
with:
path: test/snapshots
key: snapshots-${{ env.snapshot_version }}
- name: Download and extract snapshot data
if: matrix.os == 'ubuntu-latest' && steps.cache-snapshots-release.outputs.cache-hit != 'true'
working-directory: test/snapshots
shell: bash
run: |
curl -L -o snapshot_data.tar.gz \
"https://github.com/TopoToolbox/snapshot_data/releases/download/$snapshot_version/snapshot_data.tar.gz"
tar -xzf snapshot_data.tar.gz
shasum -c --status sha256sum.txt
- name: Configure static library
run: >
cmake -B ${{github.workspace}}/build/static
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=${{matrix.c_compiler}}
-DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}}
-DTT_BUILD_TESTS=ON
-DBUILD_SHARED_LIBS=OFF
--profiling-format=google-trace
--profiling-output ${{matrix.os}}_${{matrix.c_compiler}}_config_profile.json
- name: Build static library
run: cmake --build ${{github.workspace}}/build/static --config Release
- name: Test static library
run: ctest --test-dir ${{github.workspace}}/build/static -C Release --output-on-failure
- name: Validate JSON output of profiler
run: ${{github.workspace}}/build/static/test/random_dem | jq -e .
- name: Configure shared library
run: >
cmake -B ${{github.workspace}}/build/shared
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=${{matrix.c_compiler}}
-DCMAKE_CXX_COMPILER=${{matrix.cpp_compiler}}
-DTT_BUILD_TESTS=ON
-DBUILD_SHARED_LIBS=ON
-DTT_SANITIZE=OFF
- name: Build shared library
run: cmake --build ${{github.workspace}}/build/shared --config Release
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{matrix.os}}_${{matrix.c_compiler}}_cmake_profiles
path: ${{matrix.os}}_${{matrix.c_compiler}}_config_profile.json