Skip to content

Compile Tests

Compile Tests #21

Workflow file for this run

# This is the name of the workflow, visible on GitHub UI.
name: 'Compile Tests'
#description: 'Run the Arduino CLI to compile example sketches and check if compiles fine for multiple boards'
#author: 'Jorge Rivera'
# Controls when the action will run.
# Here we tell GitHub to run the workflow when a commit.
on:
# Triggers the workflow on push or pull request events
push:
paths:
- '*.h'
- '*.cpp'
- '**.ino'
- '.github/workflows/*.yml'
pull_request:
paths:
- '*.h'
- '*.cpp'
- '**.ino'
- '.github/workflows/*.yml'
schedule:
- cron: '0 0 1 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# This is the list of jobs that will be run concurrently.
# Since we use a build matrix, the actual number of jobs
# started depends on how many configurations the matrix
# will produce.
jobs:
boards:
# This is the name of the job
name: "Compile test for ${{ matrix.config.board }}"
# This is the platform GitHub will use to run our workflow
runs-on: ubuntu-latest
# Here we tell GitHub that the jobs must be determined
# dynamically depending on a matrix configuration.
strategy:
# Set to false so that GitHub does not cancel all jobs
# in progress if any array job fails.
fail-fast: false
# The matrix will produce one job for each configuration:
matrix:
config:
- board: "Arduino Nano"
fqbn: "arduino:avr:nano"
platform: "arduino:avr"
- board: "ESP8266 NodeMCUv2"
fqbn: "esp8266:esp8266:d1_mini"
platform: "esp8266:esp8266"
additional-url: "--additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json"
- board: "ESP8266 Wemos D1 Mini (@2.7.4)"
fqbn: "esp8266:esp8266:nodemcuv2"
platform: "esp8266:esp8266@2.7.4"
additional-url: "--additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json"
- board: "ESP32 NodeMCU-32S"
fqbn: "esp32:esp32:nodemcu-32s"
platform: "esp32:esp32"
additional-url: "--additional-urls https://dl.espressif.com/dl/package_esp32_index.json"
# This is the list of steps this job will run.
steps:
# We use the "arduino/setup-arduino-cli" action to install and
# configure the Arduino CLI on the system.
- name: Setup Arduino CLI
uses: arduino/setup-arduino-cli@v1.1.1
# We then install the platform, which one will be determined
# dynamically by the build matrix.
- name: Install platform ${{ matrix.config.platform }}
run: |
arduino-cli config init -v ${{ matrix.config.additional-url }}
arduino-cli core update-index -v
arduino-cli core install -v ${{ matrix.config.platform }} --run-post-install
# First of all, we clone the repo using the "checkout" action.
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v2
# Finally, we compile the sketches, using the FQBN that was set in the boards matrix.
- name: Compile examples for ${{ matrix.config.board }}
id: compile
env:
fqbn: ${{ matrix.config.fqbn }}
run: |
# Compile example sketches:
export errors=()
for sketch in $( find ./examples -name "*.ino"|sed "s/\ /__ESPACE__/g" )
do
sketch_path=$( echo $sketch |sed "s/__ESPACE__/\ /g" )
sketch_name=$( echo $sketch_path |sed "s/.*\///" )
echo -e "\033[34;1;4mCompile example sketch: $sketch_path\033[0m"
arduino-cli compile --fqbn ${{ matrix.config.fqbn }} --warnings more \
--library ../NewRemoteSwitch "$sketch_path" \
|| { errors+=($sketch) ; echo -e "\033[31;1;4mERROR COMPILING SKETCH: $sketch_path\033[0m\r\n" ;}
done
echo ::set-output name=errors::${errors[@]}
# Show errors
- name: Show errors
if: ${{ steps.compile.outputs.errors }}
env:
errors: ${{ steps.compile.outputs.errors }}
run: |
# Show errors
for sketch in $errors
do
sketch_path=$( echo $sketch |sed "s/__ESPACE__/\ /g" )
echo -e "\033[31;1;4mERROR COMPILING SKETCH: $sketch_path\033[0m"
done
exit 1