This repository has been archived by the owner on Jan 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 356
214 lines (210 loc) · 8.36 KB
/
build-and-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
# Copyright (c) 2022 The Orbit Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
name: build-and-test
on:
push:
branches:
- 'main'
paths:
- 'CMakeLists.txt'
- '.github/**'
- 'cmake/**'
- 'src/**'
- 'third_party/**'
- 'conanfile.py'
pull_request:
branches:
- 'main'
paths:
- 'CMakeLists.txt'
- '.github/**'
- 'cmake/**'
- 'src/**'
- 'third_party/**'
schedule:
- cron: '0 7 * * *'
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
job:
name: ${{ matrix.config.build_type }}.${{ matrix.config.cc }}.build-and-test-${{ matrix.config.os }}
runs-on: ${{ matrix.config.os }}
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
config:
- {
name: "GCC Release",
build_type: 'Release',
cc: "gcc",
cxx: "g++",
os: "ubuntu-22.04"
}
- {
name: "Clang Release",
build_type: 'Release',
cc: "clang",
cxx: "clang++",
os: "ubuntu-22.04"
}
- {
name: "Clang Debug",
build_type: 'Debug',
cc: "clang",
cxx: "clang++",
os: "ubuntu-22.04"
}
- {
name: "MSVC Release",
build_type: 'Release',
cc: "msvc",
os: "windows-2019",
conan_profile: "msvc2019_release"
}
env:
CCACHE_BASEDIR: "${GITHUB_WORKSPACE}"
CCACHE_DIR: "${GITHUB_WORKSPACE}/.ccache"
CCACHE_COMPRESS: "true"
CCACHE_COMPRESSLEVEL: "6"
CCACHE_MAXSIZE: "600M"
PR_NUMBER: ${{ github.event.number }}
PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
steps:
- run: |
mkdir pr_metadata
echo "$PR_NUMBER" > pr_metadata/pr_number.txt
echo "$PR_HEAD_REPO" > pr_metadata/pr_head_repo.txt
echo "$PR_HEAD_REF" > pr_metadata/pr_head_ref.txt
if: github.event_name == 'pull_request' && matrix.config.name == 'Clang Debug'
- name: 'Upload PR metadata'
if: github.event_name == 'pull_request' && matrix.config.name == 'Clang Debug'
uses: actions/upload-artifact@v3
with:
name: pr_metadata
path: pr_metadata
retention-days: 1
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Install dependencies (Ubuntu)
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt update && \
sudo apt install --yes --no-install-recommends \
build-essential \
clang-tidy-14 \
cmake \
ccache \
libboost-dev \
libcapstone-dev \
libgrpc++-dev \
libssh2-1-dev \
vulkan-validationlayers-dev \
libz-dev \
llvm-dev \
protobuf-compiler-grpc \
pkg-config \
libvulkan-volk-dev \
libvulkan-dev \
libopengl-dev \
libglx-dev \
mesa-common-dev \
qtbase5-dev \
libgtest-dev \
libgmock-dev \
git \
libprotobuf-dev
- name: Install dependencies (Windows)
if: startsWith(matrix.config.os, 'windows')
run: |
py -3 -m pip install aqtinstall
py -3 -m aqt install-qt --outputdir C:\Qt windows desktop 5.15 win64_msvc2019_64
py -3 -m pip install conan==1.58.0
choco install -y ccache
echo "C:\ProgramData\chocolatey\lib\ccache\tools\ccache-4.7.3-windows-x86_64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Save CCache Timestamp
id: ccache_timestamp
run: echo "timestamp=$(date +%m-%d-%Y--%H:%M:%S)" >> $GITHUB_OUTPUT
shell: bash
- name: Setup CCache Files
uses: actions/cache@v3
with:
path: |
.ccache
~/.conan
C:\.conan
key: ${{ matrix.config.build_type }}-${{ matrix.config.cc }}-ccache-${{ steps.ccache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config.build_type }}-${{ matrix.config.cc }}-ccache-
ccache-
- run: ccache -p
- run: ccache -z
- run: mkdir "build"
if: startsWith(matrix.config.os, 'ubuntu')
- name: CMake Configure (Ubuntu)
if: startsWith(matrix.config.os, 'ubuntu')
working-directory: ./build
env:
CXX: ${{ matrix.config.cxx }}
CC: ${{ matrix.config.cc }}
run: |
cmake -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \
-DCMAKE_CXX_FLAGS="-march=sandybridge -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
${GITHUB_WORKSPACE}
- name: CMake Build (Ubuntu)
if: startsWith(matrix.config.os, 'ubuntu')
working-directory: ./build
run: cmake --build .
- name: Run clang-tidy (Clang Debug)
if: github.event_name == 'pull_request' && matrix.config.name == 'Clang Debug'
run: |
# Use origin/main as reference branch, if not specified by Github
REFERENCE="origin/${GITHUB_BASE_REF:-main}"
MERGE_BASE="$(git merge-base $REFERENCE HEAD)" # Merge base is the commit on main this PR was branched from.
git diff -U0 --no-color --diff-filter=r $MERGE_BASE -- 'src/**' | clang-tidy-diff-14.py -p1 -path build -export-fixes clang-tidy-fixes.yml
- uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request' && matrix.config.name == 'Clang Debug'
with:
name: clang_tidy_fixes
path: clang-tidy-fixes.yml
- name: CMake Test (Ubuntu)
if: startsWith(matrix.config.os, 'ubuntu')
working-directory: ./build
run: |
CTEST_OUTPUT_ON_FAILURE=1 \
ARGS="-E IntegrationTest" \
../contrib/scripts/run_ssh_containers.sh \
cmake --build . --target test
- name: Install conan config (Windows)
if: startsWith(matrix.config.os, 'windows')
run: |
py -3 -m conans.conan config install .\third_party\conan\configs\windows\
py -3 -m conans.conan config install .\third_party\conan\configs\windows_ci\
- name: Build & Test (Windows)
if: startsWith(matrix.config.os, 'windows')
env:
Qt5_DIR: "C:\\Qt\\5.15.2\\msvc2019_64"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"
CMAKE_C_COMPILER_LAUNCHER: "ccache"
run: |
py -3 -m conans.conan install -pr:b msvc2019_release -pr:h ${{ matrix.config.conan_profile }} -if build/ --build outdated --update ./
py -3 -m conans.conan build -bf build/ .
- name: Clean up conan cache (Windows)
run: py -3 -m conans.conan remove --src --builds --force *
if: startsWith(matrix.config.os, 'windows')
- name: CCache Stats
run: ccache -s -v
- name: Upload test artifacts
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results-${{ matrix.config.cc }}-${{ matrix.config.build_type }}
path: 'build/testresults/**/*.xml'
retention-days: 1