-
Notifications
You must be signed in to change notification settings - Fork 4
88 lines (74 loc) · 2.32 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# generate the build matrix
gen_matrix:
runs-on: ubuntu-latest
outputs:
examples_matrix: ${{ steps.gen_matrix.outputs.matrix }}
steps:
# checkout the repository
- uses: actions/checkout@v4
# generate the build matrix, containing all subdirectories in the 'examples' directory
# that contain a 'platformio.ini' file
- name: Generate build matrix
id: gen_matrix
run: |
# Get all subdirectories containing platformio.ini in the ./example directory
subdirectories=$(find ./examples -type f -name "platformio.ini" -exec dirname {} \; | sort -u)
# Convert subdirectories to JSON array
json_array="["
for subdir in $subdirectories; do
json_array+="\"$subdir\", "
done
json_array="${json_array%, }]"
echo "$json_array"
echo "matrix=$json_array" >> $GITHUB_OUTPUT
# build the CI environment in all examples
build:
runs-on: ubuntu-latest
needs: gen_matrix
# run all examples in a matrix
strategy:
fail-fast: false
matrix:
example: ${{ fromJson(needs.gen_matrix.outputs.examples_matrix) }}
steps:
# checkout the repository
- uses: actions/checkout@v4
# enable caching of pip and platformio
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
# install python
- uses: actions/setup-python@v5
with:
python-version: '3.9'
# install platformio
- name: Install PlatformIO core
run: pip install --upgrade platformio
# print the platformio.ini file path
- name: Print matrix value for 'example'
run: echo ${{ matrix.example }}
# build the 'CI' environment
- name: Build 'ci' environment
run: pio run --project-dir ${{ matrix.example }} --environment ci
# dummy job after all examples were build
all_build:
runs-on: ubuntu-latest
needs: [build]
if: always()
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}