Skip to content

Commit

Permalink
add shellcheck script and workflow
Browse files Browse the repository at this point in the history
add yamllint and workflow

Signed-off-by: Robert Marklund <[email protected]>
  • Loading branch information
trollkarlen committed Jan 23, 2025
1 parent 6626b26 commit e22a83e
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: run shellcheck on scripts

"on":
push:
branches:
- main
- devel
pull_request:


jobs:
build:
name: Runs the shellcheck on scripts
runs-on: ubuntu-24.04

steps:
- name: checkout
uses: actions/checkout@v4
- name: install packages
run: sudo apt install shellcheck
- name: run shellcheck
run: ./do_shellcheck.sh
25 changes: 25 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: run yamllint on files

"on":
push:
branches:
- main
- devel
pull_request:


jobs:
build:
name: Runs the yamllint on files
runs-on: ubuntu-24.04

steps:
- name: checkout
uses: actions/checkout@v4
- name: install packages
run: sudo apt install python3
- name: install yamllint
run: python3 -m venv .venv && .venv/bin/python3 -m pip install yamllint
- name: run yamllint
run: ./do_yamllint.sh
21 changes: 21 additions & 0 deletions do_shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

me=$(basename "$0")


echo "$me: run shellcheck on shellscripts"
(
# use this when all issues are fixed
# git ls-files | grep -v "^testcases" | grep -E ".sh$" | xargs shellcheck
shellcheck do_shellcheck.sh do_yamllint.sh
)

echo "$me: run shellcheck on testcases"
(
# use this when all issues are fixed
# cd testcases && git ls-files | grep -E ".sh$" | xargs shellcheck -x
cd testcases && shellcheck -x ./checksum_buffersize*.sh
)

21 changes: 21 additions & 0 deletions do_yamllint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh

set -e

YMLLINT=""
if which yamllint >/dev/null 2>/dev/null; then
YMLLINT="yamllint"
elif [ -f .venv/bin/yamllint ]; then
YMLLINT=".venv/bin/yamllint"
else
echo "could not find yamllint please install"
echo "for debian based systems: apt -y install libxml2-utils"
echo "for redhat based systems: dnf install yamllint"
echo "local install: python3 -m venv .venv && .venv/bin/python3 -m pip install yamllint"
exit 3
fi

# run this when all issues are fixed
# git ls-files | grep -E "*.yml$" | xargs "$YMLLINT"

"$YMLLINT" .github/workflows/shellcheck.yml .github/workflows/yamllint.yml

0 comments on commit e22a83e

Please sign in to comment.