Skip to content

Commit

Permalink
shellcheck: add shellcheck ci check
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed Apr 7, 2023
1 parent 60cd2ab commit 4df6aae
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/everything.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

runs-on: ubuntu-latest
container:
image: ornladios/adios2:ci-formatting
image: ornladios/adios2:ci-formatting-test

steps:
- uses: actions/checkout@v3
Expand All @@ -82,6 +82,9 @@ jobs:
- name: Python
working-directory: source
run: ../gha/scripts/ci/scripts/run-flake8.sh
- name: Shell
working-directory: source
run: ../gha/scripts/ci/scripts/run-shellcheck.sh


#######################################
Expand Down
19 changes: 12 additions & 7 deletions scripts/ci/images/formatting/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
FROM ubuntu:20.04

RUN apt-get update && \
apt-get install -y apt-utils && \
apt-get install -y curl git flake8 libtinfo5 && \
RUN apt update && \
DEBIAN_FRONTEND="noninteractive" apt upgrade -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt install -y --no-install-recommends \
apt-utils \
ca-certificates \
clang-format-7 \
curl \
flake8 \
git \
libtinfo5 \
shellcheck \
&& \
apt-get clean

RUN curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-7.1.0/clang+llvm-7.1.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz | tar -C /opt -xJv && \
mv /opt/clang* /opt/llvm-7.1.0
ENV PATH=/opt/llvm-7.1.0/bin:$PATH
27 changes: 27 additions & 0 deletions scripts/ci/scripts/run-shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

echo "---------- Begin ENV ----------"
env | sort
echo "---------- End ENV ----------"

# If a source dir is given, then change to it. Otherwise assume we're already
# in it
if [ -n "${SOURCE_DIR}" ]
then
cd "${SOURCE_DIR}" || exit
fi

# Check C and C++ code with shellcheck
found_scripts=$(find scripts -regextype posix-extended -iregex '.*\.(sh|bash)' -print)
found_scripts+=$(git grep --name-only -e '#!/{usr/,}bin/{bash,sh}' -e '#!/{usr/,}bin/env {bash,sh}')
found_scripts=$(sort -u <<<"$found_scripts")

if ! xargs -n1 shellcheck <<<"$found_scripts"
then
echo "shellcheck:"
echo " Code format checks failed."
echo " Please run shellcheck on your changes before committing."
exit 1
fi

exit 0

0 comments on commit 4df6aae

Please sign in to comment.