Unverified Commit d0b064a1 authored by Me No Dev's avatar Me No Dev Committed by GitHub

Update CI scripts for better error handling (#3316)

parent 85c77a9c
......@@ -2,39 +2,33 @@
export ARDUINO_ESP32_PATH="$ARDUINO_USR_PATH/hardware/espressif/esp32"
if [ ! -d "$ARDUINO_ESP32_PATH" ]; then
echo "Installing ESP32 Arduino Core in '$ARDUINO_ESP32_PATH'..."
echo "Installing ESP32 Arduino Core ..."
script_init_path="$PWD"
mkdir -p "$ARDUINO_USR_PATH/hardware/espressif" && \
mkdir -p "$ARDUINO_USR_PATH/hardware/espressif"
cd "$ARDUINO_USR_PATH/hardware/espressif"
if [ $? -ne 0 ]; then exit 1; fi
echo "Installing Python Serial ..."
pip install pyserial > /dev/null
if [ "$OS_IS_WINDOWS" == "1" ]; then
echo "Installing Python Requests ..."
pip install requests > /dev/null
fi
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
echo "Linking Core..." && \
echo "Linking Core..."
ln -s $GITHUB_WORKSPACE esp32
else
echo "Cloning Core Repository..." && \
echo "Cloning Core Repository..."
git clone https://github.com/espressif/arduino-esp32.git esp32 > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: GIT clone failed"; exit 1; fi
fi
cd esp32 && \
echo "Updating Submodules..." && \
echo "Updating Submodules ..."
cd esp32
git submodule update --init --recursive > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Submodule update failed"; exit 1; fi
echo "Installing Python Serial..." && \
pip install pyserial > /dev/null
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
if [ "$OS_IS_WINDOWS" == "1" ]; then
echo "Installing Python Requests..."
pip install requests > /dev/null
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
fi
echo "Installing Platform Tools..."
echo "Installing Platform Tools ..."
cd tools && python get.py
if [ $? -ne 0 ]; then echo "ERROR: Download failed"; exit 1; fi
cd $script_init_path
echo "ESP32 Arduino has been installed in '$ARDUINO_ESP32_PATH'"
......
......@@ -46,28 +46,23 @@ else
fi
if [ ! -d "$ARDUINO_IDE_PATH" ]; then
echo "Installing Arduino IDE on $OS_NAME..."
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT'..."
echo "Installing Arduino IDE on $OS_NAME ..."
echo "Downloading 'arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT' to 'arduino.$ARCHIVE_FORMAT' ..."
if [ "$OS_IS_LINUX" == "1" ]; then
wget -O "arduino.$ARCHIVE_FORMAT" "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Download failed"; exit 1; fi
echo "Extracting 'arduino.$ARCHIVE_FORMAT'..."
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
tar xf "arduino.$ARCHIVE_FORMAT" > /dev/null
if [ $? -ne 0 ]; then exit 1; fi
mv arduino-nightly "$ARDUINO_IDE_PATH"
else
curl -o "arduino.$ARCHIVE_FORMAT" -L "https://www.arduino.cc/download.php?f=/arduino-nightly-$OS_NAME.$ARCHIVE_FORMAT" > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Download failed"; exit 1; fi
echo "Extracting 'arduino.$ARCHIVE_FORMAT'..."
echo "Extracting 'arduino.$ARCHIVE_FORMAT' ..."
unzip "arduino.$ARCHIVE_FORMAT" > /dev/null
if [ $? -ne 0 ]; then exit 1; fi
if [ "$OS_IS_MACOS" == "1" ]; then
mv "Arduino.app" "/Applications/Arduino.app"
else
mv arduino-nightly "$ARDUINO_IDE_PATH"
fi
fi
if [ $? -ne 0 ]; then exit 1; fi
rm -rf "arduino.$ARCHIVE_FORMAT"
mkdir -p "$ARDUINO_USR_PATH/libraries"
......@@ -95,7 +90,7 @@ function build_sketch(){ # build_sketch <fqbn> <path-to-ino> [extra-options]
fi
echo ""
echo "Compiling '"$(basename "$sketch")"'..."
echo "Compiling '"$(basename "$sketch")"' ..."
mkdir -p "$ARDUINO_BUILD_DIR"
mkdir -p "$ARDUINO_CACHE_DIR"
$ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=10810 \
......@@ -115,9 +110,13 @@ function build_sketch(){ # build_sketch <fqbn> <path-to-ino> [extra-options]
function count_sketches() # count_sketches <examples-path>
{
local examples="$1"
rm -rf sketches.txt
if [ ! -d "$examples" ]; then
touch sketches.txt
return 0
fi
local sketches=$(find $examples -name *.ino)
local sketchnum=0
rm -rf sketches.txt
for sketch in $sketches; do
local sketchdir=$(dirname $sketch)
local sketchdirname=$(basename $sketchdir)
......@@ -163,8 +162,10 @@ function build_sketches() # build_sketches <fqbn> <examples-path> <chunk> <total
return 1
fi
set +e
count_sketches "$examples"
local sketchcount=$?
set -e
local sketches=$(cat sketches.txt)
rm -rf sketches.txt
......
......@@ -2,40 +2,34 @@
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
echo "Installing Python Wheel..."
echo "Installing Python Wheel ..."
pip install wheel > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
echo "Installing PlatformIO..."
echo "Installing PlatformIO ..."
pip install -U https://github.com/platformio/platformio/archive/develop.zip > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
echo "Installing Platform ESP32..."
echo "Installing Platform ESP32 ..."
python -m platformio platform install https://github.com/platformio/platform-espressif32.git#feature/stage > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: Install failed"; exit 1; fi
echo "Replacing the framework version..."
echo "Replacing the framework version ..."
if [[ "$OSTYPE" == "darwin"* ]]; then
sed 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' "$HOME/.platformio/platforms/espressif32/platform.json" > "platform.json" && \
sed 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' "$HOME/.platformio/platforms/espressif32/platform.json" > "platform.json"
mv -f "platform.json" "$HOME/.platformio/platforms/espressif32/platform.json"
else
sed -i 's/https:\/\/github\.com\/espressif\/arduino-esp32\.git/*/' "$HOME/.platformio/platforms/espressif32/platform.json"
fi
if [ $? -ne 0 ]; then echo "ERROR: Replace failed"; exit 1; fi
if [ "$GITHUB_REPOSITORY" == "espressif/arduino-esp32" ]; then
echo "Linking Core..." && \
echo "Linking Core..."
ln -s $GITHUB_WORKSPACE "$PLATFORMIO_ESP32_PATH"
else
echo "Cloning Core Repository..." && \
echo "Cloning Core Repository ..."
git clone https://github.com/espressif/arduino-esp32.git "$PLATFORMIO_ESP32_PATH" > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "ERROR: GIT clone failed"; exit 1; fi
fi
echo "PlatformIO for ESP32 has been installed"
echo ""
function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
if [ "$#" -lt 2 ]; then
echo "ERROR: Illegal number of parameters"
......@@ -43,20 +37,24 @@ function build_pio_sketch(){ # build_pio_sketch <board> <path-to-ino>
return 1
fi
local board="$1"
local sketch="$2"
local sketch_dir=$(dirname "$sketch")
echo ""
echo "Compiling '"$(basename "$sketch")"'..."
python -m platformio ci --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv"
local board="$1"
local sketch="$2"
local sketch_dir=$(dirname "$sketch")
echo ""
echo "Compiling '"$(basename "$sketch")"' ..."
python -m platformio ci --board "$board" "$sketch_dir" --project-option="board_build.partitions = huge_app.csv"
}
function count_sketches() # count_sketches <examples-path>
{
local examples="$1"
local examples="$1"
rm -rf sketches.txt
if [ ! -d "$examples" ]; then
touch sketches.txt
return 0
fi
local sketches=$(find $examples -name *.ino)
local sketchnum=0
rm -rf sketches.txt
for sketch in $sketches; do
local sketchdir=$(dirname $sketch)
local sketchdirname=$(basename $sketchdir)
......@@ -91,35 +89,37 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
chunks_num="1"
fi
if [ "$chunks_num" -le 0 ]; then
echo "ERROR: Chunks count must be positive number"
return 1
fi
if [ "$chunk_idex" -ge "$chunks_num" ]; then
echo "ERROR: Chunk index must be less than chunks count"
return 1
fi
if [ "$chunks_num" -le 0 ]; then
echo "ERROR: Chunks count must be positive number"
return 1
fi
if [ "$chunk_idex" -ge "$chunks_num" ]; then
echo "ERROR: Chunk index must be less than chunks count"
return 1
fi
set +e
count_sketches "$examples"
local sketchcount=$?
set -e
local sketches=$(cat sketches.txt)
rm -rf sketches.txt
local chunk_size=$(( $sketchcount / $chunks_num ))
local all_chunks=$(( $chunks_num * $chunk_size ))
if [ "$all_chunks" -lt "$sketchcount" ]; then
chunk_size=$(( $chunk_size + 1 ))
chunk_size=$(( $chunk_size + 1 ))
fi
local start_index=$(( $chunk_idex * $chunk_size ))
if [ "$sketchcount" -le "$start_index" ]; then
echo "Skipping job"
return 0
echo "Skipping job"
return 0
fi
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
if [ "$end_index" -gt "$sketchcount" ]; then
end_index=$sketchcount
end_index=$sketchcount
fi
local start_num=$(( $start_index + 1 ))
......@@ -141,7 +141,7 @@ function build_pio_sketches() # build_pio_sketches <board> <examples-path> <chun
sketchnum=$(($sketchnum + 1))
if [ "$sketchnum" -le "$start_index" ] \
|| [ "$sketchnum" -gt "$end_index" ]; then
continue
continue
fi
build_pio_sketch "$board" "$sketch"
local result=$?
......
#!/bin/bash
set -e
if [ ! -z "$TRAVIS_TAG" ]; then
echo "Skipping Test: Tagged build"
exit 0
......@@ -52,7 +54,6 @@ if [ "$BUILD_PIO" -eq 0 ]; then
# CMake Test
if [ "$CHUNK_INDEX" -eq 0 ]; then
bash "$ARDUINO_ESP32_PATH/.github/scripts/check-cmakelists.sh"
if [ $? -ne 0 ]; then exit 1; fi
fi
build_sketches "$FQBN" "$ARDUINO_ESP32_PATH/libraries" "$CHUNK_INDEX" "$CHUNKS_CNT"
fi
......@@ -68,4 +69,3 @@ else
build_pio_sketch "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/ESP32/examples/Camera/CameraWebServer/CameraWebServer.ino"
#build_pio_sketches esp32dev "$PLATFORMIO_ESP32_PATH/libraries"
fi
if [ $? -ne 0 ]; then exit 1; fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment