-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (109 loc) · 4.09 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
name: build-and-test
on: [push]
env:
CMAKE_VERSION: 3.29.2
NINJA_VERSION: 1.9.0
jobs:
build:
name: ${{ matrix.build_type }} build with ${{ matrix.compiler }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build_type: [ 'Debug', 'Release' ]
os: [ 'ubuntu-22.04' ]
compiler: [ 'gcc-14', 'clang-18' ]
steps:
- uses: actions/checkout@v4
- name: download ninja and cmake
id: cmake_and_ninja
shell: cmake -P {0}
run: |
set(cmake_version $ENV{CMAKE_VERSION})
set(ninja_version $ENV{NINJA_VERSION})
message(STATUS "Using host CMake version: ${CMAKE_VERSION}")
set(ninja_suffix "linux.zip")
set(cmake_suffix "linux-x86_64.tar.gz")
set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin")
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}")
file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip)
# Save the path for other steps
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir)
file(APPEND $ENV{GITHUB_OUTPUT} "cmake_dir=${cmake_dir}")
execute_process(
COMMAND chmod +x ninja
COMMAND chmod +x ${cmake_dir}/cmake
)
- name: install gcc-14
id: install_gcc_14
if: matrix.compiler == 'gcc-14'
shell: bash
working-directory: ${{ env.HOME }}
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update
sudo apt install -y g++-14 gcc-14
echo "CC=gcc-14" >> $GITHUB_ENV
echo "CXX=g++-14" >> $GITHUB_ENV
- name: install clang-18
id: install_clang_18
if: matrix.compiler == 'clang-18'
shell: bash
working-directory: ${{ env.HOME }}
run: |
curl -O -L https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
echo "CC=clang-18" >> $GITHUB_ENV
echo "CXX=clang++-18" >> $GITHUB_ENV
- name: configure
shell: cmake -P {0}
run: |
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}:$ENV{PATH}")
execute_process(
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake
-S .
-B build
-G Ninja
-DCMAKE_MAKE_PROGRAM=ninja
-DCMAKE_C_COMPILER=${{ env.CC }}
-DCMAKE_CXX_COMPILER=${{ env.CXX }}
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: build
shell: cmake -P {0}
continue-on-error: false
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}:$ENV{PATH}")
execute_process(
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/cmake --build build
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: run tests
shell: cmake -P {0}
continue-on-error: false
run: |
include(ProcessorCount)
ProcessorCount(N)
set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")
execute_process(
COMMAND ${{ steps.cmake_and_ninja.outputs.cmake_dir }}/ctest --verbose -j ${N}
WORKING_DIRECTORY build
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Running tests failed!")
endif()