Skip to content

Commit caa391a

Browse files
authored
More efficient CI builds (#3303)
* More efficient CI builds * Update main.yml
1 parent 3b71e13 commit caa391a

File tree

5 files changed

+103
-66
lines changed

5 files changed

+103
-66
lines changed

.github/workflows/main.yml

+12-21
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,34 @@ on:
88
pull_request:
99

1010
jobs:
11-
11+
12+
# Ubuntu
1213
build-arduino-linux:
1314
name: Arduino ${{ matrix.chunk }} on ubuntu-latest
1415
runs-on: ubuntu-latest
1516
strategy:
1617
matrix:
17-
chunk: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
18+
chunk: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
1819

1920
steps:
2021
- uses: actions/checkout@v1
2122
- name: Build Sketches
22-
run: bash ./tools/ci/on-push.sh ${{ matrix.chunk }} 12
23+
run: bash ./tools/ci/on-push.sh ${{ matrix.chunk }} 15
2324

24-
build-arduino-mac:
25-
name: Arduino ${{ matrix.chunk }} on macOS-latest
26-
runs-on: macOS-latest
27-
strategy:
28-
matrix:
29-
chunk: [3, 6]
30-
31-
steps:
32-
- uses: actions/checkout@v1
33-
- name: Build Sketches
34-
run: bash ./tools/ci/on-push.sh ${{ matrix.chunk }} 12
35-
36-
build-arduino-win:
37-
name: Arduino ${{ matrix.chunk }} on windows-latest
38-
runs-on: windows-latest
25+
# Windows and MacOS
26+
build-arduino-win-mac:
27+
name: Arduino on ${{ matrix.os }}
28+
runs-on: ${{ matrix.os }}
3929
strategy:
4030
matrix:
41-
chunk: [5, 15, 25]
31+
os: [windows-latest, macOS-latest]
4232

4333
steps:
4434
- uses: actions/checkout@v1
4535
- name: Build Sketches
46-
run: bash ./tools/ci/on-push.sh ${{ matrix.chunk }} 30
36+
run: bash ./tools/ci/on-push.sh
4737

38+
# PlatformIO on Windows, Ubuntu and Mac
4839
build-platformio:
4940
name: PlatformIO on ${{ matrix.os }}
5041
runs-on: ${{ matrix.os }}
@@ -55,4 +46,4 @@ jobs:
5546
steps:
5647
- uses: actions/checkout@v1
5748
- name: Build Sketches
58-
run: bash ./tools/ci/on-push.sh 1 1
49+
run: bash ./tools/ci/on-push.sh 1 1 #equal and non-zero to trigger PIO

tools/ci/install-arduino-core-esp32.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/bash
22

3-
if [ ! -d "$ARDUINO_USR_PATH/hardware/espressif/esp32" ]; then
4-
echo "Installing ESP32 Arduino Core in '$ARDUINO_USR_PATH/hardware/espressif/esp32'..."
3+
export ARDUINO_ESP32_PATH="$ARDUINO_USR_PATH/hardware/espressif/esp32"
4+
if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
5+
echo "Installing ESP32 Arduino Core in '$ARDUINO_ESP32_PATH'..."
56
script_init_path="$PWD"
67
mkdir -p "$ARDUINO_USR_PATH/hardware/espressif" && \
78
cd "$ARDUINO_USR_PATH/hardware/espressif"
@@ -36,6 +37,6 @@ if [ ! -d "$ARDUINO_USR_PATH/hardware/espressif/esp32" ]; then
3637
if [ $? -ne 0 ]; then echo "ERROR: Download failed"; exit 1; fi
3738
cd $script_init_path
3839

39-
echo "ESP32 Arduino has been installed in '$ARDUINO_USR_PATH/hardware/espressif/esp32'"
40+
echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'"
4041
echo ""
4142
fi

tools/ci/install-arduino-ide.sh

+28-14
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ else
4545
export ARDUINO_USR_PATH="$HOME/Arduino"
4646
fi
4747

48-
echo "Installing Arduino IDE on $OS_NAME..."
49-
5048
if [ ! -d "$ARDUINO_IDE_PATH" ]; then
49+
echo "Installing Arduino IDE on $OS_NAME..."
5150
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT'..."
5251
if [ "$OS_IS_LINUX" == "1" ]; then
5352
wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
@@ -70,12 +69,21 @@ if [ ! -d "$ARDUINO_IDE_PATH" ]; then
7069
fi
7170
if [ $? -ne 0 ]; then exit 1; fi
7271
rm -rf "arduino.$ARCHIVE_FORMAT"
73-
fi
7472

75-
mkdir -p "$ARDUINO_USR_PATH/libraries"
76-
mkdir -p "$ARDUINO_USR_PATH/hardware"
73+
mkdir -p "$ARDUINO_USR_PATH/libraries"
74+
mkdir -p "$ARDUINO_USR_PATH/hardware"
75+
76+
echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'"
77+
echo ""
78+
fi
7779

7880
function build_sketch(){ # build_sketch <fqbn> <path-to-ino> [extra-options]
81+
if [ "$#" -lt 2 ]; then
82+
echo "ERROR: Illegal number of parameters"
83+
echo "USAGE: build_sketch <fqbn> <path-to-ino> [extra-options]"
84+
return 1
85+
fi
86+
7987
local fqbn="$1"
8088
local sketch="$2"
8189
local xtra_opts="$3"
@@ -126,14 +134,26 @@ function count_sketches() # count_sketches <examples-path>
126134
return $sketchnum
127135
}
128136

129-
function build_sketches() # build_sketches <examples-path> <fqbn> <chunk> <total-chunks> [extra-options]
137+
function build_sketches() # build_sketches <fqbn> <examples-path> <chunk> <total-chunks> [extra-options]
130138
{
131-
local examples=$1
132-
local fqbn=$2
139+
local fqbn=$1
140+
local examples=$2
133141
local chunk_idex=$3
134142
local chunks_num=$4
135143
local xtra_opts=$5
136144

145+
if [ "$#" -lt 2 ]; then
146+
echo "ERROR: Illegal number of parameters"
147+
echo "USAGE: build_sketches <fqbn> <examples-path> [<chunk> <total-chunks>] [extra-options]"
148+
return 1
149+
fi
150+
151+
if [ "$#" -lt 4 ]; then
152+
chunk_idex="0"
153+
chunks_num="1"
154+
xtra_opts=$3
155+
fi
156+
137157
if [ "$chunks_num" -le 0 ]; then
138158
echo "ERROR: Chunks count must be positive number"
139159
return 1
@@ -195,9 +215,3 @@ function build_sketches() # build_sketches <examples-path> <fqbn> <chunk> <total
195215
return 0
196216
}
197217

198-
echo "Arduino IDE Installed in '$ARDUINO_IDE_PATH'"
199-
# echo "You can install boards in '$ARDUINO_IDE_PATH/hardware' or in '$ARDUINO_USR_PATH/hardware'"
200-
# echo "User libraries should be installed in '$ARDUINO_USR_PATH/libraries'"
201-
# echo "Then you can call 'build_sketch <fqbn> <path-to-ino> [extra-options]' to build your sketches"
202-
echo ""
203-

tools/ci/install-platformio-esp32.sh

+25-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
4+
35
echo "Installing Python Wheel..."
46
pip install wheel > /dev/null 2>&1
57
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
@@ -23,18 +25,24 @@ if [ $? -ne 0 ]; then echo "ERROR: Replace failed"; exit 1; fi
2325

2426
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
2527
echo "Linking Core..." && \
26-
ln -s $GITHUB_WORKSPACE "$HOME/.platformio/packages/framework-arduinoespressif32"
28+
ln -s $GITHUB_WORKSPACE "$PLATFORMIO_ESP32_PATH"
2729
else
2830
echo "Cloning Core Repository..." && \
29-
git clone https://github.com/espressif/arduino-esp32.git "$HOME/.platformio/packages/framework-arduinoespressif32" > /dev/null 2>&1
31+
git clone https://github.com/espressif/arduino-esp32.git "$PLATFORMIO_ESP32_PATH" > /dev/null 2>&1
3032
if [ $? -ne 0 ]; then echo "ERROR: GIT clone failed"; exit 1; fi
3133
fi
3234

3335
echo "PlatformIO for ESP32 has been installed"
3436
echo ""
3537

3638

37-
function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino> [extra-options]
39+
function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
40+
if [ "$#" -lt 2 ]; then
41+
echo "ERROR: Illegal number of parameters"
42+
echo "USAGE: build_pio_sketch <board> <path-to-ino>"
43+
return 1
44+
fi
45+
3846
local board="$1"
3947
local sketch="$2"
4048
local sketch_dir=$(dirname "$sketch")
@@ -65,13 +73,24 @@ function count_sketches() # count_sketches <examples-path>
6573
return $sketchnum
6674
}
6775

68-
function build_pio_sketches() # build_pio_sketches <examples-path> <board> <chunk> <total-chunks>
76+
function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chunk> <total-chunks>
6977
{
70-
local examples=$1
71-
local board=$2
78+
if [ "$#" -lt 2 ]; then
79+
echo "ERROR: Illegal number of parameters"
80+
echo "USAGE: build_pio_sketches <board> <examples-path> [<chunk> <total-chunks>]"
81+
return 1
82+
fi
83+
84+
local board=$1
85+
local examples=$2
7286
local chunk_idex=$3
7387
local chunks_num=$4
7488

89+
if [ "$#" -lt 4 ]; then
90+
chunk_idex="0"
91+
chunks_num="1"
92+
fi
93+
7594
if [ "$chunks_num" -le 0 ]; then
7695
echo "ERROR: Chunks count must be positive number"
7796
return 1

tools/ci/on-push.sh

+34-22
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,50 @@ fi
1919
CHUNK_INDEX=$1
2020
CHUNKS_CNT=$2
2121
BUILD_PIO=0
22-
if [ "$#" -lt 2 ] || [ "$CHUNKS_CNT" -le 0 ]; then
23-
echo "Building all sketches"
22+
if [ "$#" -lt 2 ] || [ "$CHUNKS_CNT" -le 0 ]; then
2423
CHUNK_INDEX=0
2524
CHUNKS_CNT=1
26-
fi
27-
if [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ]; then
25+
elif [ "$CHUNK_INDEX" -gt "$CHUNKS_CNT" ]; then
2826
CHUNK_INDEX=$CHUNKS_CNT
29-
fi
30-
if [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
27+
elif [ "$CHUNK_INDEX" -eq "$CHUNKS_CNT" ]; then
3128
BUILD_PIO=1
3229
fi
3330

34-
# CMake Test
35-
if [ "$CHUNK_INDEX" -eq 0 ]; then
36-
bash ./tools/ci/check-cmakelists.sh
37-
if [ $? -ne 0 ]; then exit 1; fi
38-
fi
39-
4031
if [ "$BUILD_PIO" -eq 0 ]; then
4132
# ArduinoIDE Test
33+
FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
4234
source ./tools/ci/install-arduino-ide.sh
4335
source ./tools/ci/install-arduino-core-esp32.sh
44-
build_sketches "$GITHUB_WORKSPACE/libraries" "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" "$CHUNK_INDEX" "$CHUNKS_CNT"
36+
if [ "$OS_IS_WINDOWS" == "1" ]; then
37+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
38+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
39+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
40+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
41+
elif [ "$OS_IS_MACOS" == "1" ]; then
42+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
43+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
44+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
45+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
46+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
47+
build_sketch "$FQBN" "$ARDUINO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
48+
else
49+
# CMake Test
50+
if [ "$CHUNK_INDEX" -eq 0 ]; then
51+
bash "$ARDUINO_ESP32_PATH/tools/ci/check-cmakelists.sh"
52+
if [ $? -ne 0 ]; then exit 1; fi
53+
fi
54+
build_sketches "$FQBN" "$ARDUINO_ESP32_PATH/libraries" "$CHUNK_INDEX" "$CHUNKS_CNT"
55+
fi
4556
else
4657
# PlatformIO Test
4758
source ./tools/ci/install-platformio-esp32.sh
48-
python -m platformio ci --board esp32dev libraries/WiFi/examples/WiFiClient && \
49-
python -m platformio ci --board esp32dev libraries/WiFiClientSecure/examples/WiFiClientSecure && \
50-
python -m platformio ci --board esp32dev libraries/BluetoothSerial/examples/SerialToSerialBT && \
51-
python -m platformio ci --board esp32dev libraries/BLE/examples/BLE_server && \
52-
python -m platformio ci --board esp32dev libraries/AzureIoT/examples/GetStarted && \
53-
python -m platformio ci --board esp32dev libraries/ESP32/examples/Camera/CameraWebServer --project-option="board_build.partitions = huge_app.csv"
54-
#build_pio_sketches libraries esp32dev $CHUNK_INDEX $CHUNKS_CNT
55-
if [ $? -ne 0 ]; then exit 1; fi
56-
fi
59+
BOARD="esp32dev"
60+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient/WiFiClient.ino" && \
61+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino" && \
62+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/BluetoothSerial/examples/SerialToSerialBT/SerialToSerialBT.ino" && \
63+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/BLE/examples/BLE_server/BLE_server.ino" && \
64+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/AzureIoT/examples/GetStarted/GetStarted.ino" && \
65+
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
66+
#build_pio_sketches esp32dev "$PLATFORMIO_ESP32_PATH/libraries"
67+
fi
68+
if [ $? -ne 0 ]; then exit 1; fi

0 commit comments

Comments
 (0)