forked from 1technophile/NewRemoteSwitch
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (106 loc) · 4.42 KB
/
CompileTest.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
# 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:[email protected]"
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/[email protected]
# 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