Skip to content

Commit 705c5ba

Browse files
authored
Improve github workflow (#223)
* refactor: improve github workflow * doc: improve descriptions * feat: add caching based on all platform*.ini files
1 parent c399632 commit 705c5ba

File tree

3 files changed

+98
-43
lines changed

3 files changed

+98
-43
lines changed

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"cppcheck",
66
"doxyfile",
77
"graphviz",
8+
"libmicroros",
89
"mattnotmitt",
910
"mrad",
1011
"multirobot",

.github/workflows/main.yml

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
11
name: main
22

3-
# Controls when the action will run.
3+
concurrency:
4+
group: ci-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
# Controls when this workflow runs.
48
on:
59
push:
10+
# Runs on every push.
611
branches: [ '**' ]
12+
713
release:
8-
# A release, pre-release, or draft of a release is published.
14+
# Runs when a release, pre-release, or draft of a release is published.
915
types: [ published ]
10-
# Allows you to run this workflow manually from the Actions tab.
16+
17+
# Can be run manually from the Actions tab.
1118
workflow_dispatch:
1219

1320
# A workflow run is made up of one or more jobs that can run sequentially or in parallel.
1421
jobs:
15-
# The introduction just shows some useful informations.
22+
# Show some useful information.
1623
intro:
17-
# The type of runner that the job will run on.
1824
runs-on: ubuntu-24.04
19-
# Steps represent a sequence of tasks that will be executed as part of the job.
25+
2026
steps:
2127
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
2228
- run: echo "The name of the branch is ${{ github.ref }} and the repository is ${{ github.repository }}."
2329

24-
- name: Checkout repository
25-
uses: actions/checkout@v4
26-
27-
- name: Set up Python
28-
uses: actions/setup-python@v5
29-
with:
30-
python-version: '3.12.3'
31-
cache: 'pip'
32-
cache-dependency-path: .github/workflows/requirements.txt
33-
34-
- name: Install dependencies
35-
run: |
36-
pip install -r .github/workflows/requirements.txt
37-
38-
# Build all targets
30+
# Build all targets and perform static checks on them.
3931
build:
40-
# The type of runner that the job will run on.
4132
runs-on: ubuntu-24.04
4233
needs: intro
4334
strategy:
@@ -49,31 +40,39 @@ jobs:
4940
"SensorFusionTarget",
5041
"TurtleTarget"]
5142

52-
# Steps represent a sequence of tasks that will be executed as part of the job.
5343
steps:
5444
- name: Checkout repository
5545
uses: actions/checkout@v4
5646

5747
- name: Set up Python
58-
uses: actions/setup-python@v5
48+
uses: actions/setup-python@v6
5949
with:
6050
python-version: '3.12.3'
6151
cache: 'pip'
6252
cache-dependency-path: .github/workflows/requirements.txt
63-
53+
6454
- name: Install dependencies
6555
run: |
6656
pip install -r .github/workflows/requirements.txt
67-
68-
- name: Compile ${{ matrix.environment }} firmware
69-
run: platformio run --environment ${{ matrix.environment }}
7057
58+
- name: Cache PlatformIO
59+
uses: actions/cache@v4
60+
with:
61+
path: |
62+
~/.platformio/.cache
63+
~/.platformio/packages
64+
~/.platformio/platforms
65+
key: ${{ runner.os }}-pio-${{ hashFiles('platformio*.ini') }}
66+
67+
# Run cppcheck and clang-tidy.
7168
- name: Perform static checks on ${{ matrix.environment }}
72-
run: platformio check --environment ${{ matrix.environment }} --fail-on-defect=medium --fail-on-defect=high
69+
run: platformio check --environment ${{ matrix.environment }} # --fail-on-defect=medium --fail-on-defect=high
7370

74-
# Perform static checks and test
71+
- name: Compile ${{ matrix.environment }} firmware
72+
run: platformio run --environment ${{ matrix.environment }}
73+
74+
# Perform static checks on test.
7575
check:
76-
# The type of runner that the job will run on.
7776
runs-on: ubuntu-24.04
7877
needs: intro
7978
strategy:
@@ -85,22 +84,31 @@ jobs:
8584
uses: actions/checkout@v4
8685

8786
- name: Set up Python
88-
uses: actions/setup-python@v5
87+
uses: actions/setup-python@v6
8988
with:
9089
python-version: '3.12.3'
9190
cache: 'pip'
9291
cache-dependency-path: .github/workflows/requirements.txt
93-
92+
9493
- name: Install dependencies
9594
run: |
9695
pip install -r .github/workflows/requirements.txt
9796
97+
- name: Cache PlatformIO
98+
uses: actions/cache@v4
99+
with:
100+
path: |
101+
~/.platformio/.cache
102+
~/.platformio/packages
103+
~/.platformio/platforms
104+
key: ${{ runner.os }}-pio-${{ hashFiles('platformio*.ini') }}
105+
106+
# Run cppcheck and clang-tidy.
98107
- name: Perform static checks on ${{ matrix.environment }}
99-
run: platformio check --environment ${{ matrix.environment }} --fail-on-defect=medium --fail-on-defect=high
108+
run: platformio check --environment ${{ matrix.environment }} # --fail-on-defect=medium --fail-on-defect=high
100109

101-
# Perform tests
110+
# Perform tests.
102111
test:
103-
# The type of runner that the job will run on.
104112
runs-on: ubuntu-24.04
105113
needs: intro
106114

@@ -109,22 +117,30 @@ jobs:
109117
uses: actions/checkout@v4
110118

111119
- name: Set up Python
112-
uses: actions/setup-python@v5
120+
uses: actions/setup-python@v6
113121
with:
114122
python-version: '3.12.3'
115123
cache: 'pip'
116124
cache-dependency-path: .github/workflows/requirements.txt
117-
125+
118126
- name: Install dependencies
119127
run: |
120128
pip install -r .github/workflows/requirements.txt
121129
130+
- name: Cache PlatformIO
131+
uses: actions/cache@v4
132+
with:
133+
path: |
134+
~/.platformio/.cache
135+
~/.platformio/packages
136+
~/.platformio/platforms
137+
key: ${{ runner.os }}-pio-${{ hashFiles('platformio*.ini') }}
138+
122139
- name: Run tests on native environment
123140
run: platformio test --environment Test -vvv
124141

125-
# Build documentation
142+
# Build documentation.
126143
doc:
127-
# The type of runner that the job will run on.
128144
runs-on: ubuntu-24.04
129145
needs: intro
130146
strategy:
@@ -157,4 +173,4 @@ jobs:
157173

158174
- name: Print doxygen warnings
159175
if: ${{ failure() }}
160-
run: cat ./doc/doxygen/doxygen_warnings.txt
176+
run: cat ./doc/doxygen/doxygen_warnings.txt

platformio.ini

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ lib_ignore =
282282
${app:ConvoyLeader.lib_ignore}
283283
extra_scripts =
284284
${target:esp32.extra_scripts}
285+
check_src_filters =
286+
+<*>
287+
-<lib/libmicroros/>
285288

286289
; *****************************************************************************
287290
; Convoy leader application on simulation
@@ -299,6 +302,9 @@ lib_ignore =
299302
${app:ConvoyLeader.lib_ignore}
300303
extra_scripts =
301304
${target:Sim.extra_scripts}
305+
check_src_filters =
306+
+<*>
307+
-<lib/libmicroros/>
302308

303309
; *****************************************************************************
304310
; Convoy follower application on target
@@ -316,6 +322,9 @@ lib_ignore =
316322
${app:ConvoyFollower.lib_ignore}
317323
extra_scripts =
318324
${target:esp32.extra_scripts}
325+
check_src_filters =
326+
+<*>
327+
-<lib/libmicroros/>
319328

320329
; *****************************************************************************
321330
; Convoy follower application on simulation
@@ -333,6 +342,9 @@ lib_ignore =
333342
${app:ConvoyFollower.lib_ignore}
334343
extra_scripts =
335344
${target:Sim.extra_scripts}
345+
check_src_filters =
346+
+<*>
347+
-<lib/libmicroros/>
336348

337349
; *****************************************************************************
338350
; Line follower application on simulation
@@ -350,6 +362,9 @@ lib_ignore =
350362
${app:LineFollower.lib_ignore}
351363
extra_scripts =
352364
${target:Sim.extra_scripts}
365+
check_src_filters =
366+
+<*>
367+
-<lib/libmicroros/>
353368

354369
; *****************************************************************************
355370
; Line follower application on target
@@ -367,6 +382,9 @@ lib_ignore =
367382
${app:LineFollower.lib_ignore}
368383
extra_scripts =
369384
${target:esp32.extra_scripts}
385+
check_src_filters =
386+
+<*>
387+
-<lib/libmicroros/>
370388

371389
; *****************************************************************************
372390
; Remote Control application on simulation
@@ -384,6 +402,9 @@ lib_ignore =
384402
${app:RemoteControl.lib_ignore}
385403
extra_scripts =
386404
${target:Sim.extra_scripts}
405+
check_src_filters =
406+
+<*>
407+
-<lib/libmicroros/>
387408

388409
; *****************************************************************************
389410
; Remote Control application on target
@@ -401,6 +422,9 @@ lib_ignore =
401422
${app:RemoteControl.lib_ignore}
402423
extra_scripts =
403424
${target:esp32.extra_scripts}
425+
check_src_filters =
426+
+<*>
427+
-<lib/libmicroros/>
404428

405429
; *****************************************************************************
406430
; Sensor Fusion application on simulation
@@ -420,6 +444,9 @@ lib_ignore =
420444
extra_scripts =
421445
${target:Sim.extra_scripts}
422446
lib_compat_mode = off
447+
check_src_filters =
448+
+<*>
449+
-<lib/libmicroros/>
423450

424451
; *****************************************************************************
425452
; Sensor Fusion application on target
@@ -438,6 +465,9 @@ lib_ignore =
438465
${app:SensorFusion.lib_ignore}
439466
extra_scripts =
440467
${target:esp32.extra_scripts}
468+
check_src_filters =
469+
+<*>
470+
-<lib/libmicroros/>
441471

442472
; *****************************************************************************
443473
; PC target environment for tests
@@ -455,6 +485,9 @@ lib_ignore =
455485
${app:Test.lib_ignore}
456486
extra_scripts =
457487
${target:Test.extra_scripts}
488+
check_src_filters =
489+
+<*>
490+
-<lib/libmicroros/>
458491

459492
; *****************************************************************************
460493
; Turtle application on target
@@ -475,7 +508,9 @@ lib_ignore =
475508
libmicroros
476509
extra_scripts =
477510
${target:esp32.extra_scripts}
478-
511+
check_src_filters =
512+
+<*>
513+
-<lib/libmicroros/>
479514

480515
; *****************************************************************************
481516
; Turtle application on simulation
@@ -498,4 +533,7 @@ lib_ignore =
498533
${target:Sim.lib_ignore}
499534
${app:Turtle.lib_ignore}
500535
extra_scripts =
501-
${target:Sim.extra_scripts}
536+
${target:Sim.extra_scripts}
537+
check_src_filters =
538+
+<*>
539+
-<lib/libmicroros/>

0 commit comments

Comments
 (0)