From 6bec5f82837978a58f476dd6cc602d8aa568c984 Mon Sep 17 00:00:00 2001 From: Carter Canedy Date: Tue, 24 Sep 2024 09:08:05 -0700 Subject: [PATCH 1/3] make shellcheck emit all errors found and check for tab indentation --- .github/workflows/shellcheck.yml | 43 +++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index e91ad941..b8d03ab8 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -14,17 +14,42 @@ jobs: - uses: actions/checkout@v4 - run: git fetch origin ${{ github.base_ref }} - - name: Download and set up shellcheck + - name: Download, setup, and run ShellCheck + shell: bash {0} run : | - wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz - tar -xf shellcheck-v0.10.0.linux.x86_64.tar.xz - cd shellcheck-v0.10.0 - chmod +x shellcheck + SC_URL="https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz" + curl -fsSL "$SC_URL" | tar -Jx + chmod +x "./shellcheck-v0.10.0/shellcheck" - - name: Run shellcheck - run: | - for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do + error=0 + files_to_check=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs) + + for file in $files_to_check; do if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then - ./shellcheck-v0.10.0/shellcheck -S error "$file" + sc_output=$(./shellcheck-v0.10.0/shellcheck -fgcc -Serror "$file") + iter_safe_parsed_errors=$(echo -e "$sc_output" | sed -n 's/\(.\+\)\:\([0-9]\+\)\:\([0-9]\+\)\: \(.*\)/::error file=\1,line=\2,col=\3::\4/p' | sed 's/ /:space:/g') + + for error in $iter_safe_parsed_errors; do + echo "$error" | sed 's/:space:/ /g' + error=1 + done + + tabs_detected=$(grep -nP '^\t+\S+' "$file") + + # fast fail on the action runner would fail immediately if there weren't any tabs found + # this check makes sure that we don't continue if there's something really weird going on + if [ "$?" = "2" ]; then + echo "::error file=$file::There was a critical while grepping $file, aborting" + exit 1 + fi + + iter_safe_parsed_tabs_detected=$(echo "$tabs_detected" | sed -n 's,\([0-9]\+\).*,::error file='"$file"'\,line=\1::Found tab indentations,p' | sed 's/ /:space:/g') + + for error in $iter_safe_parsed_tabs_detected; do + echo "$error" | sed 's/:space:/ /g' + error=1 + done fi done + + exit $error From 73f6e24396e8392bf64f18857f18bbebf696f10f Mon Sep 17 00:00:00 2001 From: Carter Canedy Date: Wed, 2 Oct 2024 12:59:04 -0700 Subject: [PATCH 2/3] expand tabs with spaces --- .../Developer-tools/sublime-setup.sh | 62 +++++++++---------- core/tabs/system-setup/arch/server-setup.sh | 8 +-- start.sh | 4 +- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/core/tabs/applications-setup/Developer-tools/sublime-setup.sh b/core/tabs/applications-setup/Developer-tools/sublime-setup.sh index 0bbe87b7..16c03497 100644 --- a/core/tabs/applications-setup/Developer-tools/sublime-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/sublime-setup.sh @@ -3,37 +3,37 @@ . ../../common-script.sh installSublime() { - if ! command_exists sublime; then - printf "%b\n" "${YELLOW}Installing Sublime...${RC}" - case "$PACKAGER" in - apt-get|nala) - curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add - - echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list - "$ESCALATION_TOOL" "$PACKAGER" update - "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text - ;; - zypper) - "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg - "$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo - "$ESCALATION_TOOL" "$PACKAGER" refresh - "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text - ;; - pacman) - "$AUR_HELPER" -S --needed --noconfirm sublime-text-4 - ;; - dnf) - "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg - "$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo - "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text - ;; - *) - printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" - exit 1 - ;; - esac - else - printf "%b\n" "${GREEN}Sublime is already installed.${RC}" - fi + if ! command_exists sublime; then + printf "%b\n" "${YELLOW}Installing Sublime...${RC}" + case "$PACKAGER" in + apt-get|nala) + curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add - + echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list + "$ESCALATION_TOOL" "$PACKAGER" update + "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text + ;; + zypper) + "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg + "$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo + "$ESCALATION_TOOL" "$PACKAGER" refresh + "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text + ;; + pacman) + "$AUR_HELPER" -S --needed --noconfirm sublime-text-4 + ;; + dnf) + "$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg + "$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo + "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" + exit 1 + ;; + esac + else + printf "%b\n" "${GREEN}Sublime is already installed.${RC}" + fi } diff --git a/core/tabs/system-setup/arch/server-setup.sh b/core/tabs/system-setup/arch/server-setup.sh index 4ae0afd6..e2600205 100755 --- a/core/tabs/system-setup/arch/server-setup.sh +++ b/core/tabs/system-setup/arch/server-setup.sh @@ -466,7 +466,7 @@ if [[ $TOTAL_MEM -lt 8000000 ]]; then mkswap /mnt/opt/swap/swapfile swapon /mnt/opt/swap/swapfile # The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself. - echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. + echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. fi gpu_type=$(lspci | grep -E "VGA|3D|Display") @@ -493,8 +493,8 @@ nc=$(grep -c ^processor /proc/cpuinfo) echo -ne " ------------------------------------------------------------------------- You have " $nc" cores. And - changing the makeflags for " $nc" cores. Aswell as - changing the compression settings. + changing the makeflags for " $nc" cores. Aswell as + changing the compression settings. ------------------------------------------------------------------------- " TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') @@ -670,4 +670,4 @@ sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: A # Add sudo rights sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers -EOF \ No newline at end of file +EOF diff --git a/start.sh b/start.sh index fd69cbec..3c412fb6 100755 --- a/start.sh +++ b/start.sh @@ -14,8 +14,8 @@ check() { exit 1 fi - unset exit_code - unset message + unset exit_code + unset message } findArch() { From af9453cc17dcf9bb69335ab1985b3295e7fac0e0 Mon Sep 17 00:00:00 2001 From: cartercanedy <99052281+cartercanedy@users.noreply.github.com> Date: Sat, 5 Oct 2024 19:45:06 -0700 Subject: [PATCH 3/3] fix grammar --- .github/workflows/shellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index b8d03ab8..6b1ad429 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -39,7 +39,7 @@ jobs: # fast fail on the action runner would fail immediately if there weren't any tabs found # this check makes sure that we don't continue if there's something really weird going on if [ "$?" = "2" ]; then - echo "::error file=$file::There was a critical while grepping $file, aborting" + echo "::error file=$file::There was a critical error while grepping $file, aborting" exit 1 fi