forked from maplibre/maplibre-native
-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (195 loc) · 7.32 KB
/
linux-ci.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
name: linux-ci
on:
workflow_dispatch:
push:
branches:
- main
- linux-*.*.x
tags:
- linux-*
pull_request:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# INFO: We are cancelling the concurrency group if the change is on PR. For workflow dispatch, this will not work.
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
id-token: write # needed for AWS
actions: read # needed for CodeQL
contents: read # needed for CodeQL
security-events: write # needed for CodeQL
jobs:
pre_job:
runs-on: ubuntu-22.04
outputs:
should_skip: ${{ github.event_name != 'workflow_dispatch' && steps.changed-files.outputs.linux_any_modified != 'true' }}
steps:
- uses: actions/checkout@v4
- name: Get all Linux files that have changed
if: github.event_name != 'workflow_dispatch'
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_yaml_from_source_file: .github/changed-files.yml
- name: List changed files
if: steps.changed-files.outputs.linux_any_modified == 'true'
run: |
echo "Changed file(s): ${{ steps.changed-files.outputs.linux_all_changed_files }}"
linux-build-and-test:
if: needs.pre_job.outputs.should_skip != 'true'
needs: pre_job
strategy:
fail-fast: true
matrix:
renderer: [legacy, drawable]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: cpp
- uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}
- name: Get latest CMake and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: 3.24.1
ninjaVersion: latest
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libcurl4-openssl-dev \
libuv1-dev \
libjpeg-dev \
libpng-dev \
libglfw3-dev \
libwebp-dev \
libopengl0
- if: matrix.renderer == 'drawable'
run: echo renderer_flag_cmake=-DMLN_DRAWABLE_RENDERER=ON >> "$GITHUB_ENV"
- if: matrix.renderer == 'legacy'
run: echo renderer_flag_cmake=-DMLN_LEGACY_RENDERER=ON >> "$GITHUB_ENV"
- name: Build MapLibre Native Core
env:
CI: 1
run: |
cmake --version
cmake -B build -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMLN_WITH_CLANG_TIDY=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DMLN_WITH_COVERAGE=ON ${{ env.renderer_flag_cmake }}
cmake --build build --target mbgl-core mbgl-test-runner mbgl-render-test-runner mbgl-expression-test mbgl-render mbgl-benchmark-runner
# mbgl-render (used for size test) & mbgl-benchmark-runner
- name: Upload mbgl-render as artifact
if: matrix.renderer == 'drawable' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: mbgl-render
path: |
build/bin/mbgl-render
- name: Upload mbgl-benchmark-runner as artifact
if: matrix.renderer == 'drawable' && github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: mbgl-benchmark-runner
path: |
build/mbgl-benchmark-runner
- name: Configure AWS Credentials
if: matrix.renderer == 'drawable' && github.ref == 'refs/heads/main' && vars.OIDC_AWS_ROLE_TO_ASSUME
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.run_id }}
- name: Upload mbgl-render & mbgl-benchmark-runner to S3
if: matrix.renderer == 'drawable' && github.ref == 'refs/heads/main' && vars.OIDC_AWS_ROLE_TO_ASSUME
run: |
aws s3 cp build/bin/mbgl-render s3://maplibre-native/mbgl-render-main
aws s3 cp build/mbgl-benchmark-runner s3://maplibre-native/mbgl-benchmark-runner-main
# CodeQL
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:cpp"
# unit tests
- run: chmod +x build/mbgl-test-runner
- name: Run C++ tests
run: xvfb-run -a build/mbgl-test-runner
# render tests
- run: chmod +x build/mbgl-render-test-runner
- name: Run render test
id: render_test
run: xvfb-run -a build/mbgl-render-test-runner --manifestPath=metrics/linux-${{ matrix.renderer }}.json
- name: Upload render test result
if: always() && steps.render_test.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: render-test-result-${{ matrix.renderer }}
path: |
metrics/linux-${{ matrix.renderer }}.html
# expression tests
- run: chmod +x build/expression-test/mbgl-expression-test
- name: Run expression test
run: build/expression-test/mbgl-expression-test
- if: github.event_name == 'pull_request'
uses: ./.github/actions/save-pr-number
linux-coverage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
libcurl4-openssl-dev \
libuv1-dev \
libjpeg-dev \
libpng-dev \
libwebp-dev \
libglfw3-dev \
libsqlite3-dev \
xvfb \
x11-xserver-utils
- name: Cache Bazel
uses: actions/cache@v4
with:
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
path: ~/.cache/bazel
- name: Start server
run: |
npm install --ignore-scripts
node test/storage/server.js &
- name: Generate coverage report
run: |
xvfb-run -a \
bazel coverage --combined_report=lcov --instrumentation_filter="//:mbgl-core" \
--test_output=errors --local_test_jobs=1 \
--test_env=DISPLAY --test_env=XAUTHORITY --copt="-DCI_BUILD" \
//test:core //render-test:render-test //expression-test:test
echo coverage_report="$(bazel info output_path)"/_coverage/_coverage_report.dat >> "$GITHUB_ENV"
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ${{ env.coverage_report }}
linux-ci-result:
name: Linux CI Result
if: needs.pre_job.outputs.should_skip != 'true' && always()
runs-on: ubuntu-22.04
needs:
- pre_job
- linux-build-and-test
- linux-coverage
steps:
- name: Mark result as failed
if: needs.linux-build-and-test.result != 'success' || needs.linux-coverage.result != 'success'
run: exit 1