-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (155 loc) · 6.92 KB
/
cmake-multi-platform.yml
File metadata and controls
171 lines (155 loc) · 6.92 KB
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
name: CMake on multiple platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Tests, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Tests, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Tests, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, etc.) customize the build_type list.
matrix:
build_type: [Debug]
# os: [windows-latest, ubuntu-latest, macos-latest]
# os: [ubuntu-latest, macos-latest]
os: [windows-latest]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
runExecutable: .\Debug\Connection_Machine_tests.exe
- os: ubuntu-latest
c_compiler: gcc-14
cpp_compiler: g++-14
runExecutable: ./Connection_Machine_tests
# - os: ubuntu-latest
# c_compiler: clang
# cpp_compiler: clang++
# runExecutable: ./Connection_Machine_tests
# - os: macos-latest
# c_compiler: clang
# cpp_compiler: clang++
# runExecutable: ./Connection Machine_tests
steps:
- uses: actions/checkout@v4
- name: Cache CMake dependency source code
uses: actions/cache@v4
env:
cache-name: cache-cmake-dependency-sources
with:
# CMake cache is at ${{github.workspace}}/build/_deps but we only will cache folders ending in '-src' to cache source code
path: ${{github.workspace}}/build/_deps/*-src
# Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
# it's acceptable to reuse caches for different CMakeLists content if exact match is not available and unlike build caches, we
# don't need to restrict these by OS or compiler as it's only source code that's being cached
restore-keys: |
${{ env.cache-name }}-
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential git make pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libfribidi-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev
sudo apt-get install -y python3-pip
pip install --upgrade gcovr # gets latest (8.x)
- name: Cache CMake dependency build objects
uses: actions/cache@v4
env:
cache-name: cache-cmake-dependency-builds
with:
# CMake cache is at ${{github.workspace}}/build/_deps but we only care about the folders ending in -build or -subbuild
path: |
${{github.workspace}}/build/_deps/*-build
${{github.workspace}}/build/_deps/*-subbuild
# Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}
# it's acceptable to reuse caches for different CMakeLists content if exact match is not available
# as long as the OS and Compiler match exactly
restore-keys: |
${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-
- name: Check coverage tool versions
if: success() && matrix.os == 'ubuntu-latest'
run: |
which gcc || true
which g++ || true
which gcov || true
which gcc-14 || true
which g++-14 || true
which gcov-14 || true
gcc-14 --version || true
gcov-14 --version || true
gcovr --version || true
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@v1.2
with:
version: 1.4.309.0
cache: true
- name: Build with CMake
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
cc: ${{ matrix.c_compiler }}
cxx: ${{ matrix.cpp_compiler }}
configure-options: "-DCONNECTION_MACHINE_BUILD_TESTS=ON -DCONNECTION_MACHINE_CODE_COVERAGE=ON -DCONNECTION_MACHINE_BUILD_APP=OFF -DCONNECTION_MACHINE_BUILD_CLI_APP=OFF"
target: Connection_Machine_tests
build-type: ${{ matrix.build_type }}
- name: List files
run: ls ${{ github.workspace }}/build
- name: Test
id: run_tests
working-directory: ${{ github.workspace }}/build
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ${{ matrix.runExecutable }}
# run: Gatality_tests
- name: Coverage Report
if: success() && matrix.os == 'ubuntu-latest'
working-directory: ${{ github.workspace }}
run: |
bash gcov_coverage.sh
mv ./coverage/coverage.html ./coverage/index.html
ls ./coverage
# Publish the coverage folder as the Pages artifact (ubuntu job only)
- name: Upload Pages artifact (coverage/)
if: success() && matrix.os == 'ubuntu-latest'
uses: actions/upload-pages-artifact@v3
with:
path: coverage
# optional: name: coverage-artifact
- name: Notify Discord on test failure
if: failure()
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: failure
title: Tests failed on ${{ matrix.os }}
description: Build type ${{ matrix.build_type }}
color: 0xff0000
# Deploy only after the matrix completes; it will pick up the uploaded artifact
deploy:
needs: build
if: always() && needs.build.result == 'success' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4