-
Notifications
You must be signed in to change notification settings - Fork 38
199 lines (161 loc) · 5.71 KB
/
ci.yaml
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
name: CMake
on:
push:
pull_request:
release:
types: [ published ]
env:
BUILD_TYPE: Debug
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- build_single_header: OFF
- build_single_header: ON
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install dependencies
run: |
pip install gcovr
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DBUILD_SINGLE_HEADER=${{ matrix.build_single_header }} \
-DBUILD_EXAMPLES=true -DBUILD_TESTS=true -DTESTS_COV=ON
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C $BUILD_TYPE
- name: Coverage
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --build . --target coverage_xml
- name: Upload test logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testing-shl-${{ matrix.build_single_header }}
path: ${{github.workspace}}/build/Testing
- name: Upload coverage
if: ${{ matrix.build_single_header == 'OFF' }}
uses: actions/upload-artifact@v3
with:
name: coverage
path: ${{github.workspace}}/build/coverage_xml.xml
- name: Upload generated header
if: ${{ matrix.build_single_header == 'ON' }}
uses: actions/upload-artifact@v3
with:
name: single-header
path: ${{github.workspace}}/lib/shl/embedded_cli.h
- name: Upload coverage to codecov
if: ${{ matrix.build_single_header == 'OFF' }}
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/build/coverage_xml.xml
build-arduino-example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate single header lib
working-directory: ${{github.workspace}}/lib
run: python3 build-shl.py
- name: Copy single header file to sketch dir
run: cp ${{github.workspace}}/lib/shl/embedded_cli.h ${{github.workspace}}/examples/arduino-cli/embedded_cli.h
- name: Compile arduino sketch
uses: arduino/compile-sketches@v1
with:
sketch-paths: |
- examples/arduino-cli
build-win:
strategy:
fail-fast: false
matrix:
include:
- arch: x64
- arch: Win32
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
working-directory: ${{github.workspace}}/build
run: cmake -DBUILD_SINGLE_HEADER=ON -DBUILD_EXAMPLES=true -DBUILD_TESTS=true -G "Visual Studio 16 2019" -A ${{ matrix.arch }} ..
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --config Release
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C $BUILD_TYPE
- name: Upload test logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testing-win-${{ matrix.arch }}
path: ${{github.workspace}}/build/Testing
- name: Upload windows examples
uses: actions/upload-artifact@v3
with:
name: windows-example-${{ matrix.arch }}
path: ${{github.workspace}}/build/examples/win32-example/Release/embedded_cli_win32.exe
build-mac:
runs-on: macos-12
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLES=true -DBUILD_SINGLE_HEADER=ON -DBUILD_TESTS=true
- name: Build
working-directory: ${{github.workspace}}/build
run: cmake --build . --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C $BUILD_TYPE
- name: Upload test logs
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testing-mac
path: ${{github.workspace}}/build/Testing
add-release-assets:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [ build ]
steps:
- uses: actions/download-artifact@v2
with:
path: artifacts
- name: Display structure of downloaded files
working-directory: artifacts
run: ls -R
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: artifacts/single-header/embedded_cli.h
tag: ${{ github.ref }}
asset_name: embedded_cli.h
overwrite: true