From 07a8f3d5ea1f148bb5c8330cecf7955bc054f7b3 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Tue, 13 Dec 2022 11:09:29 +0100 Subject: [PATCH] test: adapt to shellcheck v0.9.0 --- .github/workflows/tests.yml | 4 +++- test/cases/api.sh | 14 +++++++------- test/cases/aws.sh | 8 ++++---- test/cases/aws_s3.sh | 2 +- test/cases/azure.sh | 8 ++++---- test/cases/gcp.sh | 2 +- test/cases/generic_s3.sh | 2 +- test/cases/regression-old-worker-new-composer.sh | 10 +++++----- tools/generic_s3_https_test.sh | 2 +- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 882e461e0..5d0a604d7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -168,7 +168,9 @@ jobs: with: ignore: vendor # We don't want to fix the code in vendored dependencies env: - SHELLCHECK_OPTS: -e SC1091 -e SC2002 # don't check /etc/os-release sourcing and allow useless cats to live inside our codebase + # don't check /etc/os-release sourcing, allow useless cats to live inside our codebase, and + # allow seemingly unreachable commands + SHELLCHECK_OPTS: -e SC1091 -e SC2002 -e SC2317 rpmlint: name: "📦 RPMlint" diff --git a/test/cases/api.sh b/test/cases/api.sh index 493fe1601..bbe1c3dea 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -109,7 +109,7 @@ fi # Start the db DB_CONTAINER_NAME="osbuild-composer-db" -sudo ${CONTAINER_RUNTIME} run -d --name "${DB_CONTAINER_NAME}" \ +sudo "${CONTAINER_RUNTIME}" run -d --name "${DB_CONTAINER_NAME}" \ --health-cmd "pg_isready -U postgres -d osbuildcomposer" --health-interval 2s \ --health-timeout 2s --health-retries 10 \ -e POSTGRES_USER=postgres \ @@ -119,7 +119,7 @@ sudo ${CONTAINER_RUNTIME} run -d --name "${DB_CONTAINER_NAME}" \ quay.io/osbuild/postgres:13-alpine # Dump the logs once to have a little more output -sudo ${CONTAINER_RUNTIME} logs osbuild-composer-db +sudo "${CONTAINER_RUNTIME}" logs osbuild-composer-db # Initialize a module in a temp dir so we can get tern without introducing # vendoring inconsistency @@ -194,7 +194,7 @@ function dump_db() { set +x # Save the result, including the manifest, for the job, straight from the db - sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \ + sudo "${CONTAINER_RUNTIME}" exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c "SELECT result FROM jobs WHERE type='manifest-id-only'" \ | sudo tee "${ARTIFACTS}/build-result.txt" set -x } @@ -209,8 +209,8 @@ function cleanups() { # dump the DB here to ensure that it gets dumped even if the test fails dump_db - sudo ${CONTAINER_RUNTIME} kill "${DB_CONTAINER_NAME}" - sudo ${CONTAINER_RUNTIME} rm "${DB_CONTAINER_NAME}" + sudo "${CONTAINER_RUNTIME}" kill "${DB_CONTAINER_NAME}" + sudo "${CONTAINER_RUNTIME}" rm "${DB_CONTAINER_NAME}" sudo rm -rf "$WORKDIR" @@ -487,7 +487,7 @@ waitForState "building" sudo systemctl stop "osbuild-remote-worker@*" RETRIED=0 for RETRY in {1..10}; do - ROWS=$(sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c \ + ROWS=$(sudo "${CONTAINER_RUNTIME}" exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c \ "SELECT retries FROM jobs WHERE id = '$COMPOSE_ID' AND retries = 1") if grep -q "1 row" <<< "$ROWS"; then RETRIED=1 @@ -502,7 +502,7 @@ if [ "$RETRIED" != 1 ]; then exit 1 fi # remove the job from the queue so the worker doesn't pick it up again -sudo ${CONTAINER_RUNTIME} exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c \ +sudo "${CONTAINER_RUNTIME}" exec "${DB_CONTAINER_NAME}" psql -U postgres -d osbuildcomposer -c \ "DELETE FROM jobs WHERE id = '$COMPOSE_ID'" sudo systemctl start "osbuild-remote-worker@localhost:8700.service" diff --git a/test/cases/aws.sh b/test/cases/aws.sh index d28a7eb4d..5c2c6968b 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -60,7 +60,7 @@ AMI_DATA=${TEMPDIR}/ami-data-${TEST_ID}.json # We need awscli to talk to AWS. if ! hash aws; then echo "Using 'awscli' from a container" - sudo ${CONTAINER_RUNTIME} pull ${CONTAINER_IMAGE_CLOUD_TOOLS} + sudo "${CONTAINER_RUNTIME}" pull ${CONTAINER_IMAGE_CLOUD_TOOLS} AWS_CMD="sudo ${CONTAINER_RUNTIME} run --rm \ -e AWS_ACCESS_KEY_ID=${V2_AWS_ACCESS_KEY_ID} \ @@ -206,7 +206,7 @@ fi CONTAINER_CLOUD_IMAGE_VAL="quay.io/cloudexperience/cloud-image-val-test:$TAG" -sudo ${CONTAINER_RUNTIME} pull ${CONTAINER_CLOUD_IMAGE_VAL} +sudo "${CONTAINER_RUNTIME}" pull "${CONTAINER_CLOUD_IMAGE_VAL}" greenprint "Running cloud-image-val on generated image" @@ -229,13 +229,13 @@ if [ "$ARCH" == "aarch64" ]; then sed -i s/t3.medium/a1.large/ "${TEMPDIR}/resource-file.json" fi -sudo ${CONTAINER_RUNTIME} run \ +sudo "${CONTAINER_RUNTIME}" run \ -a stdout -a stderr \ -e AWS_ACCESS_KEY_ID="${V2_AWS_ACCESS_KEY_ID}" \ -e AWS_SECRET_ACCESS_KEY="${V2_AWS_SECRET_ACCESS_KEY}" \ -e AWS_REGION="${AWS_REGION}" \ -v "${TEMPDIR}":/tmp:Z \ - ${CONTAINER_CLOUD_IMAGE_VAL} \ + "${CONTAINER_CLOUD_IMAGE_VAL}" \ python cloud-image-val.py -r /tmp/resource-file.json -d -o /tmp/report.xml -m 'not pub' && RESULTS=1 || RESULTS=0 mv "${TEMPDIR}"/report.html "${ARTIFACTS}" diff --git a/test/cases/aws_s3.sh b/test/cases/aws_s3.sh index a72a0d4e9..9ed343526 100755 --- a/test/cases/aws_s3.sh +++ b/test/cases/aws_s3.sh @@ -45,7 +45,7 @@ AWS_S3_PROVIDER_CONFIG=${TEMPDIR}/aws.toml # We need awscli to talk to AWS. if ! hash aws; then echo "Using 'awscli' from a container" - sudo ${CONTAINER_RUNTIME} pull ${CONTAINER_IMAGE_CLOUD_TOOLS} + sudo "${CONTAINER_RUNTIME}" pull ${CONTAINER_IMAGE_CLOUD_TOOLS} AWS_CMD="sudo ${CONTAINER_RUNTIME} run --rm \ -e AWS_ACCESS_KEY_ID=${V2_AWS_ACCESS_KEY_ID} \ diff --git a/test/cases/azure.sh b/test/cases/azure.sh index 0c0c1ba7c..56a9f503f 100755 --- a/test/cases/azure.sh +++ b/test/cases/azure.sh @@ -43,7 +43,7 @@ trap cleanup EXIT # Terraform needs azure-cli to talk to Azure. if ! hash az; then echo "Using 'azure-cli' from a container" - sudo ${CONTAINER_RUNTIME} pull ${CONTAINER_IMAGE_CLOUD_TOOLS} + sudo "${CONTAINER_RUNTIME}" pull ${CONTAINER_IMAGE_CLOUD_TOOLS} # directory mounted to the container, in which azure-cli stores the credentials after logging in AZURE_CMD_CREDS_DIR="${TEMPDIR}/azure-cli_credentials" @@ -206,7 +206,7 @@ fi CONTAINER_CLOUD_IMAGE_VAL="quay.io/cloudexperience/cloud-image-val-test:$TAG" -sudo ${CONTAINER_RUNTIME} pull ${CONTAINER_CLOUD_IMAGE_VAL} +sudo "${CONTAINER_RUNTIME}" pull "${CONTAINER_CLOUD_IMAGE_VAL}" greenprint "Running cloud-image-val on generated image" @@ -225,14 +225,14 @@ tee "${TEMPDIR}/resource-file.json" <