-
Notifications
You must be signed in to change notification settings - Fork 51
234 lines (216 loc) · 7.74 KB
/
github-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
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
name: Build and Test
permissions: read-all
on:
# By default this will run when the activity type is "opened", "synchronize",
# or "reopened".
pull_request:
branches:
- main
- development
- "[0-9]+.[0-9]+.[0-9]+" # Run on release branch, e.g. 1.2.0
# Run when protected branches are pushed to, e.g. via merge
push:
branches:
- main
- development
- "[0-9]+.[0-9]+.[0-9]+" # Run on release branch, e.g. 1.2.0
# Manually run this workflow on any specified branch.
workflow_dispatch:
###################
# Define env vars #
###################
env:
HEXL_VER: 1.2.5
HEXL_DIR: ${GITHUB_WORKSPACE}/lib/cmake/hexl-${HEXL_VER}
HEXL_HINT_DIR: >
-DHEXL_HINT_DIR=${GITHUB_WORKSPACE}/lib/cmake/hexl-${HEXL_VER}
COVERAGE_COMPILER_FLAGS: >
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_CXX_COMPILER=g++-11
-DCMAKE_C_COMPILER=gcc-11
-DHEXL_BENCHMARK=ON
-DHEXL_TESTING=ON
-DHEXL_COVERAGE=ON
-DHEXL_DOCS=ON
-DHEXL_TREAT_WARNING_AS_ERROR=ON
-DCMAKE_INSTALL_PREFIX=./
jobs:
format:
name: Format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
# Required for pre-commit
- run: pip3 install cpplint==1.5.5
# NOTE: This is deprecated in favor of pre-commit.ci
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
nix-build:
name: '${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}'
runs-on: '${{ matrix.os }}'
permissions:
contents: write # required for actions/upload-artifacts@v2
defaults:
run:
shell: bash
strategy:
matrix:
# removed platforms not available on github hosted servers.
# sel-fhosted ice-lake servers not enabled by sysadmin
# os: [ice-lake, [self-hosted, ubuntu-18.04], macos-latest, ubuntu-20.04]
# os: [macos-latest, ubuntu-20.04]
os: [macos-latest, ubuntu-22.04]
build_type: [Release, Debug]
shared_lib: [ON, OFF]
include:
# Run benchmarks quickly in Debug mode
- build_type: Debug
benchmark_min_time: "--benchmark_min_time=0.001"
- build_type: Release
benchmark_min_time: ""
exclude: # Skip debug on Mac. TODO: add Debug mode
- os: macos-latest
build_type: Debug
steps:
- uses: actions/checkout@v2
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.13.x'
- name: Default build
run: |
set -x
if [ "$RUNNER_OS" == "Linux" ]; then
export CC=clang-14
export CXX=clang++-14
fi
# Print information useful for debugging
whoami
echo $HOME
echo $GITHUB_WORKSPACE
echo "Testing from branch:"
echo $GITHUB_REFH
cmake --version
pwd
# Build library
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHEXL_SHARED_LIB=${{ matrix.shared_lib }} \
-DCMAKE_INSTALL_PREFIX=./
cmake --build build -j
cmake --build build --target install
cmake --build build --target unittest
# Instead of calling cmake --build build --target bench,
# we run the executable directly to pass command-line arguments
./build/benchmark/bench_hexl \
--benchmark_out="${GITHUB_WORKFLOW}_${GITHUB_SHA}" \
--benchmark_out_format=csv ${{ matrix.benchmark_min_time }}
# Build and run examples
cd $GITHUB_WORKSPACE/example/cmake
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
${{ env.HEXL_HINT_DIR }}
cmake --build build
build/example
# Build example using pkgconfig
cd $GITHUB_WORKSPACE/example/pkgconfig
# Set PKG_CONFIG_PATH to locate hexl.pc
export PKG_CONFIG_PATH=$GITHUB_WORKSPACE/lib/pkgconfig
cmake -S . -B build
cmake --build build
build/example
# Build example using vcpkg
# TODO: fix vcpkg example CI
# vcpkg install hexl --overlay-ports=$GITHUB_WORKSPACE/port/hexl/ --head
# cd $GITHUB_WORKSPACE/example/vcpkg
# vcpkg_toolchain=$(locate vcpkg.cmake)
# echo $vcpkg_toolchain
# cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=$vcpkg_toolchain
# cmake --build build
# build/example
# set +x
- name: Archive benchmark results
uses: actions/upload-artifact@v2
with:
name: bench_hexl_${{github.sha}}.csv
path: ${{ github.workspace }}/${{ github.workflow }}_${{ github.sha }}
retention-days: 90 # Maximum for free version
windows-build:
name: 'Windows ${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}'
runs-on: windows-latest
defaults:
run:
shell: bash
strategy:
matrix:
build_type: [Release, Debug]
# Shared lib in Windows requires exporting symbols
shared_lib: [OFF]
steps:
- uses: actions/checkout@v2
- name: Default build
run: |
set -x
# Build library
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX=./ \
-DHEXL_SHARED_LIB=${{ matrix.shared_lib }}
cmake --build build -j --config ${{ matrix.build_type}}
cmake --build build --target install --config ${{ matrix.build_type}}
cmake --build build --target unittest --config ${{ matrix.build_type}}
cmake --build build --target bench --config ${{ matrix.build_type}}
# Build and run examples
cd example/cmake
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type}} \
${{ env.HEXL_HINT_DIR }}
cmake --build build --config ${{ matrix.build_type}}
build/${{ matrix.build_type}}/example.exe
# TODO: add pkgconfig and vcpkg examples
experimental-build:
name: 'experimental: ${{ matrix.os }} ${{ matrix.build_type }} shared=${{ matrix.shared_lib }}'
runs-on: '${{ matrix.os }}'
defaults:
run:
shell: bash
strategy:
matrix:
# This is an unsupported experimental build - use at your own risk
#
# Ice-lake platform not available on github
# self-hosted platforms disabled by Intel github sys admin
# building on default ubuntu-20.04 platform
# os: [ice-lake]
os: [ubuntu-20.04]
build_type: [Release]
shared_lib: [ON]
steps:
- uses: actions/checkout@v2
- name: Default build
run: |
set -x
if [ "$RUNNER_OS" == "Linux" ]; then
export CC=clang-11
export CXX=clang++-11
fi
# Print information useful for debugging
whoami
echo $HOME
echo $GITHUB_WORKSPACE
echo "Testing from branch:"
echo $GITHUB_REFH
cmake --version
pwd
# Build library
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DHEXL_SHARED_LIB=${{ matrix.shared_lib }} \
-DCMAKE_INSTALL_PREFIX=./ \
-DHEXL_EXPERIMENTAL=ON
cmake --build build -j
cmake --build build --target install
cmake --build build --target unittest
# Instead of calling cmake --build build --target bench,
# we run the executable directly to pass command-line arguments
./build/benchmark/bench_hexl \
--benchmark_out="${GITHUB_WORKFLOW}_${GITHUB_SHA}" \
--benchmark_out_format=csv