Skip to content

Commit e3ce464

Browse files
committed
switch to arduino cli for build tests
1 parent 7cf5d63 commit e3ce464

File tree

5 files changed

+94
-64
lines changed

5 files changed

+94
-64
lines changed

.github/workflows/main.yml

+40-52
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,20 @@ jobs:
2525
run: |
2626
source $GITHUB_WORKSPACE/travis/common.sh
2727
cd $GITHUB_WORKSPACE
28-
echo -en "::set-output name=matrix::"
29-
echo -en "["
3028
31-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80
32-
echo -en ","
29+
echo -en "matrix=" >> $GITHUB_OUTPUT
30+
echo -en "[" >> $GITHUB_OUTPUT
3331
34-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80,dbg=Serial1
35-
echo -en ","
32+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 0.35.3 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Serial1,lvl=SSL,wipe=none,baud=115200 >> $GITHUB_OUTPUT
33+
echo -en "," >> $GITHUB_OUTPUT
3634
37-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.8.13 esp8266com:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80
38-
echo -en ","
35+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 0.35.3 esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=80,FlashMode=qio,eesz=4M2M,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 >> $GITHUB_OUTPUT
36+
echo -en "," >> $GITHUB_OUTPUT
3937
40-
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp32 1.8.13 espressif:esp32:esp32:FlashFreq=80
38+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp32 0.35.3 esp32:esp32:esp32:FlashFreq=80 >> $GITHUB_OUTPUT
4139
42-
echo -en "]"
40+
echo -en "]" >> $GITHUB_OUTPUT
41+
echo >> $GITHUB_OUTPUT
4342
outputs:
4443
matrix: ${{ steps.set-matrix.outputs.matrix }}
4544

@@ -48,33 +47,42 @@ jobs:
4847
strategy:
4948
fail-fast: false
5049
matrix:
51-
IDE_VERSION: [1.8.13, 1.6.13]
50+
CLI_VERSION: [0.35.3]
5251
env:
53-
IDE_VERSION: ${{ matrix.IDE_VERSION }}
52+
CLI_VERSION: ${{ matrix.CLI_VERSION }}
53+
ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide
5454

5555
steps:
5656
- uses: actions/checkout@v2
5757

58-
- name: Get Date
59-
id: get-date
58+
- name: Get hash
59+
id: get-hash
6060
run: |
61-
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
61+
echo "hash=$(/bin/date -u "+%Y%m%d")-$(md5sum ".github/workflows/main.yml" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
6262
shell: bash
6363

64-
- uses: actions/cache@v2
64+
- uses: actions/cache@v3
6565
id: cache_all
6666
with:
6767
path: |
6868
/home/runner/arduino_ide
6969
/home/runner/Arduino
70-
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.IDE_VERSION }}
70+
key: ${{ runner.os }}-${{ steps.get-hash.outputs.hash }}-${{ matrix.CLI_VERSION }}-cli
7171

7272
- name: download IDE
7373
if: steps.cache_all.outputs.cache-hit != 'true'
7474
run: |
75-
wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz -q
76-
tar xf arduino-$IDE_VERSION-linux64.tar.xz
77-
mv arduino-$IDE_VERSION $HOME/arduino_ide
75+
wget https://github.com/arduino/arduino-cli/releases/download/v${CLI_VERSION}/arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz -q
76+
tar xf arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz
77+
mkdir -p $ARDUINO_DIRECTORIES_DATA
78+
mv arduino-cli $ARDUINO_DIRECTORIES_DATA/
79+
80+
- name: download cores
81+
if: steps.cache_all.outputs.cache-hit != 'true'
82+
run: |
83+
export PATH="$ARDUINO_DIRECTORIES_DATA:$PATH"
84+
source $GITHUB_WORKSPACE/travis/common.sh
85+
get_core_cli
7886
7987
- name: download ArduinoJson
8088
if: steps.cache_all.outputs.cache-hit != 'true'
@@ -114,17 +122,11 @@ jobs:
114122
source $GITHUB_WORKSPACE/travis/common.sh
115123
clone_library https://github.com/Bodmer/TFT_eSPI
116124
117-
- name: download esp8266
125+
- name: download LovyanGFX
118126
if: steps.cache_all.outputs.cache-hit != 'true'
119127
run: |
120128
source $GITHUB_WORKSPACE/travis/common.sh
121-
get_core esp8266
122-
123-
- name: download esp32
124-
if: steps.cache_all.outputs.cache-hit != 'true' && matrix.IDE_VERSION != '1.6.13'
125-
run: |
126-
source $GITHUB_WORKSPACE/travis/common.sh
127-
get_core esp32
129+
clone_library https://github.com/lovyan03/LovyanGFX
128130
129131
build:
130132
needs: [prepare_ide, prepare_example_json]
@@ -138,6 +140,7 @@ jobs:
138140
BOARD: ${{ matrix.board }}
139141
IDE_VERSION: ${{ matrix.ideversion }}
140142
SKETCH: ${{ matrix.sketch }}
143+
ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide
141144

142145
# Steps represent a sequence of tasks that will be executed as part of the job
143146
steps:
@@ -147,59 +150,44 @@ jobs:
147150
run: |
148151
sudo apt-get install -y libgtk2.0-0
149152
150-
- name: Get Date
151-
id: get-date
153+
- name: Get hash
154+
id: get-hash
152155
run: |
153-
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
156+
echo "hash=$(/bin/date -u "+%Y%m%d")-$(md5sum ".github/workflows/main.yml" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
154157
shell: bash
155158

156-
- uses: actions/cache@v2
159+
- uses: actions/cache@v3
157160
id: cache_all
158161
with:
159162
path: |
160163
/home/runner/arduino_ide
161164
/home/runner/Arduino
162-
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
165+
key: ${{ runner.os }}-${{ steps.get-hash.outputs.hash }}-${{ matrix.cliversion }}-cli
163166

164167
- name: install python serial
165168
if: matrix.cpu == 'esp32'
166169
run: |
167170
sudo pip3 install pyserial
168171
sudo pip install pyserial
169-
# sudo apt install python-is-python3
170-
171-
- name: start DISPLAY
172-
run: |
173-
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
174-
export DISPLAY=:1.0
175-
sleep 3
176172
177173
- name: test IDE
178174
run: |
179-
export PATH="$HOME/arduino_ide:$PATH"
180-
which arduino
175+
export PATH="$ARDUINO_DIRECTORIES_DATA:$PATH"
176+
which arduino-cli
181177
182178
- name: copy code
183179
run: |
184180
mkdir -p $HOME/Arduino/libraries/
185181
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoVNC
186182
187-
- name: config IDE
188-
run: |
189-
export DISPLAY=:1.0
190-
export PATH="$HOME/arduino_ide:$PATH"
191-
arduino --board $BOARD --save-prefs
192-
arduino --get-pref sketchbook.path
193-
arduino --pref update.check=false
194-
195183
- name: build example
196184
timeout-minutes: 20
197185
run: |
198-
export DISPLAY=:1.0
186+
set -ex
199187
export PATH="$HOME/arduino_ide:$PATH"
200188
source $GITHUB_WORKSPACE/travis/common.sh
201189
cd $GITHUB_WORKSPACE
202-
build_sketch arduino $SKETCH
190+
build_sketch_cli "$SKETCH" "$BOARD"
203191
204192
done:
205193
needs: [prepare_ide, prepare_example_json, build]

examples/VNC_ST7796_LovyanGFX/LovyanGFX_VNCDriver.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "LovyanGFX_VNCDriver.h"
2-
2+
#ifdef ESP32
33
VNCDriver::VNCDriver(LGFX *lgfx) {
44
_lcd = lgfx;
55
_lcd->setRotation(1);
@@ -61,4 +61,5 @@ void VNCDriver::print_screen(String title, String msg, int color) {
6161

6262
void VNCDriver::print(String text) {
6363
_lcd->print(text);
64-
}
64+
}
65+
#endif

examples/VNC_ST7796_LovyanGFX/LovyanGFX_VNCDriver.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#pragma once
2+
3+
#ifdef ESP32
24
#include "VNC_config.h"
35
#include "VNC.h"
46
#define LGFX_USE_V1
@@ -106,4 +108,5 @@ class VNCDriver : public VNCdisplay {
106108

107109
private:
108110
LGFX* _lcd;
109-
};
111+
};
112+
#endif

examples/VNC_ST7796_LovyanGFX/VNC_ST7796_LovyanGFX.ino

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@
1010
* - arduinoVNC (https://github.com/Links2004/arduinoVNC)
1111
* - LovyanGFX (https://github.com/lovyan03/LovyanGFX)
1212
*/
13-
1413
#include <Arduino.h>
14+
15+
#ifndef ESP32
16+
// this only works on the ESP32
17+
void setup(void) {
18+
Serial.begin(115200);
19+
Serial.println("Only works on ESP32");
20+
}
21+
void loop(void) {}
22+
23+
#else
1524
#include <WiFi.h>
1625
#include <VNC.h>
1726
#include "LovyanGFX_VNCDriver.h"
@@ -105,4 +114,5 @@ void touchEvent() {
105114

106115
String getVNCAddr() {
107116
return String(vnc_ip) + String(":") + String(vnc_port);
108-
}
117+
}
118+
#endif

travis/common.sh

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
function build_sketches()
45
{
@@ -27,11 +28,28 @@ function build_sketches()
2728
done
2829
}
2930

31+
function build_sketch_cli()
32+
{
33+
local sketch=$1
34+
local board=$2
35+
arduino-cli --log --log-level info compile -b "$board" "$sketch"
36+
result=$?
37+
if [ $result -ne 0 ]; then
38+
echo "Build failed ($sketch) build verbose..."
39+
arduino-cli --log --log-level debug compile -b "$board" "$sketch"
40+
result=$?
41+
fi
42+
if [ $result -ne 0 ]; then
43+
echo "Build failed ($1) $sketch"
44+
return $result
45+
fi
46+
}
47+
3048
function build_sketch()
31-
{
49+
{
3250
local arduino=$1
3351
local sketch=$2
34-
$arduino --verify $sketch;
52+
$arduino --verify --verbose $sketch;
3553
local result=$?
3654
if [ $result -ne 0 ]; then
3755
echo "Build failed ($sketch) build verbose..."
@@ -60,7 +78,7 @@ function get_sketches_json()
6078
if [[ $sketch != ${sketches[-1]} ]] ; then
6179
echo -en ","
6280
fi
63-
81+
6482
done
6583
echo -en "]"
6684
}
@@ -70,7 +88,7 @@ function get_sketches_json_matrix()
7088
local arduino=$1
7189
local srcpath=$2
7290
local platform=$3
73-
local ideversion=$4
91+
local cliversion=$4
7492
local board=$5
7593
local sketches=($(find $srcpath -name *.ino))
7694
for sketch in "${sketches[@]}" ; do
@@ -79,24 +97,34 @@ function get_sketches_json_matrix()
7997
if [[ -f "$sketchdir/.$platform.skip" ]]; then
8098
continue
8199
fi
82-
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"ideversion\":\"$ideversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
100+
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"cliversion\":\"$cliversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
83101
if [[ $sketch != ${sketches[-1]} ]] ; then
84102
echo -en ","
85103
fi
86104
done
87105
}
88106

107+
function get_core_cli() {
108+
export ARDUINO_BOARD_MANAGER_ADDITIONAL_URLS="https://arduino.esp8266.com/stable/package_esp8266com_index.json https://espressif.github.io/arduino-esp32/package_esp32_index.json https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json"
109+
arduino-cli core update-index
110+
arduino-cli core install esp8266:esp8266
111+
arduino-cli core install esp32:esp32
112+
arduino-cli core install arduino:mbed_rp2040
113+
}
114+
89115
function get_core()
90116
{
91117
echo Setup core for $1
92118

93-
cd $HOME/arduino_ide/hardware
119+
mkdir -p $HOME/arduino_ide/packages/hardware
120+
cd $HOME/arduino_ide/packages/hardware
94121

95122
if [ "$1" = "esp8266" ] ; then
96123
mkdir esp8266com
97124
cd esp8266com
98125
git clone --depth 1 https://github.com/esp8266/Arduino.git esp8266
99126
cd esp8266/
127+
git submodule update --init
100128
rm -rf .git
101129
cd tools
102130
python get.py
@@ -127,5 +155,5 @@ function clone_library() {
127155

128156
function hash_library_names() {
129157
cd $HOME/Arduino/libraries
130-
ls | sha1sum -z | cut -c1-5
158+
ls | sha1sum -z | cut -c1-5
131159
}

0 commit comments

Comments
 (0)