7
7
branches : [ master ]
8
8
9
9
jobs :
10
- validate_library : # job id
10
+ check_dockerfile_changed :
11
11
runs-on : ubuntu-latest
12
+ outputs :
13
+ changed : ${{ steps.filter.outputs.changed }}
14
+
12
15
steps :
13
- - name : Checkout Code
14
- id : checkout
16
+ - name : Checkout code
15
17
uses : actions/checkout@v3
16
- - name : Run Tests In Container
17
- id : containerized_tests
18
- uses : ./.github/actions/run-tests-in-container
19
- - name : Coveralls Action Bug Workaround
20
- id : coveralls_bug_workaround
21
- run : sudo sed -i 's/github\/workspace/home\/runner\/work\/note-arduino\/note-arduino/g' ./coverage/lcov.info
22
- - name : Publish Test Coverage
23
- id : publish_coverage
18
+
19
+ # TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
20
+ # use something more "official".
21
+ - name : Check if Dockerfile changed
22
+ uses : dorny/paths-filter@v2
23
+ id : filter
24
+ with :
25
+ base : ' master'
26
+ filters : |
27
+ changed:
28
+ - 'Dockerfile'
29
+ build_ci_docker_image :
30
+ runs-on : ubuntu-latest
31
+ needs : [check_dockerfile_changed]
32
+ if : ${{ needs.check_dockerfile_changed.outputs.changed == 'true' }}
33
+
34
+ steps :
35
+ - name : Checkout code
36
+ uses : actions/checkout@v3
37
+
38
+ - name : Login to GitHub Container Registry
39
+ uses : docker/login-action@v2
40
+ with :
41
+ registry : ghcr.io
42
+ username : ${{ github.actor }}
43
+ password : ${{ secrets.GITHUB_TOKEN }}
44
+
45
+ - name : Set up Docker Buildx
46
+ uses : docker/setup-buildx-action@v2
47
+
48
+ - name : Rebuild image
49
+ uses : docker/build-push-action@v4
50
+ with :
51
+ context : .
52
+ load : true
53
+ tags : ghcr.io/blues/note_arduino_ci:latest
54
+ outputs : type=docker,dest=/tmp/note_arduino_ci_image.tar
55
+
56
+ - name : Upload image artifact
57
+ uses : actions/upload-artifact@v3
58
+ with :
59
+ name : note_arduino_ci_image
60
+ path : /tmp/note_arduino_ci_image.tar
61
+
62
+ run_tests :
63
+ runs-on : ubuntu-latest
64
+ if : ${{ always() }}
65
+ needs : [build_ci_docker_image]
66
+
67
+ steps :
68
+ - name : Checkout code
69
+ uses : actions/checkout@v3
70
+
71
+ - name : Load CI Docker image
72
+ if : ${{ needs.build_ci_docker_image.result == 'success' }}
73
+ uses : ./.github/actions/load-ci-image
74
+
75
+ - name : Run tests
76
+ run : |
77
+ docker run --rm --volume $(pwd):/note-arduino/ \
78
+ --workdir /note-arduino/ \
79
+ --entrypoint ./test/run_all_tests.sh \
80
+ ghcr.io/blues/note_arduino_ci:latest
81
+
82
+ - name : Adjust lcov source file paths for Coveralls
83
+ run : sudo sed -i 's/\/note-arduino\///g' ./coverage/lcov.info
84
+
85
+ - name : Publish test coverage
24
86
uses : coverallsapp/github-action@master
25
87
with :
26
88
github-token : ${{ secrets.GITHUB_TOKEN }}
27
- validate_examples : # job id
89
+ path-to-lcov : ./coverage/lcov.info
90
+
91
+ build_examples :
28
92
runs-on : ubuntu-latest
93
+ if : ${{ always() }}
94
+ needs : [build_ci_docker_image]
29
95
continue-on-error : true
30
96
strategy :
31
97
matrix :
38
104
- ./examples/Example5_UsingTemplates/Example5_UsingTemplates.ino
39
105
- ./examples/Example6_SensorTutorial/Example6_SensorTutorial.ino
40
106
- ./examples/Example7_PowerControl/Example7_PowerControl.ino
41
- - ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino
42
- - ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino
107
+ # TODO: Uncomment these once note-c is updated with the necessary NoteBinary* functions.
108
+ # - ./examples/Example8_BinarySendReceive/Example8_BinarySendReceive.ino
109
+ # - ./examples/Example9_BinarySendReceiveChunked/Example9_BinarySendReceiveChunked.ino
43
110
fully-qualified-board-name :
44
111
- STMicroelectronics:stm32:BluesW:pnum=SWAN_R5
45
112
- esp32:esp32:featheresp32
@@ -51,13 +118,45 @@ jobs:
51
118
- adafruit:nrf52:feather52840:softdevice=s140v6
52
119
- rp2040:rp2040:rpipico
53
120
- arduino:avr:uno
121
+
54
122
steps :
55
- - name : Checkout Code
123
+ - name : Checkout code
56
124
id : checkout
57
125
uses : actions/checkout@v3
126
+
127
+ - name : Load CI docker image
128
+ if : ${{ needs.build_ci_docker_image.result == 'success' }}
129
+ uses : ./.github/actions/load-ci-image
130
+
58
131
- name : Compile Examples
59
- id : compile_examples
60
- uses : ./.github/actions/compile-examples
132
+ run : |
133
+ docker run --rm --volume $(pwd):/note-arduino/ \
134
+ --workdir /note-arduino/ \
135
+ --entrypoint ./examples/build_example.sh \
136
+ ghcr.io/blues/note_arduino_ci:latest \
137
+ ${{ matrix.fully-qualified-board-name }} \
138
+ ${{ matrix.example-sketch }}
139
+
140
+ publish_ci_image :
141
+ runs-on : ubuntu-latest
142
+ # Make sure tests passed and examples built successfully before publishing.
143
+ needs : [build_ci_docker_image, run_tests, build_examples]
144
+ # Only publish the image if this is a push event and the Docker image was rebuilt.
145
+ if : ${{ github.event_name == 'push' && needs.build_ci_docker_image.result == 'success' }}
146
+
147
+ steps :
148
+ - name : Login to GitHub Container Registry
149
+ uses : docker/login-action@v2
150
+ with :
151
+ registry : ghcr.io
152
+ username : ${{ github.actor }}
153
+ password : ${{ secrets.GITHUB_TOKEN }}
154
+
155
+ - name : Set up Docker Buildx
156
+ uses : docker/setup-buildx-action@v2
157
+
158
+ - name : Push image to registry
159
+ uses : docker/build-push-action@v4
61
160
with :
62
- example-sketch : ${{ matrix.example-sketch }}
63
- fully-qualified-board-name : ${{ matrix.fully-qualified-board-name }}
161
+ push : true
162
+ tags : ghcr.io/blues/note_arduino_ci:latest
0 commit comments