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 508ede8
Show file tree
Hide file tree
Showing 5 changed files with 166 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
53 changes: 53 additions & 0 deletions .shellcheck_exclude_paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
scripts/ci/azure/linux-setup.sh
scripts/ci/azure/macos-setup.sh
scripts/ci/azure/run.sh
scripts/ci/circle/postCDashStatus.sh
scripts/ci/circle/run.sh
scripts/ci/gh-actions/check-branch-name.sh
scripts/ci/gh-actions/get-changed-files.sh
scripts/ci/gh-actions/linux-setup.sh
scripts/ci/gh-actions/macos-setup.sh
scripts/ci/gh-actions/run.sh
scripts/ci/gitlab-ci/run.sh
scripts/ci/images-v2/build-base.sh
scripts/ci/images-v2/build-clang-base.sh
scripts/ci/images-v2/build-clang.sh
scripts/ci/images-v2/build-cuda.sh
scripts/ci/images-v2/build-functions.sh
scripts/ci/images-v2/build-gcc-base.sh
scripts/ci/images-v2/build-gcc.sh
scripts/ci/images-v2/build-intel-base.sh
scripts/ci/images-v2/build-intel.sh
scripts/ci/images-v2/build-mpich.sh
scripts/ci/images-v2/build-nvhpc.sh
scripts/ci/images-v2/build.sh
scripts/ci/images/build-emu-power8-image.sh
scripts/ci/images/build-native-images.sh
scripts/ci/images/emu-el7/entrypoint.sh
scripts/ci/images/emu-el7/qemu-binfmt-conf.sh
scripts/ci/images/emu-el7/register.sh
scripts/ci/scripts/github-prs-to-gitlab.sh
scripts/ci/scripts/run-clang-format.sh
scripts/ci/scripts/run-flake8.sh
scripts/ci/setup-run/ci-el8-gcc10.sh
scripts/ci/setup-run/ci-el8-gcc11.sh
scripts/ci/setup-run/ci-el8-gcc9.sh
scripts/ci/setup-run/ci-el8-icc.sh
scripts/ci/setup-run/ci-el8-nvhpc222-mpi.sh
scripts/ci/setup-run/ci-el8-nvhpc222.sh
scripts/ci/setup-run/ci-el8-oneapi.sh
scripts/ci/setup/ci-power8-el7-xl-serial.sh
scripts/dashboard/nightly/aaargh.sh
scripts/dashboard/nightly/cori.sh
scripts/dashboard/nightly/summitdev.sh
scripts/developer/git/setup-aliases
scripts/developer/git/setup-hooks
scripts/developer/git/setup-remotes
scripts/developer/merge-pr-from-release.sh
scripts/developer/setup.sh
scripts/docker/setup-user.sh
scripts/runconf/runconf.sh
scripts/runconf/runconf_olcf.sh
scripts/travis/run-docker.sh
scripts/travis/run-format.sh
scripts/travis/run.sh
53 changes: 53 additions & 0 deletions .shellcheck_ignore_files
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
scripts/ci/azure/linux-setup.sh
scripts/ci/azure/macos-setup.sh
scripts/ci/azure/run.sh
scripts/ci/circle/postCDashStatus.sh
scripts/ci/circle/run.sh
scripts/ci/gh-actions/check-branch-name.sh
scripts/ci/gh-actions/get-changed-files.sh
scripts/ci/gh-actions/linux-setup.sh
scripts/ci/gh-actions/macos-setup.sh
scripts/ci/gh-actions/run.sh
scripts/ci/gitlab-ci/run.sh
scripts/ci/images-v2/build-base.sh
scripts/ci/images-v2/build-clang-base.sh
scripts/ci/images-v2/build-clang.sh
scripts/ci/images-v2/build-cuda.sh
scripts/ci/images-v2/build-functions.sh
scripts/ci/images-v2/build-gcc-base.sh
scripts/ci/images-v2/build-gcc.sh
scripts/ci/images-v2/build-intel-base.sh
scripts/ci/images-v2/build-intel.sh
scripts/ci/images-v2/build-mpich.sh
scripts/ci/images-v2/build-nvhpc.sh
scripts/ci/images-v2/build.sh
scripts/ci/images/build-emu-power8-image.sh
scripts/ci/images/build-native-images.sh
scripts/ci/images/emu-el7/entrypoint.sh
scripts/ci/images/emu-el7/qemu-binfmt-conf.sh
scripts/ci/images/emu-el7/register.sh
scripts/ci/scripts/github-prs-to-gitlab.sh
scripts/ci/scripts/run-clang-format.sh
scripts/ci/scripts/run-flake8.sh
scripts/ci/setup-run/ci-el8-gcc10.sh
scripts/ci/setup-run/ci-el8-gcc11.sh
scripts/ci/setup-run/ci-el8-gcc9.sh
scripts/ci/setup-run/ci-el8-icc.sh
scripts/ci/setup-run/ci-el8-nvhpc222-mpi.sh
scripts/ci/setup-run/ci-el8-nvhpc222.sh
scripts/ci/setup-run/ci-el8-oneapi.sh
scripts/ci/setup/ci-power8-el7-xl-serial.sh
scripts/dashboard/nightly/aaargh.sh
scripts/dashboard/nightly/cori.sh
scripts/dashboard/nightly/summitdev.sh
scripts/developer/git/setup-aliases
scripts/developer/git/setup-hooks
scripts/developer/git/setup-remotes
scripts/developer/merge-pr-from-release.sh
scripts/developer/setup.sh
scripts/docker/setup-user.sh
scripts/runconf/runconf.sh
scripts/runconf/runconf_olcf.sh
scripts/travis/run-docker.sh
scripts/travis/run-format.sh
scripts/travis/run.sh
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
44 changes: 44 additions & 0 deletions scripts/ci/scripts/run-shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# We need the same sort order
export LC_ALL=C
EXCLUDE_SCRIPTS=.shellcheck_exclude_paths

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

if [ -n "${SOURCE_DIR}" ]
then
cd "${SOURCE_DIR}" || exit
fi

set -x

# Give me a sorted list of the project scripts
found_scripts="$({
find scripts -regextype posix-extended -iregex '.*\.(sh|bash)' -print;
grep -rnlE -e '#!/(/usr)?/bin/(bash|sh)' -e '#!(/usr)?/bin/env\s+(bash|sh)' scripts;
} | sort -u)"

echo "[I] Found the following files:"
echo "$found_scripts"

# Give me the list of scripts without $EXCLUDE_SCRIPTS
if [ -f "$EXCLUDE_SCRIPTS" ]
then
check_scripts=$(comm -2 -3 <(echo "$found_scripts") "$EXCLUDE_SCRIPTS" )
fi

echo "[I] Checking the following files:"
echo "$check_scripts"

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

exit 0

0 comments on commit 508ede8

Please sign in to comment.