Merge pull request #658 from cartercanedy/main

Emit all shellcheck errors using github action toolkit annotations and check for tab indentation
This commit is contained in:
Chris Titus 2024-10-08 15:34:56 -05:00 committed by GitHub
commit 64c34f54c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 70 additions and 45 deletions

View File

@ -14,17 +14,42 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: git fetch origin ${{ github.base_ref }} - run: git fetch origin ${{ github.base_ref }}
- name: Download and set up shellcheck - name: Download, setup, and run ShellCheck
shell: bash {0}
run : | run : |
wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz SC_URL="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 curl -fsSL "$SC_URL" | tar -Jx
cd shellcheck-v0.10.0 chmod +x "./shellcheck-v0.10.0/shellcheck"
chmod +x shellcheck
- name: Run shellcheck error=0
run: | files_to_check=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs)
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do
for file in $files_to_check; do
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then 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 error 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 fi
done done
exit $error

View File

@ -3,37 +3,37 @@
. ../../common-script.sh . ../../common-script.sh
installSublime() { installSublime() {
if ! command_exists sublime; then if ! command_exists sublime; then
printf "%b\n" "${YELLOW}Installing Sublime...${RC}" printf "%b\n" "${YELLOW}Installing Sublime...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala) apt-get|nala)
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add - 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 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" update
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;; ;;
zypper) zypper)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg "$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" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" refresh "$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text
;; ;;
pacman) pacman)
"$AUR_HELPER" -S --needed --noconfirm sublime-text-4 "$AUR_HELPER" -S --needed --noconfirm sublime-text-4
;; ;;
dnf) dnf)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg "$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" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text "$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1 exit 1
;; ;;
esac esac
else else
printf "%b\n" "${GREEN}Sublime is already installed.${RC}" printf "%b\n" "${GREEN}Sublime is already installed.${RC}"
fi fi
} }

View File

@ -466,7 +466,7 @@ if [[ $TOTAL_MEM -lt 8000000 ]]; then
mkswap /mnt/opt/swap/swapfile mkswap /mnt/opt/swap/swapfile
swapon /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. # 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 fi
gpu_type=$(lspci | grep -E "VGA|3D|Display") gpu_type=$(lspci | grep -E "VGA|3D|Display")
@ -493,8 +493,8 @@ nc=$(grep -c ^processor /proc/cpuinfo)
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
You have " $nc" cores. And You have " $nc" cores. And
changing the makeflags for " $nc" cores. Aswell as changing the makeflags for " $nc" cores. Aswell as
changing the compression settings. changing the compression settings.
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')

View File

@ -14,8 +14,8 @@ check() {
exit 1 exit 1
fi fi
unset exit_code unset exit_code
unset message unset message
} }
findArch() { findArch() {