Use github-actions for CI instead of Travis

This commit is contained in:
Luc 2021-04-12 07:52:55 +02:00
parent a8f4f9dc71
commit 1804db5b64
12 changed files with 182 additions and 122 deletions

40
.github/ci/build-esp3d.sh vendored Normal file
View File

@ -0,0 +1,40 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
#arduino or PlatformIO
target=$1
ide=$2
#bluetooth
#local bt=$3
#authentication
#local auth=$4
#filesystem
#local fs=$5
# Make sure we are inside the github workspace
cd $GITHUB_WORKSPACE
#export paths
export PATH="$HOME/arduino_ide:$PATH"
export ARDUINO_IDE_PATH="$HOME/arduino_ide"
if [[ "$ide" == "arduino" ]];
then
if [[ "$target" == "esp32" ]];
then
echo "setup for esp32"
fqbn="esp32:esp32:esp32:PartitionScheme=min_spiffs,FlashFreq=80,PSRAM=disabled,CPUFreq=240,FlashMode=qio,FlashSize=4M,DebugLevel=none"
else
echo "setup for esp8266"
sed -i "s/\/\/#define AUTHENTICATION_FEATURE /#define AUTHENTICATION_FEATURE/g" $GITHUB_WORKSPACE/esp3d/config.h
fqbn="esp8266com:esp8266:generic:eesz=4M3M,xtal=160,FlashMode=dio,FlashFreq=40,sdk=nonosdk221,ip=lm2f,dbg=Disabled,vt=flash,exception=disabled,ssl=basic"
fi
arduino-builder -hardware "$ARDUINO_IDE_PATH/hardware" -tools "$ARDUINO_IDE_PATH/tools-builder" -tools "$ARDUINO_IDE_PATH/tools" -libraries "$ARDUINO_IDE_PATH/libraries" -fqbn=$fqbn -compile -logger=human -core-api-version=10810 ./esp3d/esp3d.ino
else
platformio run -e esp32dev
platformio run -e esp8266dev
fi

26
.github/ci/final-check.sh vendored Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
# Make sure we are inside the github workspace
cd $GITHUB_WORKSPACE
echo $STEPS_CONTEXT
step=$1
status=$2
export BODYMESSAGE="$(git log -1 $GITHUB_SHA --pretty="%B")"
export BACKTICK='`';
export TIMESTAMP=$(date --utc +%FT%TZ);
export GITHUB_ACTOR_NAME="$(git log -1 $GITHUB_SHA --pretty="%aN")";
export COMMIT_FORMATTED="[$BACKTICK${GITHUB_SHA:0:7}$BACKTICK](https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA)";
if [[ "$status" == "success" ]];
then
echo "Success build"
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://pngimg.com/uploads/github/github_PNG90.png","username":"github-action","embeds":[{"author":{"name":"Build #'"$step"' Passed - '"$GITHUB_ACTOR_NAME"'","url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'"},"url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'","title":"['"$GITHUB_REPOSITORY"':job#'"$GITHUB_RUN_NUMBER"'] ","color":65280,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$BODYMESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"ESP3D CI"}}]}' $DISCORD_WEBHOOK_URL;
else
echo "Build failed"
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://pngimg.com/uploads/github/github_PNG90.png","username":"github-action","embeds":[{"author":{"name":"Build #'"$step"' Failed - '"$GITHUB_ACTOR_NAME"'","url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'"},"url":"https://github.com/'"$GITHUB_REPOSITORY"'/actions/runs/'"$GITHUB_RUN_ID"'","title":"['"$GITHUB_REPOSITORY"':job#'"$GITHUB_RUN_NUMBER"'] ","color":16711680,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$BODYMESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"ESP3D CI"}}]}' $DISCORD_WEBHOOK_URL;
fi

12
.github/ci/install-arduino.sh vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
wget http://downloads.arduino.cc/arduino-1.8.13-linux64.tar.xz
tar xf arduino-1.8.13-linux64.tar.xz
mv arduino-1.8.13 $HOME/arduino_ide

19
.github/ci/install-esp32.sh vendored Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
#install pyserial
echo "Installing Python Serial ..."
pip install pyserial
echo "Clone esp32 core"
cd $HOME/arduino_ide/hardware
mkdir esp32
cd esp32
git clone https://github.com/espressif/arduino-esp32.git esp32
cd esp32
git submodule update --init
cd tools
python get.py

14
.github/ci/install-esp8266.sh vendored Normal file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
cd $HOME/arduino_ide/hardware
mkdir esp8266com
cd esp8266com
git clone clone -b 2.5.2 https://github.com/esp8266/Arduino.git esp8266
cd esp8266
git submodule update --init
cd tools
python get.py

9
.github/ci/install-platformio.sh vendored Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
pip install -U platformio
platformio update

15
.github/ci/prepare-libs.sh vendored Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status.
set -e
# Enable the globstar shell option
shopt -s globstar
ls $HOME
# Make sure we are inside the github workspace
cd $GITHUB_WORKSPACE
cp -r ./libraries/ESP32SSDP $HOME/arduino_ide/libraries/
cp -r ./libraries/arduinoWebSockets $HOME/arduino_ide/libraries/
cp -r ./libraries/DHT_sensor_library_for_ESPx $HOME/arduino_ide/libraries/
cp -r ./libraries/oled-ssd1306 $HOME/arduino_ide/libraries/
cp -r ./libraries/ESP32NETBIOS $HOME/arduino_ide/libraries/

47
.github/workflows/build-ci-2.0.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: build-ci-2.0
on: [pull_request, push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: "3.x"
architecture: "x64"
- name: Install Arduino
run: bash ./.github/ci/install-arduino.sh
- name: Install platformIO
run: bash ./.github/ci/install-platformio.sh
- name: Install ESP8266
run: bash ./.github/ci/install-esp8266.sh
- name: Install ESP32
run: bash ./.github/ci/install-esp32.sh
- name: Setup libraries
run: bash ./.github/ci/prepare-libs.sh
- name: Build ESP8266 arduino
id: esp8266_1
run: bash ./.github/ci/build-esp3d.sh esp8266 arduino
continue-on-error: true
- name: Build ESP32 arduino
id: esp32_1
run: bash ./.github/ci/build-esp3d.sh esp32 arduino
continue-on-error: true
- name: Build platformIO
id: pio_1
run: bash ./.github/ci/build-esp3d.sh esp32 pio
continue-on-error: true
- name: Final check
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
if: steps.esp8266_1.outcome == 'failure' || steps.esp32_1.outcome == 'failure'
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "failure"
- name: Final confirmation
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
if: steps.esp8266_1.outcome == 'success' && steps.esp32_1.outcome == 'success'
run: bash ./.github/ci/final-check.sh "$GITHUB_RUN_ID" "success"

View File

@ -1,87 +0,0 @@
dist: xenial
sudo: require
language: python
python:
- "3.7"
os:
- linux
cache:
pip: true
directories:
- "~/.platformio"
install:
- pip install -U platformio
before_script:
- export AUTHOR_NAME="$(git log -1 $TRAVIS_COMMIT --pretty="%aN")"
- platformio update
- wget http://downloads.arduino.cc/arduino-1.8.5-linux64.tar.xz
- tar xf arduino-1.8.5-linux64.tar.xz
- mv arduino-1.8.5 $HOME/arduino_ide
- cd $HOME/arduino_ide/hardware
- mkdir esp8266com
- cd esp8266com
- git clone -b 2.5.2 https://github.com/esp8266/Arduino.git esp8266
- cd esp8266/tools
- python get.py
- cd $HOME/arduino_ide/hardware
- mkdir esp32
- cd esp32
- git clone https://github.com/espressif/arduino-esp32.git esp32
- cd esp32/tools
- python get.py
- cp -r $TRAVIS_BUILD_DIR/libraries/ESPAsyncWebServer $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/ESPAsyncTCP $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/AsyncTCP $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/oled-ssd1306 $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/ESP32SSDP $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/arduinoWebSockets $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/DHT_sensor_library_for_ESPx $HOME/arduino_ide/libraries/
- cp -r $TRAVIS_BUILD_DIR/libraries/ESP32NETBIOS $HOME/arduino_ide/libraries/
script:
- cd $TRAVIS_BUILD_DIR
- source command.sh
- export PATH="$HOME/arduino_ide:$PATH"
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp8266com:esp8266:generic:eesz=4M3M,xtal=160,FlashMode=dio,FlashFreq=40,sdk=nonosdk221,ip=lm2f,dbg=Disabled,vt=flash,exception=disabled,ssl=basic --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp32:esp32:esp32:PartitionScheme=min_spiffs,FlashFreq=80,PSRAM=disabled,CPUFreq=240,FlashMode=qio,FlashSize=4M,DebugLevel=none --pref compiler.warning_level=all --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- sed -i "s/\/\/#define AUTHENTICATION_FEATURE /#define AUTHENTICATION_FEATURE/g" $TRAVIS_BUILD_DIR/esp3d/config.h
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp8266com:esp8266:generic:eesz=4M3M,xtal=160,FlashMode=dio,FlashFreq=40,sdk=nonosdk221,ip=lm2f,dbg=Disabled,vt=flash,exception=disabled,ssl=basic --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp32:esp32:esp32:PartitionScheme=min_spiffs,FlashFreq=80,PSRAM=disabled,CPUFreq=240,FlashMode=qio,FlashSize=4M,DebugLevel=none --pref compiler.warning_level=all --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- sed -i "s/\/\/#define ASYNCWEBSERVER /#define ASYNCWEBSERVER/g" $TRAVIS_BUILD_DIR/esp3d/config.h
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp8266com:esp8266:generic:eesz=4M3M,xtal=160,FlashMode=dio,FlashFreq=40,sdk=nonosdk221,ip=lm2f,dbg=Disabled,vt=flash,exception=disabled,ssl=basic --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- rm -f $HOME/.arduino15/preferences.txt
- arduino --board esp32:esp32:esp32:PartitionScheme=min_spiffs,FlashFreq=80,PSRAM=disabled,CPUFreq=240,FlashMode=qio,FlashSize=4M,DebugLevel=none --pref compiler.warning_level=all --save-prefs
- build_sketch $TRAVIS_BUILD_DIR/esp3d/esp3d.ino
- rm -fr $HOME/arduino_ide
- rm -fr $HOME/.arduino15
- platformio run
after_success:
- chmod +x success.sh
- ./success.sh
after_failure:
- chmod +x fail.sh
- ./fail.sh
notifications:
email:
recipients:
- $TRAVIS_EMAIL
on_success: change
on_failure: change

View File

@ -1,19 +0,0 @@
#!/bin/bash
function build_sketch()
{
local sketch=$1
# buld sketch with arudino ide
echo -e "\n Build $sketch \n"
arduino --verbose --verify $sketch
# get build result from arduino
local re=$?
# check result
if [ $re -ne 0 ]; then
echo "Failed to build $sketch"
return $re
fi
}

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
echo 'Sending Discord Webhook';
export BACKTICK='`';
export TIMESTAMP=$(date --utc +%FT%TZ);
export REPO_OWNER="luc-github";
export REPO_NAME="ESP3D";
export COMMIT_FORMATTED="[$BACKTICK${TRAVIS_COMMIT:0:7}$BACKTICK](https://github.com/$REPO_OWNER/$REPO_NAME/commit/$TRAVIS_COMMIT)";
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://i.imgur.com/kOfUGNS.png","username":"Travis CI","embeds":[{"author":{"name":"Build #'"$TRAVIS_BUILD_NUMBER"' Failed - '"$AUTHOR_NAME"'","url":"https://travis-ci.org/'"$REPO_OWNER"'/'"$REPO_NAME"'/builds/'"$TRAVIS_BUILD_ID"'"},"url":"https://github.com/'"$REPO_OWNER"'/'"$REPO_NAME"'/commit/'"$TRAVIS_COMMIT"'","title":"['"$TRAVIS_REPO_SLUG"':'"$TRAVIS_BRANCH"'] ","color":16711680,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$TRAVIS_COMMIT_MESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"Travis CI"}}]}' $DISCORD_WEBHOOK_URL;

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
echo 'Sending Discord Webhook';
export BACKTICK='`';
export TIMESTAMP=$(date --utc +%FT%TZ);
export REPO_OWNER="luc-github";
export REPO_NAME="ESP3D";
export COMMIT_FORMATTED="[$BACKTICK${TRAVIS_COMMIT:0:7}$BACKTICK](https://github.com/$REPO_OWNER/$REPO_NAME/commit/$TRAVIS_COMMIT)";
curl -v -H User-Agent:bot -H Content-Type:application/json -d '{"avatar_url":"https://i.imgur.com/kOfUGNS.png","username":"Travis CI","embeds":[{"author":{"name":"Build #'"$TRAVIS_BUILD_NUMBER"' Passed - '"$AUTHOR_NAME"'","url":"https://travis-ci.org/'"$REPO_OWNER"'/'"$REPO_NAME"'/builds/'"$TRAVIS_BUILD_ID"'"},"url":"https://github.com/'"$REPO_OWNER"'/'"$REPO_NAME"'/commit/'"$TRAVIS_COMMIT"'","title":"['"$TRAVIS_REPO_SLUG"':'"$TRAVIS_BRANCH"'] ","color":65280,"fields":[{"name":"_ _", "value": "'"$COMMIT_FORMATTED"' - '"$TRAVIS_COMMIT_MESSAGE"'"}],"timestamp":"'"$TIMESTAMP"'","footer":{"text":"Travis CI"}}]}' $DISCORD_WEBHOOK_URL;