Skip to content

Commit

Permalink
ci: add shellcheck differential checks
Browse files Browse the repository at this point in the history
Enables linting the various shell scripts using shellcheck.

Signed-off-by: Andy Sadler <[email protected]>
  • Loading branch information
sadlerap committed Oct 5, 2023
1 parent 5a7c20c commit d2559f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ jobs:
architecture: "x64"
- name: Checkout code
uses: actions/checkout@v4
- name: Shellcheck
uses: redhat-plumbers-in-action/differential-shellcheck@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run linting checks
run: |
./setup.sh
Expand Down
31 changes: 17 additions & 14 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
#!/usr/bin/env bash
#!/bin/bash

set -o pipefail

usage() {
echo "$0 usage:"
grep " .)\ #" $0 | sed -e "s/^\s\+\([a-z]\).*)\ # \(.*\)$/\t-\1: \2/g"
grep " .)\ #" "$0" | sed -e "s/^\s\+\([a-z]\).*)\ # \(.*\)$/\t-\1: \2/g"
exit 0
}

while getopts ":j:n:h" arg; do
case $arg in
case ${arg} in
j) # set number of jobs to use to run tests (may cause test instability!)
jobs=${OPTARG}
;;
n) # set the namespace to run tests in
TEST_NAMESPACE=${OPTARG}
TEST_NAMESPACE="${OPTARG}"
;;
h) # display help
usage
exit 0
;;
*)
usage
;;
esac
done

OUTPUT_DIR=test-output
if [ -f test-tmp-dir ]; then
OUTPUT_DIR=$(cat test-tmp-dir)
if [[ -f test-tmp-dir ]]; then
OUTPUT_DIR="$(cat test-tmp-dir)"
fi
[ -d "${OUTPUT_DIR}" ] || mkdir -p "${OUTPUT_DIR}"
[[ -d "${OUTPUT_DIR}" ]] || mkdir -p "${OUTPUT_DIR}"

PYTHON_VENV_DIR="${OUTPUT_DIR}/venv"

mkdir -p "${OUTPUT_DIR}"

if [ -z $TEST_NAMESPACE ]; then
if [[ -z "${TEST_NAMESPACE}" ]]; then
TEST_NAMESPACE="servicebindings-cts"
fi

TEST_ACCEPTANCE_OUTPUT_DIR="${OUTPUT_DIR}"/results

if [ $(kubectl get namespace ${TEST_NAMESPACE} > /dev/null; echo $?) -eq '0' ]; then
kubectl delete namespace ${TEST_NAMESPACE}
fi
# shellcheck disable=SC2261
kubectl get namespace "${TEST_NAMESPACE}" 2&>/dev/null > /dev/null || kubectl delete namespace "${TEST_NAMESPACE}"

if [ -z $jobs ]; then
if [[ -z "${jobs}" ]]; then
jobs=1
fi

echo "Running acceptance tests"

FEATURES_PATH=features TEST_NAMESPACE=${TEST_NAMESPACE} "${PYTHON_VENV_DIR}/bin/behavex" -o ${TEST_ACCEPTANCE_OUTPUT_DIR} --capture --capture-stderr --parallel-processes ${jobs} --parallel-scheme scenario
FEATURES_PATH=features TEST_NAMESPACE="${TEST_NAMESPACE}" "${PYTHON_VENV_DIR}/bin/behavex" -o "${TEST_ACCEPTANCE_OUTPUT_DIR}" --capture --capture-stderr --parallel-processes "${jobs}" --parallel-scheme scenario

0 comments on commit d2559f7

Please sign in to comment.