-
Notifications
You must be signed in to change notification settings - Fork 11
221 lines (215 loc) · 7.6 KB
/
main.yml
File metadata and controls
221 lines (215 loc) · 7.6 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Main Workflow
on: [ push, pull_request ]
env:
LLVM_VERSION: 19
jobs:
debug:
if: github.event_name == 'push'
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts24.4.3
strategy:
matrix:
toolchain: [ "clang", "gcc" ]
include:
- toolchain: gcc
c-compiler: gcc
cxx-compiler: g++
- toolchain: clang
c-compiler: clang
cxx-compiler: clang++
steps:
- uses: actions/checkout@v4
with:
submodules: true
# language=bash
- run: >
cmake
-B $GITHUB_WORKSPACE/build
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
.
# language=bash
- run: |
cd $GITHUB_WORKSPACE/build
make VERBOSE=1 -j$(nproc)
make test ARGS="--verbose"
- name: Archive workspace
if: always()
run: |
cd $GITHUB_WORKSPACE
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
- uses: actions/upload-artifact@v4
if: always()
with:
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
# Shall it break one day, feel free to remove the matrix from here.
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
path: ${{runner.temp}}/workspace.tar.gz
retention-days: 2
optimizations:
if: github.event_name == 'push'
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts24.4.3
strategy:
matrix:
toolchain: [ "clang", "gcc" ]
build_type: [ Release, MinSizeRel ]
include:
- toolchain: gcc
c-compiler: gcc
cxx-compiler: g++
cxx-flags: ""
- toolchain: clang
c-compiler: clang
cxx-compiler: clang++
steps:
- uses: actions/checkout@v4
with:
submodules: true
# language=bash
- run: >
cmake
-B $GITHUB_WORKSPACE/build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx-flags }}"
-DNO_STATIC_ANALYSIS=1
.
# language=bash
- run: |
cd $GITHUB_WORKSPACE/build
make VERBOSE=1 -j$(nproc)
make test ARGS="--verbose"
- name: Archive workspace
if: always()
run: |
cd $GITHUB_WORKSPACE
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
- uses: actions/upload-artifact@v4
if: always()
with:
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
# Shall it break one day, feel free to remove the matrix from here.
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
path: ${{runner.temp}}/workspace.tar.gz
retention-days: 2
coverage:
if: github.event_name == 'push'
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts24.4.3
steps:
- uses: actions/checkout@v4
with:
submodules: true
# language=bash
- run: >
cmake -B $GITHUB_WORKSPACE/build -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=ON -DENABLE_COVERAGE=ON .
# language=bash
- run: |
cd $GITHUB_WORKSPACE/build
make -j$(nproc) && make test && make coverage
- name: Archive workspace
if: always()
run: |
cd $GITHUB_WORKSPACE
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}
path: ${{runner.temp}}/workspace.tar.gz
retention-days: 30
# TODO: re-enable this
# avr:
# if: github.event_name == 'push'
# runs-on: ubuntu-latest
# env:
# mcu: at90can64
# flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits
# strategy:
# matrix:
# std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
# steps:
# - uses: actions/checkout@v4
# # language=bash
# - run: |
# sudo apt update -y && sudo apt upgrade -y
# sudo apt install gcc-avr avr-libc
# avr-gcc --version
# - run: avr-gcc -Ilib/cavl/ libudpard/*.c -c -std=${{matrix.std}} -mmcu=${{env.mcu}} ${{env.flags}}
arm:
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits -Wcast-align -Wfatal-errors
strategy:
matrix:
std: [ "c99", "c11", "gnu99", "gnu11" ]
steps:
- uses: actions/checkout@v4
# language=bash
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt-get install -y gcc-arm-none-eabi
- run: arm-none-eabi-gcc -Ilib/cavl/ libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }}
sonar:
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts24.4.3
if: >
(
(github.event_name == 'pull_request' || contains(github.ref, '/main') || contains(github.ref, '/release')) &&
!contains(github.event.head_commit.message, '#yolo')
) || (
contains(github.event.head_commit.message, '#sonar')
)
env:
SONAR_SCANNER_VERSION: 5.0.1.3006
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: true
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: "zulu"
# language=bash
- run: |
clang --version
- name: Install Sonar tools
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
BUILD_WRAPPER_DOWNLOAD_URL: https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
# language=bash
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
# Sonar is not run on builds originating from forks due to secrets not being available (avoids errors).
# language=bash
- run: |
[ -z "$SONAR_TOKEN" ] || tools/run_sonar.sh
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{github.job}}
path: ${{github.workspace}}/
retention-days: 3
style_check:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.20
with:
source: "./libudpard ./tests"
extensions: "c,h,cpp,hpp"
clangFormatVersion: ${{ env.LLVM_VERSION }}