Skip to content

fix: various bug fixes and code improvements #3295

fix: various bug fixes and code improvements

fix: various bug fixes and code improvements #3295

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Lint
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main, next]
pull_request:
branches: [main, next]
types: [opened, synchronize, ready_for_review, edited]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
SHELL_SCRIPTS_DIR: internal/inside-distrobox/assets
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: "go.mod"
- run: make test
golangci:
name: Golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: "go.mod"
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.5.0
fmtcheck:
name: Go fmt check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v6.0.1
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: "go.mod"
- name: format check
run: |
make fmt
if [ -n "$(git status --porcelain)" ]; then
echo "Code is not formatted. Please run 'make fmt' and commit the changes."
git --no-pager diff
exit 1
fi
dash:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Run dash -n
run: |
result=0
for file in $(find ${SHELL_SCRIPTS_DIR} -type f); do
if file "$file" | grep -qi shell; then
echo "### Checking file $file..."
dash -n $file
result=$(( result + $? ))
fi
done
exit $result
shfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Run shfmt
run: |
result=0
podman pull docker.io/peterdavehello/shfmt:latest
for file in $(find ${SHELL_SCRIPTS_DIR} -type f); do
if file "$file" | grep -qi shell; then
echo "### Checking file $file..."
podman run --rm -v "$PWD:/mnt" docker.io/peterdavehello/shfmt:latest shfmt -d -s -ci -sr -kp -fn -i=0 -p /mnt/$file
result=$(( result + $? ))
fi
done
exit $result
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
# Exclude from bashate the following rules:
# - SC2310 we don't want to exit if errors happen inside a check, that's why we have a check...
# - SC2311 don't care if we inherit errexit inside substitutions, we do checks for that.
# - SC2312 we already check errors and adding "|| true" everywhere hinders readability.
- name: Run shellcheck
run: |
result=0
podman pull docker.io/koalaman/shellcheck:stable
for file in $(find ${SHELL_SCRIPTS_DIR} -type f); do
if file "$file" | grep -qi shell; then
echo "### Checking file $file..."
# Should read the .shellcheckrc file to behave like -s sh -a -o all -Sstyle -Calways -x -e SC2310,SC2311,SC2312
podman run --rm -v "$PWD:/mnt" docker.io/koalaman/shellcheck:stable -a -Sstyle -Calways $file
result=$(( result + $? ))
fi
done
exit $result
differential-shellcheck:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Run Differential ShellCheck
uses: redhat-plumbers-in-action/differential-shellcheck@v5
with:
severity: style
scan-directory: ${{ env.SHELL_SCRIPTS_DIR }}
token: ${{ secrets.GITHUB_TOKEN }}
bashate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
# Exclude from bashate the following rules:
# - E002 we use tab indentation as suggested by shfmt.
# - E003 we use tab indentation as suggested by shfmt.
# - E010 for readability allow if/then and for/do to be on different lines.
# - E011 for readability allow if/then and for/do to be on different lines.
- name: Run bashate
run: |
sudo pip3 install -U bashate
for file in $(find ${SHELL_SCRIPTS_DIR} -type f); do
if file "$file" | grep -qi shell; then
echo "### Checking file $file..."
bashate -i E002,E003,E010,E011 --max-line-length 120 $file
result=$(( result + $? ))
fi
done
exit $result
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: codespell-project/actions-codespell@v2
with:
skip: .git,*.pdf,*.1,*.css,*.lock
shell-funcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Run shell-funcheck
run: |
curl -L -O https://github.com/89luca89/shell-funcheck/releases/download/v0.0.1/shell-funcheck-amd64
chmod +x ./shell-funcheck-amd64
for i in ${SHELL_SCRIPTS_DIR}/*; do
./shell-funcheck-amd64 check "$i"
done