From 399f2faf0c855b25ced7a16b07026c6c05a1da75 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 28 Feb 2020 08:16:01 +0100 Subject: [PATCH 1/5] [CI] Reduce unnecessary output from action Signed-off-by: Frederic Pillon --- .github/actions/pio-build/Dockerfile | 4 ++-- .github/actions/pio-build/entrypoint.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/pio-build/Dockerfile b/.github/actions/pio-build/Dockerfile index c6ff9d567f..8a00581cb7 100644 --- a/.github/actions/pio-build/Dockerfile +++ b/.github/actions/pio-build/Dockerfile @@ -5,10 +5,10 @@ ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 # Install prerequisites -RUN apt-get update && apt-get install -y git python3 python3-pip wget +RUN apt-get --quiet=2 update && apt-get install --quiet=2 -y git python3 python3-pip wget # Install PlatformIO -RUN pip3 install -U platformio +RUN pip3 install --quiet --upgrade platformio CMD /bin/bash # Copies your code file from your action repository to the filesystem path `/` of the container diff --git a/.github/actions/pio-build/entrypoint.sh b/.github/actions/pio-build/entrypoint.sh index 3ddc08c7bd..af4338dcd0 100755 --- a/.github/actions/pio-build/entrypoint.sh +++ b/.github/actions/pio-build/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash CMSIS_VERSION=$1 CMSIS_ARCHIVE=CMSIS-${CMSIS_VERSION}.tar.bz2 @@ -11,8 +11,8 @@ python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/pl ln -sf $GITHUB_WORKSPACE $HOME/.platformio/packages/framework-arduinoststm32 # Download and unpack CMSIS package -wget https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/CMSIS-$CMSIS_VERSION.tar.bz2 -tar -xvjf CMSIS-$CMSIS_VERSION.tar.bz2 +wget --no-verbose https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/CMSIS-$CMSIS_VERSION.tar.bz2 +tar -xjf CMSIS-$CMSIS_VERSION.tar.bz2 cd $GITHUB_WORKSPACE/CI/build/ python3 platformio-builder.py --board=blackpill_f103c8 --board=remram_v1 From ac883e469298172cfd26b4566bc76b7260bb4ca2 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 28 Feb 2020 08:28:28 +0100 Subject: [PATCH 2/5] [CI] Make action scripts ShellCheck compliant ShellCheck is a static analysis tool for shell scripts. https://www.shellcheck.net/ Signed-off-by: Frederic Pillon --- .github/actions/pio-build/entrypoint.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/pio-build/entrypoint.sh b/.github/actions/pio-build/entrypoint.sh index af4338dcd0..b82f1425a8 100755 --- a/.github/actions/pio-build/entrypoint.sh +++ b/.github/actions/pio-build/entrypoint.sh @@ -1,19 +1,19 @@ #!/bin/bash -CMSIS_VERSION=$1 -CMSIS_ARCHIVE=CMSIS-${CMSIS_VERSION}.tar.bz2 +CMSIS_VERSION="$1" +CMSIS_ARCHIVE="CMSIS-${CMSIS_VERSION}.tar.bz2" # Install the development version of ststm32 platform -platformio platform install https://github.com/platformio/platform-ststm32.git +platformio platform install "https://github.com/platformio/platform-ststm32.git" # Prepare framework for CI python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" -ln -sf $GITHUB_WORKSPACE $HOME/.platformio/packages/framework-arduinoststm32 +ln -sf "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" # Download and unpack CMSIS package -wget --no-verbose https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/CMSIS-$CMSIS_VERSION.tar.bz2 -tar -xjf CMSIS-$CMSIS_VERSION.tar.bz2 -cd $GITHUB_WORKSPACE/CI/build/ +wget --no-verbose "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/$CMSIS_ARCHIVE" +tar -xjf "$CMSIS_ARCHIVE" +cd "$GITHUB_WORKSPACE/CI/build/" python3 platformio-builder.py --board=blackpill_f103c8 --board=remram_v1 exit $? From 7cb45c2e8621a02022eabd82fb17e255c69bbf5c Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 28 Feb 2020 08:29:02 +0100 Subject: [PATCH 3/5] [CI] Handle failed commands in PlatformIO action Signed-off-by: Frederic Pillon --- .github/actions/pio-build/entrypoint.sh | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/actions/pio-build/entrypoint.sh b/.github/actions/pio-build/entrypoint.sh index b82f1425a8..8456cca526 100755 --- a/.github/actions/pio-build/entrypoint.sh +++ b/.github/actions/pio-build/entrypoint.sh @@ -4,16 +4,26 @@ CMSIS_VERSION="$1" CMSIS_ARCHIVE="CMSIS-${CMSIS_VERSION}.tar.bz2" # Install the development version of ststm32 platform -platformio platform install "https://github.com/platformio/platform-ststm32.git" - +platformio platform install "https://github.com/platformio/platform-ststm32.git" || { + exit 1 +} # Prepare framework for CI -python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" - -ln -sf "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" +python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" || { + exit 1 +} +ln -sf "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" || { + exit 1 +} # Download and unpack CMSIS package -wget --no-verbose "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/$CMSIS_ARCHIVE" -tar -xjf "$CMSIS_ARCHIVE" -cd "$GITHUB_WORKSPACE/CI/build/" +wget --no-verbose "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/$CMSIS_ARCHIVE" || { + exit 1 +} +tar -xjf "$CMSIS_ARCHIVE" || { + exit 1 +} +cd "$GITHUB_WORKSPACE/CI/build/" || { + exit 1 +} python3 platformio-builder.py --board=blackpill_f103c8 --board=remram_v1 exit $? From cd65f22f404ddaae4d82ba3ce8f50316edf16f74 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 28 Feb 2020 08:30:57 +0100 Subject: [PATCH 4/5] [CI] Make variables readonly in PlatformIO actions Signed-off-by: Frederic Pillon --- .github/actions/pio-build/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/pio-build/entrypoint.sh b/.github/actions/pio-build/entrypoint.sh index 8456cca526..1609a82eca 100755 --- a/.github/actions/pio-build/entrypoint.sh +++ b/.github/actions/pio-build/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash -CMSIS_VERSION="$1" -CMSIS_ARCHIVE="CMSIS-${CMSIS_VERSION}.tar.bz2" +readonly CMSIS_VERSION="$1" +readonly CMSIS_ARCHIVE="CMSIS-${CMSIS_VERSION}.tar.bz2" # Install the development version of ststm32 platform platformio platform install "https://github.com/platformio/platform-ststm32.git" || { From 6958c5638e70d18e2761ad5c48a4ceab37b6bb14 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 28 Feb 2020 08:32:04 +0100 Subject: [PATCH 5/5] [CI] Use long option names in commands of the action Signed-off-by: Frederic Pillon --- .github/actions/pio-build/Dockerfile | 2 +- .github/actions/pio-build/entrypoint.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/pio-build/Dockerfile b/.github/actions/pio-build/Dockerfile index 8a00581cb7..edf0d63576 100644 --- a/.github/actions/pio-build/Dockerfile +++ b/.github/actions/pio-build/Dockerfile @@ -5,7 +5,7 @@ ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 # Install prerequisites -RUN apt-get --quiet=2 update && apt-get install --quiet=2 -y git python3 python3-pip wget +RUN apt-get --quiet=2 update && apt-get install --quiet=2 --assume-yes git python3 python3-pip wget # Install PlatformIO RUN pip3 install --quiet --upgrade platformio diff --git a/.github/actions/pio-build/entrypoint.sh b/.github/actions/pio-build/entrypoint.sh index 1609a82eca..b51c1ba630 100755 --- a/.github/actions/pio-build/entrypoint.sh +++ b/.github/actions/pio-build/entrypoint.sh @@ -11,14 +11,14 @@ platformio platform install "https://github.com/platformio/platform-ststm32.git" python3 -c "import json; import os; fp=open(os.path.expanduser('~/.platformio/platforms/ststm32/platform.json'), 'r+'); data=json.load(fp); data['packages']['framework-arduinoststm32']['version'] = '*'; fp.seek(0); fp.truncate(); json.dump(data, fp); fp.close()" || { exit 1 } -ln -sf "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" || { +ln --symbolic "$GITHUB_WORKSPACE" "$HOME/.platformio/packages/framework-arduinoststm32" || { exit 1 } # Download and unpack CMSIS package wget --no-verbose "https://github.com/stm32duino/ArduinoModule-CMSIS/releases/download/$CMSIS_VERSION/$CMSIS_ARCHIVE" || { exit 1 } -tar -xjf "$CMSIS_ARCHIVE" || { +tar --extract --bzip2 --file="$CMSIS_ARCHIVE" || { exit 1 } cd "$GITHUB_WORKSPACE/CI/build/" || {