-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (137 loc) · 6.47 KB
/
cmake.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
name: CI Linux
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: ${{ matrix.name }} ${{ matrix.build_type }}
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.os }}
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: ${{ matrix.build_type }}
CTEST_OUTPUT_ON_FAILURE: ON
CLANG_DEFAULT: 13
strategy:
fail-fast: false
matrix:
name: [
ubuntu-latest-gcc-12,
ubuntu-20.04-clang-13,
ubuntu-22.04-clang-14,
ubuntu-22.04-clang-15,
mac-os-latest
]
build_type: [Debug, Release]
include:
- name: ubuntu-latest-gcc-12
os: ubuntu-latest
compiler: gcc
version: "12"
- name: ubuntu-20.04-clang-13
os: ubuntu-20.04
compiler: clang
version: "13"
- name: ubuntu-22.04-clang-14
os: ubuntu-22.04
compiler: clang
version: "14"
- name: ubuntu-22.04-clang-15
os: ubuntu-22.04
compiler: clang
version: "15"
- name: mac-os-latest
os: macos-latest
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
if [ "${{ runner.os }}" = "Linux" ]; then
# Workaround https://github.com/actions/runner-images/issues/8659
echo "matrix.name=${{ matrix.name }}"
echo "matrix.os=${{ matrix.os }}"
if [[ "${{ matrix.name }}" = "ubuntu-22.04-clang-14" ]] || [[ "${{ matrix.os }}" = "ubuntu-latest" ]] ; then
echo "Workaround for https://github.com/actions/runner-images/issues/8659"
sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades libc6=2.35-0ubuntu3.4 \
libc6-dev=2.35-0ubuntu3.4 \
libstdc++6=12.3.0-1ubuntu1~22.04 \
libgcc-s1=12.3.0-1ubuntu1~22.04
fi
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
# Figure out which version of ubuntu is actually running
export $(cat /etc/os-release | grep UBUNTU_CODENAME)
# If clang is being used to compile, use the specified version, otherwise, use the default version
export CLANG_VERSION=$([ "${{ matrix.compiler }}" = "clang" ] && echo "${{ matrix.version }}" || echo $CLANG_DEFAULT )
sudo add-apt-repository --yes --update \
"deb http://apt.llvm.org/$UBUNTU_CODENAME/ llvm-toolchain-$UBUNTU_CODENAME-$CLANG_VERSION main"
sudo add-apt-repository --yes --update ppa:ubuntu-toolchain-r/test
sudo apt-get -y update
sudo apt-get install -y build-essential ninja-build #g++ #python-is-python3
if [ "${{ matrix.compiler }}" = "gcc" ]; then
sudo apt-get install -y gcc-${{ matrix.version }} g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib
#sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} ${{ matrix.version }}0 \
--slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.version }}
gcc --version
g++ --version
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
else
sudo apt-get install -y clang-${{ matrix.version }} g++-multilib
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi
# Always install and link clang-tidy as they will be used during the build
sudo apt-get install -y clang-format-$CLANG_VERSION clang-tidy-$CLANG_VERSION
sudo ln -fs /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format
ls -alh `which clang-format`
clang-format --version
sudo ln -fs /usr/bin/clang-tidy-$CLANG_VERSION /usr/bin/clang-tidy
ls -alh `which clang-tidy`
clang-tidy --version
elif [ "${{ runner.os }}" = "macOS" ]; then
brew install ninja
clang --version
clang++ --version
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
fi
shell: bash
# This must happen before the "Configure CMake" step otherwise the python version used to compile
# will be different than the one installed here.
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCFG_EXAMPLES=ON -DCFG_PYTHON_BINDINGS=ON -G Ninja
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
ctest -C ${{env.BUILD_TYPE}}
${{github.workspace}}/build/src/include_file_test
for i in `seq 1 14`; do
${{github.workspace}}/build/src/config_build ${{github.workspace}}/examples/config_example$i.cfg
done
- name: Run python tests
run: |
pushd ${{github.workspace}}/build/python
EXAMPLES_DIR=${{github.workspace}}/examples python3 -m pytest ${{github.workspace}}/python
popd