Skip to content

Commit

Permalink
ci: run script if lint checks pass (#70)
Browse files Browse the repository at this point in the history
* ci: run script if lint checks pass

* fix: install virtualenv dependency

* fix: skip menu select in CI

* refactor: split up the shell commands

* ci: after flash_your_device, run flash_the_ttgo_tdisplay

* ci: run all device-specific scripts

* feat: small improvements

* ci: Run jobs sequentially

* ci: run shfmt in parallel with shellcheck

* ci: set appropriate timeouts

* ci: use actions checkout v4
  • Loading branch information
epiccurious authored Dec 19, 2023
1 parent 0c51090 commit 943c3dc
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 45 deletions.
35 changes: 29 additions & 6 deletions .github/workflows/bash_validation_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,47 @@ on:

workflow_dispatch:

env:
TERM: xterm

jobs:
shellcheck:
name: Validation with ShellCheck
validate-shellcheck:
name: Validate with ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run ShellCheck on jade-diy
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -e SC1091
shfmt-checker:
name: Validation with shfmt

validate-shfmt:
name: Validate with shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run shfmt on jade-diy scripts
uses: luizm/action-sh-checker@master
env:
SHFMT_OPTS: -i 2 -sr
with:
sh_checker_shellcheck_disable: true

run-scripts:
name: Execute the scripts
runs-on: ubuntu-latest
needs: [validate-shellcheck, validate-shfmt]
steps:
- uses: actions/checkout@v4
- name: Install runtime dependency python3-virtualenv
run: sudo apt update && sudo apt install -y python3-virtualenv
- name: Run flash_your_device
run: timeout 240 /bin/bash -x ./flash_your_device
- name: Run flash_the_ttgo_tdisplay
run: timeout 30 /bin/bash -x ./device_specific/flash_the_ttgo_tdisplay
- name: Run flash_the_m5stack_m5stickc_plus
run: timeout 30 /bin/bash -x ./device_specific/flash_the_m5stack_m5stickc_plus
- name: Run flash_the_m5stack_core_basic
run: timeout 30 /bin/bash -x ./device_specific/flash_the_m5stack_core_basic
- name: Run flash_the_m5stack_fire
run: timeout 30 /bin/bash -x ./device_specific/flash_the_m5stack_fire
2 changes: 2 additions & 0 deletions device_specific/flash_the_m5stack_core_basic
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ rm sdkconfig.defaults.bak

idf.py build

[ "${CI:-false}" = true ] && echo "Exiting the script for CI runners." && exit 0

while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo
done
Expand Down
2 changes: 2 additions & 0 deletions device_specific/flash_the_m5stack_fire
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ rm sdkconfig.defaults.bak

idf.py build

[ "${CI:-false}" = true ] && echo "Exiting the script for CI runners." && exit 0

while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo
done
Expand Down
2 changes: 2 additions & 0 deletions device_specific/flash_the_m5stack_m5stickc_plus
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ rm sdkconfig.defaults.bak

idf.py build

[ "${CI:-false}" = true ] && echo "Exiting the script for CI runners." && exit 0

while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo
done
Expand Down
2 changes: 2 additions & 0 deletions device_specific/flash_the_ttgo_tdisplay
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ rm sdkconfig.defaults.bak

idf.py build

[ "${CI:-false}" = true ] && echo "Exiting the script for CI runners." && exit 0

while [ ! -c "${tty_device}" ]; do
read -srn1 -p "Connect your ${chosen_device} and PRESS ANY KEY to continue... " && echo
done
Expand Down
83 changes: 44 additions & 39 deletions flash_your_device
Original file line number Diff line number Diff line change
Expand Up @@ -125,53 +125,58 @@ cd "${jade_save_directory}"
jade_version="$(git describe --tags)"
echo "ok."

echo -e "\nWhich device do you want to flash?"
PS3='Please enter the number for your device or QUIT: '
options=("${device1}" "${device2}" "${device3}" "${device4}" "QUIT")
select choice in "${options[@]}"; do
case "${choice}" in
"${device1}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
break
;;
"${device2}")
tty_device="/dev/ttyUSB0"
flash_command="idf.py -b 115200 flash"
cp configs/sdkconfig_display_m5stickcplus.defaults sdkconfig.defaults
break
;;
"${device3}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_m5blackgray.defaults sdkconfig.defaults
break
;;
"${device4}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_m5fire.defaults sdkconfig.defaults
break
;;
"QUIT")
echo "You chose to quit."
exit 0
;;
*) echo "You entered ${REPLY}, which is invalid." ;;
esac
done
chosen_device="${choice}"
echo
if [ "${CI:-false}" = true ]; then
cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
else
echo -e "\nWhich device do you want to flash?"
PS3='Please enter the number for your device or QUIT: '
options=("${device1}" "${device2}" "${device3}" "${device4}" "QUIT")
select chosen_device in "${options[@]}"; do
case "${chosen_device}" in
"${device1}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_ttgo_tdisplay.defaults sdkconfig.defaults
break
;;
"${device2}")
tty_device="/dev/ttyUSB0"
flash_command="idf.py -b 115200 flash"
cp configs/sdkconfig_display_m5stickcplus.defaults sdkconfig.defaults
break
;;
"${device3}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_m5blackgray.defaults sdkconfig.defaults
break
;;
"${device4}")
tty_device="/dev/ttyACM0"
flash_command="idf.py flash"
cp configs/sdkconfig_display_m5fire.defaults sdkconfig.defaults
break
;;
"QUIT")
echo "You chose to quit."
exit 0
;;
*) echo "You entered ${REPLY}, which is invalid." ;;
esac
done
echo
fi

[ -f sdkconfig ] && rm sdkconfig
sed -i.bak '/CONFIG_DEBUG_MODE/d' ./sdkconfig.defaults
sed -i.bak '1s/^/CONFIG_LOG_DEFUALT_LEVEL_NONE=y\n/' sdkconfig.defaults

echo -n "Creating the Jade firmware... "
echo -n "Building the Jade firmware... "
idf.py build &> /dev/null
echo "ok."

[ "${CI:-false}" = true ] && echo "Exiting the script for CI runners." && exit 0

case "${machine}" in
Linux*)
while [ ! -c "${tty_device}" ]; do
Expand Down

0 comments on commit 943c3dc

Please sign in to comment.