Skip to content

Commit

Permalink
Merge pull request #45 from terhorstd/add_shellcheck
Browse files Browse the repository at this point in the history
Add shellcheck
  • Loading branch information
terhorstd authored Jan 27, 2022
2 parents 4424f15 + 0bbc05a commit 8293ff5
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 32 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Install ${{ matrix.envmodules }}
run: sudo apt-get install ${{ matrix.envmodules }}
run: sudo apt install ${{ matrix.envmodules }}

- name: Install test dependencies
run: sudo apt install shellcheck

- name: Install BATS
run: |
./build.sh configure || true
echo "y" | ./build.sh bats
./build.sh -s bats
- name: Run BATS
run: |
source /etc/profile
Expand Down
2 changes: 1 addition & 1 deletion plans/Builder/unstable/ebrains
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ build_install () {
log_status ">>> build and install ${PACKAGE}..."
set -x
if [ -d "${TARGET}" ]; then
read -p "sure you want to delete ${TARGET}? (ctrl-c for NO)"
read -rp "sure you want to delete ${TARGET}? (ctrl-c for NO)"
rm -vrf "${TARGET}"
fi
#git clone --depth 1 -b "${VARIANT}" "[email protected]:INM-6/${PACKAGE}.git" "${TARGET}"
Expand Down
2 changes: 1 addition & 1 deletion plans/Builder/unstable/master
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ build_install () {
log_status ">>> build and install ${PACKAGE}..."
set -x
if [ -d "${TARGET}" ]; then
read -p "sure you want to delete ${TARGET}? (ctrl-c for NO)"
read -rp "sure you want to delete ${TARGET}? (ctrl-c for NO)"
rm -vrf "${TARGET}"
fi
git clone --depth 1 -b "${VARIANT}" "https://github.com/INM-6/${PACKAGE}.git" "${TARGET}"
Expand Down
2 changes: 1 addition & 1 deletion plans/LFPy/2.2dev0/default
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
pip install ${CONFIGURE_OPTIONS:-} \
pip install "${CONFIGURE_OPTIONS:-}" \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
--src "${SOURCE}" \
Expand Down
4 changes: 2 additions & 2 deletions plans/cmake/3.18.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ build_package () {
log_status ">>> build"
cd "${BUILD}"
set -x
"${SOURCE}/bootstrap" --prefix="${TARGET}" --parallel=${MAKE_THREADS:-$(nproc)} |& tee "${LOG}/bootstrap.log"
make -j ${MAKE_THREADS:-$(nproc)} |& tee "${LOG}/make.log"
"${SOURCE}/bootstrap" --prefix="${TARGET}" --parallel="${MAKE_THREADS:-$(nproc)}" |& tee "${LOG}/bootstrap.log"
make -j "${MAKE_THREADS:-$(nproc)}" |& tee "${LOG}/make.log"
set +x
}

4 changes: 2 additions & 2 deletions plans/cmake/3.18.1/default
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ build_package () {
log_status ">>> build"
cd "${BUILD}"
set -x
"${SOURCE}/bootstrap" --prefix="${TARGET}" --parallel=${MAKE_THREADS:-$(nproc)} |& tee "${LOG}/bootstrap.log"
"${SOURCE}/bootstrap" --prefix="${TARGET}" --parallel="${MAKE_THREADS:-$(nproc)}" |& tee "${LOG}/bootstrap.log"
#./bootstrap --prefix="${TARGET}" --srcdir="${SOURCE}" |& tee "${LOG}/bootstrap.log"
make -j ${MAKE_THREADS:-$(nproc)} |& tee "${LOG}/make.log"
make -j "${MAKE_THREADS:-$(nproc)}" |& tee "${LOG}/make.log"
set +x
}

2 changes: 2 additions & 0 deletions plans/elephant/0.2.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
2 changes: 2 additions & 0 deletions plans/elephant/0.8.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
8 changes: 5 additions & 3 deletions plans/environment-modules/4.7.1/default
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ URL=https://github.com/cea-hpc/modules/releases/download/v${VERSION}/modules-${V
# this checksum was not officially provided, but taken from downloaded tar-ball
SHA256SUM=ee7ecd62bbbde6d51e30788a97800c39e72515b6a910839fb84041b35ba42b4d

CONFIGURE_OPTIONS="--modulefilesdir '$MODULE_INSTALL_PATH' --enable-color --disable-example-modulefiles"
CONFIGURE_OPTIONS=("--modulefilesdir" "$MODULE_INSTALL_PATH" "--enable-color" "--disable-example-modulefiles")

build_package () {
log_status ">>> in-tree build ${PACKAGE}/${VERSION}/${VARIANT}..."
cd "${SOURCE}"
set -x
"./configure" --prefix="${TARGET}" ${CONFIGURE_OPTIONS:-} 2>&1 | tee "${LOG}/configure.log"
make -j ${MAKE_THREADS:-$(nproc)} 2>&1 | tee "${LOG}/make.log"
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
"./configure" --prefix="${TARGET}" "${CONFIGURE_OPTIONS[@]}" 2>&1 | tee "${LOG}/configure.log"
make -j "${MAKE_THREADS:-$(nproc)}" 2>&1 | tee "${LOG}/make.log"
set +x
}
2 changes: 2 additions & 0 deletions plans/fairgraph/0.5.1/default
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
6 changes: 5 additions & 1 deletion plans/fairgraph/0.5.1/git
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ source_prepare() {
build_prepare() {
log_status ">>> prepare build"
if [ -d "${BUILD}" ]; then
read -p "sure you want to delete ${BUILD}? (ctrl-c for NO)"
read -rp "sure you want to delete ${BUILD}? (ctrl-c for NO)"
rm -vrf "${BUILD}"
fi
mkdir -pv "${BUILD}"
Expand All @@ -55,6 +55,8 @@ build_prepare() {
# is a subset of --root
cd "${BUILD}"

# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand All @@ -75,6 +77,8 @@ build_package () {

# --target "${TARGET}"
# is a subset of --root
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
6 changes: 2 additions & 4 deletions plans/gsl/2.6/default
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
PACKAGE=gsl
VERSION=${1:-2.6}
SUFFIX=${2:-}
URL=ftp://ftp.gnu.org/gnu/${PACKAGE}/${PACKAGE}-${VERSION}.tar.gz
GPG_VERIFY_KEY=../gsl_key.txt

build_install() {
make install |& tee ${LOG}/make-install.log
awk 'BEGIN {f=2;x=0}; /^-------/{x=1;if (f>0) f--} f*x' ${LOG}/make-install.log >${TARGET}/ConfigurationSummary.txt
make install |& tee "${LOG}/make-install.log"
awk 'BEGIN {f=2;x=0}; /^-------/{x=1;if (f>0) f--} f*x' "${LOG}/make-install.log" >"${TARGET}/ConfigurationSummary.txt"
}

2 changes: 2 additions & 0 deletions plans/hybridLFPy/0.1.3/default
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
pip install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
1 change: 1 addition & 0 deletions plans/nest-simulator/2.14.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ DOI=10.5281/zenodo.882971
MD5SUM=a214b61da740c9252f3dfea5ed804441
SHA256SUM=afaf7d53c2d5305fac1257759cc0ea6d62c3cebf7d5cc4a07d4739af4dbb9caf

# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
1 change: 1 addition & 0 deletions plans/nest-simulator/2.16.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ MD5SUM=327c1d1edea9580cde1bc1deaa7f63f3 # GitHub release tarball
SHA256SUM=abfeb61719dec54da9477be035bef1d9d764f4e7663f63f6a6d9211f967e0490
log_warning "!!! NOTE: Building from release tar-ball, which is different from the DOI version!"

# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
1 change: 1 addition & 0 deletions plans/nest-simulator/2.18.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ DOI=10.5281/zenodo.2605422
MD5SUM=5d04f99bb8d1fa13a5796ef12500ec99
SHA256SUM=7295c936fbdd5486395b06f54f0d4d35d9a1b6ee50b7b844186ec2c92de641d1

# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
3 changes: 2 additions & 1 deletion plans/nest-simulator/2.20.0/Python3-CN-gsl2.6
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ MD5SUM=d3fc815b6a6db187468350cc971fed0b
SHA256SUM=40e33187c22d6e843d80095b221fa7fd5ebe4dbc0116765a91fc5c425dd0eca4
log_warning "!!! NOTE: Building from release tar-ball, which is different from the DOI version!"

CMAKEFLAGS="-Dwith-python=3 -Dwith-gsl=ON"
CONFIGURE_OPTIONS="-Dwith-python=3 -Dwith-gsl=ON"
# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
11 changes: 6 additions & 5 deletions plans/nest-simulator/2.20.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ URL='https://github.com/nest/nest-simulator/archive/v2.20.0.tar.gz'
MD5SUM=d3fc815b6a6db187468350cc971fed0b
SHA256SUM=40e33187c22d6e843d80095b221fa7fd5ebe4dbc0116765a91fc5c425dd0eca4

CMAKEFLAGS="-Dwith-python=OFF"
if which python; then
PYTHON="$(which python3)"
CMAKEFLAGS="-Dwith-python=3"
CONFIGURE_OPTIONS="-Dwith-python=OFF"
if command -v python; then
PYTHON="$(command -v python3)"
CONFIGURE_OPTIONS="-Dwith-python=3"
fi

CMAKEFLAGS+=" -Dwith-boost=ON"
CONFIGURE_OPTIONS+=" -Dwith-boost=ON"

# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
3 changes: 2 additions & 1 deletion plans/nest-simulator/2.20.0/py3.8-gsl2.6
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ MD5SUM=d3fc815b6a6db187468350cc971fed0b
SHA256SUM=40e33187c22d6e843d80095b221fa7fd5ebe4dbc0116765a91fc5c425dd0eca4
log_warning "!!! NOTE: Building from release tar-ball, which is different from the DOI version!"

CMAKEFLAGS="-Dwith-python=3 -Dwith-gsl=ON"
CONFIGURE_OPTIONS="-Dwith-python=3 -Dwith-gsl=ON"
# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
11 changes: 6 additions & 5 deletions plans/nest-simulator/2.20.1/default
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ URL="https://github.com/nest/nest-simulator/archive/v${VERSION}.tar.gz"
MD5SUM=fd9aaebedd1d5ace9e7b4c5ae867f1fd
SHA256SUM=df3d32b5899d5d444f708037b290f889ac6ff8eae6b7be9e9faee2c0d660d8e5

CMAKEFLAGS="-Dwith-python=OFF"
if which python; then
PYTHON="$(which python3)"
CMAKEFLAGS="-Dwith-python=3"
CONFIGURE_OPTIONS="-Dwith-python=OFF"
if command -v python; then
PYTHON="$(command -v python3)"
CONFIGURE_OPTIONS="-Dwith-python=3"
fi

CMAKEFLAGS+=" -Dwith-boost=ON"
CONFIGURE_OPTIONS+=" -Dwith-boost=ON"

# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
1 change: 1 addition & 0 deletions plans/nest-simulator/3.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ MD5SUM=5f369b65512bbb9a7031529ed18776e4
SHA256SUM=d481ea67f3251fe3aadf5252ab0a999172f0cd5536c5985366d271d772e686e6


# shellcheck source=plans/nest-simulator/common
source "$(dirname "${PLAN}")/../common"
6 changes: 4 additions & 2 deletions plans/nest-simulator/common
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ build_package () {
log_status ">>> build"
cd "${BUILD}"
set -x
cmake ${CMAKEFLAGS} -DCMAKE_INSTALL_PREFIX:PATH="$TARGET" "$SOURCE" 2>&1 | tee "${LOG}/cmake.log"
make -j ${MAKE_THREADS:-$(nproc)} 2>&1 | tee "${LOG}/make.log"
# CONFIGURE_OPTIONS variable needs to be split, so no quotes
# shellcheck disable=SC2086
cmake ${CONFIGURE_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH="$TARGET" "$SOURCE" 2>&1 | tee "${LOG}/cmake.log"
make -j "${MAKE_THREADS:-$(nproc)}" 2>&1 | tee "${LOG}/make.log"
set +x
}

Expand Down
1 change: 1 addition & 0 deletions plans/snakemake/5.27.4/default
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ build_install () {

# --target "${TARGET}"
# is a subset of --root
# shellcheck disable=SC2086
pip3 install ${CONFIGURE_OPTIONS:-} \
--root "${TARGET}" \
--cache-dir "${PACKAGE_CACHE}" \
Expand Down
2 changes: 1 addition & 1 deletion plans/tree/1.8.0/default
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ log_warning "WARNING: This build re-assigns \$TARGET path to $TARGET, because tr
build_prepare() {
log_status ">>> prepare build"
if [ -d "${BUILD}" ]; then
read -p "sure you want to delete ${BUILD}? (ctrl-c for NO)"
read -rp "sure you want to delete ${BUILD}? (ctrl-c for NO)"
rm -vrf "${BUILD}"
fi
# tree specific:
Expand Down
9 changes: 9 additions & 0 deletions tests/static-checks.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bats

@test "pass shellcheck static code analysis" {
# Covered by strict mode (set -euo pipefail)
# SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
# SC2034: <variablename> appears unused. Verify it or export it.
export SHELLCHECK_OPTS='--exclude=SC2034,SC2164'
shellcheck $(find plans/ -type f -not -name "*.txt" -a -not -name "*.module" )
}

0 comments on commit 8293ff5

Please sign in to comment.