Repository navigation
144 lines (124 loc) · 4.98 KB
/
Copy pathcmake-multi-platform.yml
File metadata and controls
144 lines (124 loc) · 4.98 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
name: CMake on multiple platforms
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
types: [ "opened", "reopened", "synchronize", "ready_for_review" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# ensure we don't stop after 1 failure to always have a complete picture of what is failing
fail-fast: false
# Set up a matrix to run the following configurations:
# - ubuntu Debug/Release clang/gcc
# - windows Debug/Release cl
# - macos Debug/Release clang
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
build_type: [Release, Debug]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc
steps:
- uses: actions/checkout@v7
- name: Set Env
shell: bash
run: |
echo "BUILD_OUTPUT_DIR=${{ github.workspace }}/build" >> "$GITHUB_ENV"
- name: VCPKG Install (Windows)
if: runner.os == 'Windows'
uses: ./.github/workflows/windows-vcpkg
with:
key: vcpkg-cache-${{ runner.os }}
- 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 ${{ env.BUILD_OUTPUT_DIR }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCPPSOCKETS_TESTS=TRUE
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed
# because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ env.BUILD_OUTPUT_DIR }} --config ${{ matrix.build_type }}
- name: Upload Compile Commands
uses: actions/upload-artifact@v7
if: matrix.os == 'ubuntu-latest' && matrix.build_type == 'Release' && matrix.c_compiler == 'clang'
with:
name: compile_commands.json
path: ${{ env.BUILD_OUTPUT_DIR }}/compile_commands.json
archive: false
- name: Upload CppSockets lib
uses: actions/upload-artifact@v6
with:
name: libcppsockets-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
path: "${{ env.BUILD_OUTPUT_DIR }}/**/libcppsockets.*"
- name: Upload UnitTests
uses: actions/upload-artifact@v6
if: matrix.os != 'windows-latest'
with:
name: unit_tests-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
path: "${{ env.BUILD_OUTPUT_DIR }}/tests/**/unit_tests*"
- name: Upload UnitTests
uses: actions/upload-artifact@v6
if: matrix.os == 'windows-latest'
with:
name: unit_tests-${{ runner.os }}-${{ matrix.c_compiler }}-${{ matrix.build_type }}
path: |
${{ env.BUILD_OUTPUT_DIR }}/tests/**/unit_tests*
${{ env.BUILD_OUTPUT_DIR }}/tests/**/*.dll
- name: Setup DLL PATH (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
echo "$VCPKG_ROOT/installed/x64-windows/bin" >> "$GITHUB_PATH"
echo "$BUILD_OUTPUT_DIR/${{ matrix.build_type }}" >> "$GITHUB_PATH"
- name: Test
working-directory: ${{ env.BUILD_OUTPUT_DIR }}
# 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: ctest --timeout 60 --build-config ${{ matrix.build_type }} --test-dir tests --output-on-failure
clang-tidy:
needs: 'build'
runs-on: ubuntu-latest
if: always() && github.event_name == 'pull_request'
steps:
- name: Checkout Code
uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: compile_commands.json
- name: clang-tidy review
uses: ZedThree/clang-tidy-review@v0.21.0
# If there are any comments, fail the check
- if: steps.review.outputs.total_comments > 0
run: exit 1