-
Notifications
You must be signed in to change notification settings - Fork 6
164 lines (140 loc) · 5.51 KB
/
note-arduino-ci.yml
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
name: Note Arduino CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
check_dockerfile_changed:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout code
uses: actions/checkout@v3
# TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
# use something more "official".
- name: Check if Dockerfile changed
uses: dorny/paths-filter@v2
id: filter
with:
base: 'master'
filters: |
changed:
- 'Dockerfile'
build_ci_docker_image:
runs-on: ubuntu-latest
needs: [check_dockerfile_changed]
if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Rebuild image
uses: docker/build-push-action@v4
with:
context: .
load: true
tags: ghcr.io/blues/note_arduino_ci:latest
outputs: type=docker,dest=/tmp/note_arduino_ci_image.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: note_arduino_ci_image
path: /tmp/note_arduino_ci_image.tar
run_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Load CI Docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run tests
run: |
docker run --rm --volume $(pwd):/note-arduino/ \
--workdir /note-arduino/ \
--entrypoint ./test/run_all_tests.sh \
--user root \
ghcr.io/blues/note_arduino_ci:latest
- name: Adjust lcov source file paths for Coveralls
run: sudo sed -i 's/\/note-arduino\///g' ./coverage/lcov.info
- name: Publish test coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
build_examples:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
strategy:
fail-fast: false
matrix:
example-sketch:
- ./examples/Example0_LibrarylessCommunication/Example0_LibrarylessCommunication.ino
- ./examples/Example1_NotecardBasics/Example1_NotecardBasics.ino
- ./examples/Example2_PeriodicCommunications/Example2_PeriodicCommunications.ino
- ./examples/Example3_InboundPolling/Example3_InboundPolling.ino
- ./examples/Example4_InboundInterrupts/Example4_InboundInterrupts.ino
- ./examples/Example5_UsingTemplates/Example5_UsingTemplates.ino
- ./examples/Example6_SensorTutorial/Example6_SensorTutorial.ino
- ./examples/Example7_PowerControl/Example7_PowerControl.ino
- ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino
- ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino
fully-qualified-board-name:
- adafruit:nrf52:feather52840:softdevice=s140v6
- adafruit:samd:adafruit_feather_m4
# The binary examples don't fit in the Uno's flash.
# - arduino:avr:uno
- arduino:mbed_nano:nano33ble
- esp32:esp32:featheresp32
- rp2040:rp2040:rpipico
- SparkFun:apollo3:sfe_artemis_thing_plus
- STMicroelectronics:stm32:BluesW:pnum=SWAN_R5
- STMicroelectronics:stm32:GenF4:pnum=FEATHER_F405
- STMicroelectronics:stm32:Nucleo_32:pnum=NUCLEO_L432KC
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v3
- name: Load CI docker image
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Compile Examples
run: |
docker run --rm --volume $(pwd):/note-arduino/ \
--workdir /note-arduino/ \
--entrypoint ./examples/build_example.sh \
ghcr.io/blues/note_arduino_ci:latest \
${{ matrix.fully-qualified-board-name }} \
${{ matrix.example-sketch }}
publish_ci_image:
runs-on: ubuntu-latest
# Make sure tests passed and examples built successfully before publishing.
needs: [build_ci_docker_image, run_tests, build_examples]
# Only publish the image if this is a push event and the Docker image was rebuilt.
if: ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }}
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Push image to registry
uses: docker/build-push-action@v4
with:
push: true
tags: ghcr.io/blues/note_arduino_ci:latest