Skip to content

Commit

Permalink
feat: enable shfmt CI check and fix formatting (#58)
Browse files Browse the repository at this point in the history
* refactor: use spaces after redirects

* refactor: reduce indent inside case statements

* refactor: simplify if-then syntax

* refactor: improve syntax for case statements

* refactor: improve format of select-do statement

* refactor: improve indents in if-then statements

* refactor: add a space after redirects

* feat: add shfmt CI check

* refactor: remove unnecessary whitespace

* doc: improve wording
  • Loading branch information
epiccurious authored Dec 16, 2023
1 parent 91b34eb commit 5a6f671
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 152 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/bash_validation_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ jobs:
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: -e SC1091
#
# in case we want to use shfmt too
#shfmt-checker:
# name: Validation with shfmt
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - 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
shfmt-checker:
name: Validation with shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ You are better off buying the hardware directly from the hardware vendor than th

There are three options for flashing your device:
- [**Install with the Semi-Automated Script**](#install-with-the-semi-automated-script) (easiest way)
- [**Install with a Device-Specific Script**](#install-with-a-device-specific-script) (other easy way)
- [**Install with a Device-Specific Script**](#install-with-a-device-specific-script) (another easy way)
- [**Install by Running the Code Manually**](#install-by-running-the-code-manually) (harder way)

### Use the Semi-Automated Script
Expand Down
22 changes: 11 additions & 11 deletions device_specific/flash_the_m5stack_core_basic
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cleanup() {
rm -rf -- "${temp_directory}"
if [ -n "${initial_tty_device_permissions}" ] &&
[ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
fi
}

Expand Down Expand Up @@ -42,36 +42,36 @@ fi

echo "LINUX ONLY. Flashing the ${chosen_device}..."

if ! command -v cmake &>/dev/null; then
if ! command -v cmake &> /dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
elif ! command -v git &> /dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
elif ! command -v pip &> /dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
elif ! command -v virtualenv &> /dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_temp_directory}"/
git submodule update --depth 1 --init --recursive
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
git submodule update --depth 1 --init --recursive
./install.sh esp32 &> /dev/null
source ./export.sh 1> /dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
cd "${esp_idf_save_directory}"/
./install.sh esp32
source ./export.sh

if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive &> /dev/null
git submodule update --depth 1 --init --recursive &> /dev/null
fi
cd "${jade_save_directory}"
jade_version="$(git describe --tags)"
Expand Down
22 changes: 11 additions & 11 deletions device_specific/flash_the_m5stack_fire
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cleanup() {
rm -rf -- "${temp_directory}"
if [ -n "${initial_tty_device_permissions}" ] &&
[ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
fi
}

Expand Down Expand Up @@ -42,36 +42,36 @@ fi

echo "LINUX ONLY. Flashing the ${chosen_device}..."

if ! command -v cmake &>/dev/null; then
if ! command -v cmake &> /dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
elif ! command -v git &> /dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
elif ! command -v pip &> /dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
elif ! command -v virtualenv &> /dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_temp_directory}"/
git submodule update --depth 1 --init --recursive
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
git submodule update --depth 1 --init --recursive
./install.sh esp32 &> /dev/null
source ./export.sh 1> /dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
cd "${esp_idf_save_directory}"/
./install.sh esp32
source ./export.sh

if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive &> /dev/null
git submodule update --depth 1 --init --recursive &> /dev/null
fi
cd "${jade_save_directory}"
jade_version="$(git describe --tags)"
Expand Down
22 changes: 11 additions & 11 deletions device_specific/flash_the_m5stack_m5stickc_plus
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cleanup() {
rm -rf -- "${temp_directory}"
if [ -n "${initial_tty_device_permissions}" ] &&
[ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
fi
}

Expand Down Expand Up @@ -42,36 +42,36 @@ fi

echo "LINUX ONLY. Flashing the ${chosen_device}..."

if ! command -v cmake &>/dev/null; then
if ! command -v cmake &> /dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
elif ! command -v git &> /dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
elif ! command -v pip &> /dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
elif ! command -v virtualenv &> /dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi

if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_temp_directory}"/
git submodule update --depth 1 --init --recursive
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
git submodule update --depth 1 --init --recursive
./install.sh esp32 &> /dev/null
source ./export.sh 1> /dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
cd "${esp_idf_save_directory}"/
./install.sh esp32
source ./export.sh

if [ ! -d "${jade_save_directory}" ]; then
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
git clone --branch "${jade_git_tag}" --single-branch --depth 1 "${jade_repo_url}" "${jade_save_directory}"
cd "${jade_save_directory}"
git submodule update --depth 1 --init --recursive &> /dev/null
git submodule update --depth 1 --init --recursive &> /dev/null
fi
cd "${jade_save_directory}"
jade_version="$(git describe --tags)"
Expand Down
14 changes: 7 additions & 7 deletions device_specific/flash_the_ttgo_tdisplay
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cleanup() {
rm -rf -- "${temp_directory}"
if [ -n "${initial_tty_device_permissions}" ] &&
[ "$(stat -c '%a' "${tty_device}")" != "${initial_tty_device_permissions}" ]; then
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
sudo chmod "${initial_tty_device_permissions}" "${tty_device}"
fi
}

Expand Down Expand Up @@ -42,16 +42,16 @@ fi

echo "LINUX ONLY. Flashing the ${chosen_device}..."

if ! command -v cmake &>/dev/null; then
if ! command -v cmake &> /dev/null; then
echo -e "\nERROR:\ncmake was not found on your system.\nPlease install cmake by running:\n\nsudo apt update && sudo apt install -y cmake\n"
exit 1
elif ! command -v git &>/dev/null; then
elif ! command -v git &> /dev/null; then
echo -e "\nERROR:\ngit was not found on your system.\nPlease install git by running:\n\nsudo apt update && sudo apt install -y git\n"
exit 1
elif ! command -v pip &>/dev/null; then
elif ! command -v pip &> /dev/null; then
echo -e "\n\RROR:\npip was not found on your system.\nPlease install pip by running:\n\nsudo apt update && sudo apt install -y python3-pip\n"
exit 1
elif ! command -v virtualenv &>/dev/null; then
elif ! command -v virtualenv &> /dev/null; then
echo -e "\nERROR:\nvirtualenv was not found on your system.\nPlease install virtualenv by running:\n\nsudo apt update && sudo apt install -y python3-virtualenv\n"
exit 1
fi
Expand All @@ -60,8 +60,8 @@ if [ ! -f "${esp_idf_save_directory}"/export.sh ]; then
git clone --branch "${esp_idf_git_tag}" --single-branch --depth 1 "${esp_idf_repo_url}" "${esp_idf_temp_directory}"
cd "${esp_idf_temp_directory}"/
git submodule update --depth 1 --init --recursive
./install.sh esp32 &>/dev/null
source ./export.sh 1>/dev/null
./install.sh esp32 &> /dev/null
source ./export.sh 1> /dev/null
mv "${esp_idf_temp_directory}" "${esp_idf_save_directory}"
fi
cd "${esp_idf_save_directory}"/
Expand Down
Loading

0 comments on commit 5a6f671

Please sign in to comment.