Skip to content

Commit

Permalink
switch to arduino cli for build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Links2004 committed Apr 30, 2024
1 parent 7cf5d63 commit 16a6acf
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 62 deletions.
95 changes: 40 additions & 55 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,20 @@ jobs:
run: |
source $GITHUB_WORKSPACE/travis/common.sh
cd $GITHUB_WORKSPACE
echo -en "::set-output name=matrix::"
echo -en "["
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80
echo -en ","
echo -en "matrix=" >> $GITHUB_OUTPUT
echo -en "[" >> $GITHUB_OUTPUT
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80,dbg=Serial1
echo -en ","
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
echo -en "," >> $GITHUB_OUTPUT
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp8266 1.8.13 esp8266com:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80
echo -en ","
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
echo -en "," >> $GITHUB_OUTPUT
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp32 1.8.13 espressif:esp32:esp32:FlashFreq=80
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples esp32 0.35.3 esp32:esp32:esp32:FlashFreq=80 >> $GITHUB_OUTPUT
echo -en "]"
echo -en "]" >> $GITHUB_OUTPUT
echo >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

Expand All @@ -48,33 +47,42 @@ jobs:
strategy:
fail-fast: false
matrix:
IDE_VERSION: [1.8.13, 1.6.13]
CLI_VERSION: [0.35.3]
env:
IDE_VERSION: ${{ matrix.IDE_VERSION }}
CLI_VERSION: ${{ matrix.CLI_VERSION }}
ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide

steps:
- uses: actions/checkout@v2

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

- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache_all
with:
path: |
/home/runner/arduino_ide
/home/runner/Arduino
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.IDE_VERSION }}
key: ${{ runner.os }}-${{ steps.get-hash.outputs.hash }}-${{ matrix.CLI_VERSION }}-cli

- name: download IDE
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz -q
tar xf arduino-$IDE_VERSION-linux64.tar.xz
mv arduino-$IDE_VERSION $HOME/arduino_ide
wget https://github.com/arduino/arduino-cli/releases/download/v${CLI_VERSION}/arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz -q
tar xf arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz
mkdir -p $ARDUINO_DIRECTORIES_DATA
mv arduino-cli $ARDUINO_DIRECTORIES_DATA/
- name: download cores
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
export PATH="$ARDUINO_DIRECTORIES_DATA:$PATH"
source $GITHUB_WORKSPACE/travis/common.sh
get_core_cli
- name: download ArduinoJson
if: steps.cache_all.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -114,17 +122,11 @@ jobs:
source $GITHUB_WORKSPACE/travis/common.sh
clone_library https://github.com/Bodmer/TFT_eSPI
- name: download esp8266
- name: download LovyanGFX
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
source $GITHUB_WORKSPACE/travis/common.sh
get_core esp8266
- name: download esp32
if: steps.cache_all.outputs.cache-hit != 'true' && matrix.IDE_VERSION != '1.6.13'
run: |
source $GITHUB_WORKSPACE/travis/common.sh
get_core esp32
clone_library https://github.com/lovyan03/LovyanGFX
build:
needs: [prepare_ide, prepare_example_json]
Expand All @@ -138,28 +140,25 @@ jobs:
BOARD: ${{ matrix.board }}
IDE_VERSION: ${{ matrix.ideversion }}
SKETCH: ${{ matrix.sketch }}
ARDUINO_DIRECTORIES_DATA: /home/runner/arduino_ide

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2

- name: install libgtk2.0-0
- name: Get hash
id: get-hash
run: |
sudo apt-get install -y libgtk2.0-0
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
echo "hash=$(/bin/date -u "+%Y%m%d")-$(md5sum ".github/workflows/main.yml" | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache_all
with:
path: |
/home/runner/arduino_ide
/home/runner/Arduino
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.cliversion }}-cli

- name: install python serial
if: matrix.cpu == 'esp32'
Expand All @@ -168,38 +167,24 @@ jobs:
sudo pip install pyserial
# sudo apt install python-is-python3

- name: start DISPLAY
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
export DISPLAY=:1.0
sleep 3
- name: test IDE
run: |
export PATH="$HOME/arduino_ide:$PATH"
which arduino
export PATH="$ARDUINO_DIRECTORIES_DATA:$PATH"
which arduino-cli
- name: copy code
run: |
mkdir -p $HOME/Arduino/libraries/
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoVNC
- name: config IDE
run: |
export DISPLAY=:1.0
export PATH="$HOME/arduino_ide:$PATH"
arduino --board $BOARD --save-prefs
arduino --get-pref sketchbook.path
arduino --pref update.check=false
- name: build example
timeout-minutes: 20
run: |
export DISPLAY=:1.0
set -ex
export PATH="$HOME/arduino_ide:$PATH"
source $GITHUB_WORKSPACE/travis/common.sh
cd $GITHUB_WORKSPACE
build_sketch arduino $SKETCH
build_sketch_cli "$SKETCH" "$BOARD"
done:
needs: [prepare_ide, prepare_example_json, build]
Expand Down
4 changes: 4 additions & 0 deletions examples/VNC_ST7796_LovyanGFX/VNC_ST7796_LovyanGFX.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*/

#include <Arduino.h>
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
#include <WiFi.h>
#endif
#include <VNC.h>
#include "LovyanGFX_VNCDriver.h"

Expand Down
42 changes: 35 additions & 7 deletions travis/common.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

function build_sketches()
{
Expand Down Expand Up @@ -27,11 +28,28 @@ function build_sketches()
done
}

function build_sketch_cli()
{
local sketch=$1
local board=$2
arduino-cli --log --log-level info compile -b "$board" "$sketch"
result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
arduino-cli --log --log-level debug compile -b "$board" "$sketch"
result=$?
fi
if [ $result -ne 0 ]; then
echo "Build failed ($1) $sketch"
return $result
fi
}

function build_sketch()
{
{
local arduino=$1
local sketch=$2
$arduino --verify $sketch;
$arduino --verify --verbose $sketch;
local result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
Expand Down Expand Up @@ -60,7 +78,7 @@ function get_sketches_json()
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi

done
echo -en "]"
}
Expand All @@ -70,7 +88,7 @@ function get_sketches_json_matrix()
local arduino=$1
local srcpath=$2
local platform=$3
local ideversion=$4
local cliversion=$4
local board=$5
local sketches=($(find $srcpath -name *.ino))
for sketch in "${sketches[@]}" ; do
Expand All @@ -79,24 +97,34 @@ function get_sketches_json_matrix()
if [[ -f "$sketchdir/.$platform.skip" ]]; then
continue
fi
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"ideversion\":\"$ideversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"cliversion\":\"$cliversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi
done
}

function get_core_cli() {
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"
arduino-cli core update-index
arduino-cli core install esp8266:esp8266
arduino-cli core install esp32:esp32
arduino-cli core install arduino:mbed_rp2040
}

function get_core()
{
echo Setup core for $1

cd $HOME/arduino_ide/hardware
mkdir -p $HOME/arduino_ide/packages/hardware
cd $HOME/arduino_ide/packages/hardware

if [ "$1" = "esp8266" ] ; then
mkdir esp8266com
cd esp8266com
git clone --depth 1 https://github.com/esp8266/Arduino.git esp8266
cd esp8266/
git submodule update --init
rm -rf .git
cd tools
python get.py
Expand Down Expand Up @@ -127,5 +155,5 @@ function clone_library() {

function hash_library_names() {
cd $HOME/Arduino/libraries
ls | sha1sum -z | cut -c1-5
ls | sha1sum -z | cut -c1-5
}

0 comments on commit 16a6acf

Please sign in to comment.