Skip to content

Commit d39a5ab

Browse files
committed
Add "smoke test" sketch compilation CI workflow for MuxTO firmware
On every push and pull request that affects relevant files, and periodically, compile the Nano Every's MuxTO firmware sketch. The binary is saved as a workflow artifact to make it available for beta testers who might prefer flashing it directly over setting up the toolchain needed to compile it locally. Due to the standard output from Arduino CLI not providing the correct size data, a bespoke check is done for whether the compiled binary will fit in the available 12 kB of memory. If not, the workflow run fails. On creation or commit to a pull request, a report of the resulting change in memory usage of the sketch will be commented to the PR thread.
1 parent f21c25d commit d39a5ab

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

Diff for: .github/workflows/compile-muxto.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Compile MuxTO
2+
3+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/compile-muxto.yml"
8+
- "firmwares/MuxTO/**"
9+
pull_request:
10+
paths:
11+
- ".github/workflows/compile-muxto.yml"
12+
- "firmwares/MuxTO/**"
13+
schedule:
14+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
15+
- cron: "0 8 * * TUE"
16+
workflow_dispatch:
17+
repository_dispatch:
18+
19+
env:
20+
BINARY_FILENAME: MuxTO.ino.bin
21+
BINARY_ARTIFACT_NAME: MuxTO
22+
23+
jobs:
24+
build:
25+
name: Build firmware
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
fail-fast: false
30+
31+
matrix:
32+
board:
33+
- fqbn: arduino:samd:muxto:float=default,config=enabled,clock=internal_usb,timer=timer_732Hz,bootloader=4kb,serial=two_uart,usb=cdc
34+
platforms: |
35+
# Install MattairTech_Arduino:samd via Boards Manager for the toolchain
36+
- name: MattairTech_Arduino:samd
37+
source-url: https://www.mattairtech.com/software/arduino/package_MattairTech_index.json
38+
# This needs to match with the version of MattairTech_Arduino:samd the Arduino fork is based on in order to get the right tool versions
39+
version: 1.6.17
40+
# Install the platform with MuxTO support
41+
- name: arduino:samd
42+
source-url: https://github.com/arduino/ArduinoCore-samd.git
43+
version: muxto
44+
45+
steps:
46+
- name: Set environment variables
47+
run: |
48+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
49+
echo "BINARY_OUTPUT_PATH=${{ runner.temp }}/output" >> "$GITHUB_ENV"
50+
echo "SKETCHES_REPORTS_PATH=${{ runner.temp }}/sketches-reports" >> "$GITHUB_ENV"
51+
52+
- name: Checkout repository
53+
uses: actions/checkout@v2
54+
55+
- name: Compile firmware
56+
uses: arduino/compile-sketches@v1
57+
with:
58+
github-token: ${{ secrets.GITHUB_TOKEN }}
59+
fqbn: ${{ matrix.board.fqbn }}
60+
platforms: ${{ matrix.board.platforms }}
61+
libraries: |
62+
-
63+
sketch-paths: |
64+
- firmwares/MuxTO
65+
cli-compile-flags: |
66+
- --output-dir=${{ env.BINARY_OUTPUT_PATH }}
67+
enable-deltas-report: true
68+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
69+
70+
- name: Save firmware binary as workflow artifact
71+
uses: actions/upload-artifact@v2
72+
with:
73+
if-no-files-found: error
74+
path: ${{ env.BINARY_OUTPUT_PATH }}/${{ env.BINARY_FILENAME }}
75+
name: ${{ env.BINARY_ARTIFACT_NAME }}
76+
77+
- name: Save sketches report as workflow artifact
78+
uses: actions/upload-artifact@v2
79+
with:
80+
if-no-files-found: error
81+
path: ${{ env.SKETCHES_REPORTS_PATH }}
82+
name: sketches-reports
83+
84+
size:
85+
name: Check firmware size
86+
needs: build
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Download binary artifact
90+
uses: actions/download-artifact@v2
91+
with:
92+
name: ${{ env.BINARY_ARTIFACT_NAME }}
93+
94+
# The normal size check done by Arduino CLI is not working correctly, so it's necessary to check the size directly
95+
- name: Check firmware binary size
96+
run: |
97+
BINARY_SIZE="$(stat --printf="%s" "${{ github.workspace }}/${{ env.BINARY_FILENAME }}")"
98+
MAX_BINARY_SIZE=$((12 * 1024))
99+
echo "File size: ${BINARY_SIZE}/${MAX_BINARY_SIZE} B"
100+
if [[ $BINARY_SIZE -gt $MAX_BINARY_SIZE ]]; then
101+
echo "::error::Binary size of $BINARY_SIZE B exceeds the available memory ($MAX_BINARY_SIZE B)"
102+
exit 1
103+
fi

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Arduino Core for ATMEGA4809 CPU
22

3+
[![Compile MuxTO status](https://github.com/arduino/ArduinoCore-megaavr/actions/workflows/compile-muxto.yml/badge.svg)](https://github.com/arduino/ArduinoCore-megaavr/actions/workflows/compile-muxto.yml)
4+
35
This repository contains the source code and configuration files of the Arduino Core
46
for Microchip's ATMEGA4809 processor (used on the Arduino Uno WiFi Rev2 boards).
57

0 commit comments

Comments
 (0)