8000 use github actions for build · PeterEmbedded/arduinoWebSockets@1b4f186 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b4f186

Browse files
committed
use github actions for build
1 parent c68e015 commit 1b4f186

File tree

2 files changed

+199
-45
lines changed

2 files changed

+199
-45
lines changed

.github/workflows/main.yml

Lines changed: 133 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,167 @@
1-
# This is a basic workflow to help you get started with Actions
2-
31
name: CI
4-
5-
# Controls when the action will run.
62
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
3+
schedule:
4+
- cron: '0 0 * * 5'
85
push:
96
branches: [ master ]
107
pull_request:
118
branches: [ master ]
9+
release:
10+
types: [ published, created, edited ]
1211

1312
# Allows you to run this workflow manually from the Actions tab
1413
workflow_dispatch:
1514

1615
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1716
jobs:
18-
# This workflow contains a single job called "build"
17+
18+
prepare_example_json:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- name: generate examples
24+
id: set-matrix
25+
run: |
26+
source $GITHUB_WORKSPACE/travis/common.sh
27+
cd $GITHUB_WORKSPACE
28+
echo -en "::set-output name=matrix::"
29+
echo -en "["
30+
31+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80
32+
echo -en ","
33+
34+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.6.13 esp8266com:esp8266:generic:xtal=80,dbg=Serial1
35+
echo -en ","
36+
37+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp8266 esp8266 1.8.13 esp8266com:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80
38+
echo -en ","
39+
40+
get_sketches_json_matrix arduino $GITHUB_WORKSPACE/examples/esp32 esp32 1.8.13 espressif:esp32:esp32:FlashFreq=80
41+
42+
echo -en "]"
43+
outputs:
44+
matrix: ${{ steps.set-matrix.outputs.matrix }}
45+
46+
prepare_ide:
47+
runs-on: ubuntu-latest
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
IDE_VERSION: [1.8.13, 1.6.13]
52+
env:
53+
IDE_VERSION: ${{ matrix.IDE_VERSION }}
54+
55+
steps:
56+
- uses: actions/checkout@v2
57+
58+
- name: Get Date
59+
id: get-date
60+
run: |
61+
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
62+
shell: bash
63+
64+
- uses: actions/cache@v2
65+
id: cache_all
66+
with:
67+
path: |
68+
/home/runner/arduino_ide
69+
/home/runner/Arduino
70+
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.IDE_VERSION }}
71+
72+
- name: download IDE
73+
if: steps.cache_all.outputs.cache-hit != 'true'
74+
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
78+
79+
- name: download ArduinoJson
80+
if: steps.cache_all.outputs.cache-hit != 'true'
81+
run: |
82+
mkdir -p $HOME/Arduino/libraries
83+
wget https://github.com/bblanchon/ArduinoJson/archive/6.x.zip -q
84+
unzip 6.x.zip
85+
mv ArduinoJson-6.x $HOME/Arduino/libraries/ArduinoJson
86+
87+
- name: download esp8266
88+
if: steps.cache_all.outputs.cache-hit != 'true'
89+
run: |
90+
source $GITHUB_WORKSPACE/travis/common.sh
91+
get_core esp8266
92+
93+
- name: download esp32
94+
if: steps.cache_all.outputs.cache-hit != 'true' && matrix.IDE_VERSION != '1.6.13'
95+
run: |
96+
source $GITHUB_WORKSPACE/travis/common.sh
97+
get_core esp32
98+
1999
build:
20-
# The type of runner that the job will run on
100+
needs: [prepare_ide, prepare_example_json]
21101
runs-on: ubuntu-latest
22102
strategy:
23-
matrix:
24-
env:
25-
- CPU: esp8266
26-
BOARD: esp8266com:esp8266:generic:xtal=80
27-
IDE_VERSION: 1.6.13
28-
- CPU: esp8266
29-
BOARD: esp8266com:esp8266:generic:xtal=80,dbg=Serial1
30-
IDE_VERSION: 1.6.13
31-
- CPU: esp8266
32-
BOARD: esp8266com:esp8266:generic:xtal=80,eesz=1M,FlashMode=qio,FlashFreq=80
33-
IDE_VERSION: 1.8.13
34-
- CPU: esp32
35-
BOARD: espressif:esp32:esp32:FlashFreq=80
36-
IDE_VERSION: 1.8.5
37-
- CPU: esp32
38-
BOARD: espressif:esp32:esp32:FlashFreq=80
39-
IDE_VERSION: 1.8.9
40-
- CPU: esp32 F438
41-
BOARD: espressif:esp32:esp32:FlashFreq=80
42-
IDE_VERSION: 1.8.13
43-
env: ${{ matrix.env }}
103+
fail-fast: false
104+
matrix:
105+
include: ${{ fromJson(needs.prepare_example_json.outputs.matrix) }}
106+
env:
107+
CPU: ${{ matrix.cpu }}
108+
BOARD: ${{ matrix.board }}
109+
IDE_VERSION: ${{ matrix.ideversion }}
110+
SKETCH: ${{ matrix.sketch }}
44111

45112
# Steps represent a sequence of tasks that will be executed as part of the job
46113
steps:
47-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
48114
- uses: actions/checkout@v2
49-
50-
- name: prepare
115+
116+
- name: Get Date
117+
id: get-date
118+
run: |
119+
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
120+
shell: bash
121+
122+
- uses: actions/cache@v2
123+
id: cache_all
124+
with:
125+
path: |
126+
/home/runner/arduino_ide
127+
/home/runner/Arduino
128+
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ matrix.ideversion }}
129+
130+
- name: install python serial
131+
if: matrix.cpu == 'esp32'
132+
run: |
133+
sudo pip3 install pyserial
134+
sudo pip install pyserial
135+
# sudo apt install python-is-python3
136+
137+
- name: start DISPLAY
51138
run: |
52139
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
53140
export DISPLAY=:1.0
54141
sleep 3
55-
wget http://downloads.arduino.cc/arduino-$IDE_VERSION-linux64.tar.xz
56-
tar xf arduino-$IDE_VERSION-linux64.tar.xz
57-
mv arduino-$IDE_VERSION $HOME/arduino_ide
142+
143+
- name: test IDE
144+
run: |
58145
export PATH="$HOME/arduino_ide:$PATH"
59146
which arduino
60-
mkdir -p $HOME/Arduino/libraries
61147
62-
wget https://github.com/bblanchon/ArduinoJson/archive/6.x.zip
63-
unzip 6.x.zip
64-
mv ArduinoJson-6.x $HOME/Arduino/libraries/ArduinoJson
148+
- name: copy code
149+
run: |
65150
cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/arduinoWebSockets
66-
source $GITHUB_WORKSPACE/travis/common.sh
67-
get_core $CPU
68-
cd $GITHUB_WORKSPACE
151+
152+
- name: config IDE
153+
run: |
154+
export DISPLAY=:1.0
155+
export PATH="$HOME/arduino_ide:$PATH"
69156
arduino --board $BOARD --save-prefs
70157
arduino --get-pref sketchbook.path
71158
arduino --pref update.check=false
72159
73-
- name: build examples
160+
- name: build example
74161
run: |
162+
export DISPLAY=:1.0
163+
export PATH="$HOME/arduino_ide:$PATH"
75164
source $GITHUB_WORKSPACE/travis/common.sh
76165
cd $GITHUB_WORKSPACE
77-
build_sketches arduino $HOME/Arduino/libraries/arduinoWebSockets/examples/$CPU $CPU
166+
build_sketch arduino $SKETCH
167+

travis/common.sh

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,66 @@ function build_sketches()
2727
done
2828
}
2929

30+
function build_sketch()
31+
{
32+
local arduino=$1
33+
local sketch=$2
34+
$arduino --verify $sketch;
35+
local result=$?
36+
if [ $result -ne 0 ]; then
37+
echo "Build failed ($sketch) build verbose..."
38+
$arduino --verify --verbose --preserve-temp-files $sketch
39+
result=$?
40+
fi
41+
if [ $result -ne 0 ]; then
42+
echo "Build failed ($1) $sketch"
43+
return $result
44+
fi
45+
}
46+
47+
function get_sketches_json()
48+
{
49+
local arduino=$1
50+
local srcpath=$2
51+
local platform=$3
52+
local sketches=($(find $srcpath -name *.ino))
53+
echo -en "["
54+
for sketch in "${sketches[@]}" ; do
55+
local sketchdir=$(dirname $sketch)
56+
if [[ -f "$sketchdir/.$platform.skip" ]]; then
57+
continue
58+
fi
59+
echo -en "\"$sketch\""
60+
if [[ $sketch != ${sketches[-1]} ]] ; then
61+
echo -en ","
62+
fi
63+
64+
done
65+
echo -en "]"
66+
}
67+
68+
function get_sketches_json_matrix()
69+
{
70+
local arduino=$1
71+
local srcpath=$2
72+
local platform=$3
73+
local ideversion=$4
74+
local board=$5
75+
local sketches=($(find $srcpath -name *.ino))
76+
for sketch in "${sketches[@]}" ; do
77+
local sketchdir=$(dirname $sketch)
78+
local sketchname=$(basename $sketch)
79+
if [[ -f "$sketchdir/.$platform.skip" ]]; then
80+
continue
81+
fi
82+
echo -en "{\"name\":\"$sketchname\",\"board\":\"$board\",\"ideversion\":\"$ideversion\",\"cpu\":\"$platform\",\"sketch\":\"$sketch\"}"
83+
if [[ $sketch != ${sketches[-1]} ]] ; then
84+
echo -en ","
85+
fi
86+
done
87+
}
88+
89+
3090

3191
function get_core()
3292
{
@@ -38,15 +98,19 @@ function get_core()
3898
mkdir esp8266com
3999
cd esp8266com
40100
git clone https://github.com/esp8266/Arduino.git esp8266
41-
cd esp8266/tools
101+
cd esp8266/
102+
rm -rf .git
103+
cd tools
42104
python get.py
43105
fi
44106

45107
if [ "$1" = "esp32" ] ; then
46108
mkdir espressif
47109
cd espressif
48110
git clone https://github.com/espressif/arduino-esp32.git esp32
49-
cd esp32/tools
111+
cd esp32/
112+
rm -rf .git
113+
cd tools
50114
python get.py
51115
fi
52116

0 commit comments

Comments
 (0)
0