From 7c52d1b6c852d8db0b2e77d1893d061a754f7f5c Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Thu, 19 Oct 2023 23:42:28 +0000 Subject: [PATCH] Make linter happy and clean up some scripts --- Makefile | 2 +- monitoring/atproxy/run_locally.sh | 7 +++++-- monitoring/mock_uss/run_locally_msgsigning.sh | 7 +++++-- monitoring/mock_uss/run_locally_test_geoawareness.sh | 5 +++-- monitoring/mock_uss/start_all_local_mocks.sh | 7 ++++--- monitoring/prober/run_locally.sh | 9 +++------ .../uss_qualifier/bin/generate_rid_test_definition.sh | 5 +++-- monitoring/uss_qualifier/bin/run.sh | 5 +++-- monitoring/uss_qualifier/run_locally.sh | 5 +++-- .../uss_qualifier/scripts/format_test_documentation.sh | 5 +++-- .../uss_qualifier/scripts/format_test_suite_docs.sh | 5 +++-- monitoring/uss_qualifier/scripts/run_unit_tests.sh | 5 +++-- .../uss_qualifier/scripts/validate_test_definitions.sh | 5 +++-- 13 files changed, 42 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 3caab29d58..327689fb3b 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ validate-uss-qualifier-docs: .PHONY: shell-lint shell-lint: - find . -name '*.sh' | grep -v '^./interfaces' | xargs docker run --rm -v "$(CURDIR):/monitoring" -w /monitoring koalaman/shellcheck + find . -name '*.sh' ! -path "./interfaces/*" | xargs docker run --rm -v "$(CURDIR):/monitoring" -w /monitoring koalaman/shellcheck .PHONY: json-schema json-schema: diff --git a/monitoring/atproxy/run_locally.sh b/monitoring/atproxy/run_locally.sh index 653acd722e..5f47c622e8 100755 --- a/monitoring/atproxy/run_locally.sh +++ b/monitoring/atproxy/run_locally.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eo pipefail + # Find and change to repo root directory OS=$(uname) if [[ "$OS" == "Darwin" ]]; then @@ -10,9 +12,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) CLIENT_BASIC_AUTH="local_client:local_client" PUBLIC_KEY="/var/test-certs/auth2.pem" diff --git a/monitoring/mock_uss/run_locally_msgsigning.sh b/monitoring/mock_uss/run_locally_msgsigning.sh index 6d366e7de5..ae96a2135b 100755 --- a/monitoring/mock_uss/run_locally_msgsigning.sh +++ b/monitoring/mock_uss/run_locally_msgsigning.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eo pipefail + # Find and change to repo root directory OS=$(uname) if [[ "$OS" == "Darwin" ]]; then @@ -10,9 +12,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) AUTH="DummyOAuth(http://host.docker.internal:8085/token,uss1)" DSS="http://host.docker.internal:8082" diff --git a/monitoring/mock_uss/run_locally_test_geoawareness.sh b/monitoring/mock_uss/run_locally_test_geoawareness.sh index 87e9bda62c..ba11692bfd 100755 --- a/monitoring/mock_uss/run_locally_test_geoawareness.sh +++ b/monitoring/mock_uss/run_locally_test_geoawareness.sh @@ -10,9 +10,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) PUBLIC_KEY="/var/test-certs/auth2.pem" container_name="mock_uss_geoawareness_test" diff --git a/monitoring/mock_uss/start_all_local_mocks.sh b/monitoring/mock_uss/start_all_local_mocks.sh index 7c1f860a9c..8fb4e0d4df 100755 --- a/monitoring/mock_uss/start_all_local_mocks.sh +++ b/monitoring/mock_uss/start_all_local_mocks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eo pipefail @@ -12,9 +12,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) ./monitoring/mock_uss/run_locally.sh up -d diff --git a/monitoring/prober/run_locally.sh b/monitoring/prober/run_locally.sh index a9cc78e64f..7d4fda0b03 100755 --- a/monitoring/prober/run_locally.sh +++ b/monitoring/prober/run_locally.sh @@ -13,9 +13,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) CORE_SERVICE_CONTAINER="local_infra-dss-1" OAUTH_CONTAINER="local_infra-oauth-1" @@ -25,10 +26,6 @@ for container_name in "${localhost_containers[@]}"; do if [ "$( docker container inspect -f '{{.State.Status}}' "$container_name" )" == "running" ]; then echo "$container_name available!" else - echo '#########################################################################' - echo '## Prerequisite to run this command is: ##' - echo '## Local DSS instance + Dummy OAuth server (/build/dev/run_locally.sh) ##' - echo '#########################################################################' echo "Error: $container_name not running. Execute 'build/dev/run_locally.sh up' before running monitoring/prober/run_locally.sh"; exit 1; fi diff --git a/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh b/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh index 0157afe19f..c0c4778120 100755 --- a/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh +++ b/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh @@ -12,9 +12,10 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) CONFIG_LOCATION="monitoring/uss_qualifier/config_run_locally.json" CONFIG='--config config_run_locally.json' diff --git a/monitoring/uss_qualifier/bin/run.sh b/monitoring/uss_qualifier/bin/run.sh index 0ff2a942fb..c514c5059b 100755 --- a/monitoring/uss_qualifier/bin/run.sh +++ b/monitoring/uss_qualifier/bin/run.sh @@ -30,9 +30,10 @@ AUTH="${2:-NoAuth()}" QUALIFIER_OPTIONS="--auth $AUTH --config /config.json --report output/report.json" -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) if [ "$CI" == "true" ]; then docker_args="--add-host host.docker.internal:host-gateway" # Required to reach other containers in Ubuntu (used for Github Actions) diff --git a/monitoring/uss_qualifier/run_locally.sh b/monitoring/uss_qualifier/run_locally.sh index c327dda8f0..224ee228db 100755 --- a/monitoring/uss_qualifier/run_locally.sh +++ b/monitoring/uss_qualifier/run_locally.sh @@ -12,9 +12,10 @@ else fi cd "${BASEDIR}/../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) CONFIG_NAME="${1:-ALL}" diff --git a/monitoring/uss_qualifier/scripts/format_test_documentation.sh b/monitoring/uss_qualifier/scripts/format_test_documentation.sh index c7d6503ffa..552f30b4e5 100755 --- a/monitoring/uss_qualifier/scripts/format_test_documentation.sh +++ b/monitoring/uss_qualifier/scripts/format_test_documentation.sh @@ -13,9 +13,10 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) # shellcheck disable=SC2086 docker run --name test_documentation_formatter \ diff --git a/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh b/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh index 6a1cb1ffea..9e0adfd073 100755 --- a/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh +++ b/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh @@ -13,9 +13,10 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) # shellcheck disable=SC2086 docker run --name test_suite_docs_formatter \ diff --git a/monitoring/uss_qualifier/scripts/run_unit_tests.sh b/monitoring/uss_qualifier/scripts/run_unit_tests.sh index f120dd8055..6aba675a0b 100755 --- a/monitoring/uss_qualifier/scripts/run_unit_tests.sh +++ b/monitoring/uss_qualifier/scripts/run_unit_tests.sh @@ -13,9 +13,10 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) # shellcheck disable=SC2086 docker run --name uss_qualifier_unit_test \ diff --git a/monitoring/uss_qualifier/scripts/validate_test_definitions.sh b/monitoring/uss_qualifier/scripts/validate_test_definitions.sh index 1c13b60336..dfdb99a042 100755 --- a/monitoring/uss_qualifier/scripts/validate_test_definitions.sh +++ b/monitoring/uss_qualifier/scripts/validate_test_definitions.sh @@ -13,9 +13,10 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -cd monitoring +( +cd monitoring || exit 1 make image -cd .. +) # shellcheck disable=SC2086 docker run --name test_definition_validator \