use github actions for build

This commit is contained in:
Links
2021-01-05 18:35:22 +01:00
parent c68e015322
commit 1b4f186fa6
2 changed files with 200 additions and 46 deletions

View File

@ -1,77 +1,167 @@
# This is a basic workflow to help you get started with Actions
name: CI name: CI
# Controls when the action will run.
on: on:
# Triggers the workflow on push or pull request events but only for the master branch schedule:
- cron: '0 0 * * 5'
push: push:
branches: [ master ] branches: [ master ]
pull_request: pull_request:
branches: [ master ] branches: [ master ]
release:
types: [ published, created, edited ]
# Allows you to run this workflow manually from the Actions tab # Allows you to run this workflow manually from the Actions tab
workflow_dispatch: workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel # A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs: jobs:
# This workflow contains a single job called "build"
build: prepare_example_json:
# The type of runner that the job will run on runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: generate examples
id: set-matrix
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 esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80
echo -en ","
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80,dbg=Serial1
echo -en ","
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 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/esp32 esp32 1.8.13 espressif:esp32:esp32:FlashFreq=80
echo -en "]"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
prepare_ide:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: fail-fast: false
env: matrix:
- CPU: esp8266 IDE_VERSION: [1.8.13, 1.6.13]
BOARD: esp8266com:esp8266:generic:xtal=80 env:
IDE_VERSION: 1.6.13 IDE_VERSION: ${{ matrix.IDE_VERSION }}
- CPU: esp8266
BOARD: esp8266com:esp8266:generic:xtal=80,dbg=Serial1 steps:
IDE_VERSION: 1.6.13 - uses: actions/checkout@v2
- CPU: esp8266
BOARD: esp8266com:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80 - name: Get Date
IDE_VERSION: 1.8.13 id: get-date
- CPU: esp32 run: |
BOARD: espressif:esp32:esp32:FlashFreq=80 echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
IDE_VERSION: 1.8.5 shell: bash
- CPU: esp32
BOARD: espressif:esp32:esp32:FlashFreq=80 - uses: actions/cache@v2
IDE_VERSION: 1.8.9 id: cache_all
- CPU: esp32 with:
BOARD: espressif:esp32:esp32:FlashFreq=80 path: |
IDE_VERSION: 1.8.13 /home/runner/arduino_ide
env: ${{ matrix.env }} /home/runner/Arduino
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.IDE_VERSION }}
- 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
- name: download ArduinoJson
if: steps.cache_all.outputs.cache-hit != 'true'
run: |
mkdir -p $HOME/Arduino/libraries
wget https://github.com/bblanchon/ArduinoJson/archive/6.x.zip -q
unzip 6.x.zip
mv ArduinoJson-6.x $HOME/Arduino/libraries/ArduinoJson
- name: download esp8266
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
build:
needs: [prepare_ide, prepare_example_json]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare_example_json.outputs.matrix) }}
env:
CPU: ${{ matrix.cpu }}
BOARD: ${{ matrix.board }}
IDE_VERSION: ${{ matrix.ideversion }}
SKETCH: ${{ matrix.sketch }}
# Steps represent a sequence of tasks that will be executed as part of the job # Steps represent a sequence of tasks that will be executed as part of the job
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: prepare - name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
shell: bash
- uses: actions/cache@v2
id: cache_all
with:
path: |
/home/runner/arduino_ide
/home/runner/Arduino
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
- name: install python serial
if: matrix.cpu == 'esp32'
run: |
sudo pip3 install pyserial
sudo pip install pyserial
# sudo apt install python-is-python3
- name: start DISPLAY
run: | 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 /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 export DISPLAY=:1.0
sleep 3 sleep 3
wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
tar xf arduino-$IDE_VERSION-linux64.tar.xz - name: test IDE
mv arduino-$IDE_VERSION $HOME/arduino_ide run: |
export PATH="$HOME/arduino_ide:$PATH" export PATH="$HOME/arduino_ide:$PATH"
which arduino which arduino
mkdir -p $HOME/Arduino/libraries
wget https://github.com/bblanchon/ArduinoJson/archive/6.x.zip - name: copy code
unzip 6.x.zip run: |
mv ArduinoJson-6.x $HOME/Arduino/libraries/ArduinoJson
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets
source $GITHUB_WORKSPACE/travis/common.sh
get_core $CPU - name: config IDE
cd $GITHUB_WORKSPACE run: |
export DISPLAY=:1.0
export PATH="$HOME/arduino_ide:$PATH"
arduino --board $BOARD --save-prefs arduino --board $BOARD --save-prefs
arduino --get-pref sketchbook.path arduino --get-pref sketchbook.path
arduino --pref update.check=false arduino --pref update.check=false
- name: build examples - name: build example
run: | run: |
export DISPLAY=:1.0
export PATH="$HOME/arduino_ide:$PATH"
source $GITHUB_WORKSPACE/travis/common.sh source $GITHUB_WORKSPACE/travis/common.sh
cd $GITHUB_WORKSPACE cd $GITHUB_WORKSPACE
build_sketches arduino $HOME/Arduino/libraries/arduinoWebSockets/examples/$CPU $CPU build_sketch arduino $SKETCH

View File

@ -27,6 +27,66 @@ function build_sketches()
done done
} }
function build_sketch()
{
local arduino=$1
local sketch=$2
$arduino --verify $sketch;
local result=$?
if [ $result -ne 0 ]; then
echo "Build failed ($sketch) build verbose..."
$arduino --verify --verbose --preserve-temp-files $sketch
result=$?
fi
if [ $result -ne 0 ]; then
echo "Build failed ($1) $sketch"
return $result
fi
}
function get_sketches_json()
{
local arduino=$1
local srcpath=$2
local platform=$3
local sketches=($(find $srcpath -name *.ino))
echo -en "["
for sketch in "${sketches[@]}" ; do
local sketchdir=$(dirname $sketch)
if [[ -f "$sketchdir/.$platform.skip" ]]; then
continue
fi
echo -en "\"$sketch\""
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi
done
echo -en "]"
}
function get_sketches_json_matrix()
{
local arduino=$1
local srcpath=$2
local platform=$3
local ideversion=$4
local board=$5
local sketches=($(find $srcpath -name *.ino))
for sketch in "${sketches[@]}" ; do
local sketchdir=$(dirname $sketch)
local sketchname=$(basename $sketch)
if [[ -f "$sketchdir/.$platform.skip" ]]; then
continue
fi
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"ideversion\":\"$ideversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
if [[ $sketch != ${sketches[-1]} ]] ; then
echo -en ","
fi
done
}
function get_core() function get_core()
{ {
@ -38,7 +98,9 @@ function get_core()
mkdir esp8266com mkdir esp8266com
cd esp8266com cd esp8266com
git clone https://github.com/esp8266/Arduino.git esp8266 git clone https://github.com/esp8266/Arduino.git esp8266
cd esp8266/tools cd esp8266/
rm -rf .git
cd tools
python get.py python get.py
fi fi
@ -46,7 +108,9 @@ function get_core()
mkdir espressif mkdir espressif
cd espressif cd espressif
git clone https://github.com/espressif/arduino-esp32.git esp32 git clone https://github.com/espressif/arduino-esp32.git esp32
cd esp32/tools cd esp32/
rm -rf .git
cd tools
python get.py python get.py
fi fi