From 6d17e9c15e8508fc422376c859595f67395eb858 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Thu, 19 Oct 2023 22:09:28 +0000 Subject: [PATCH] Use `make image` to build image --- Makefile | 6 +++--- monitoring/.gitignore | 5 ++++- monitoring/Makefile | 4 ++-- monitoring/atproxy/run_locally.sh | 7 +++---- monitoring/build.sh | 1 + monitoring/mock_uss/run_locally_msgsigning.sh | 18 +++++++++++++----- .../mock_uss/run_locally_test_geoawareness.sh | 18 +++++++++++++----- monitoring/mock_uss/start_all_local_mocks.sh | 7 +++---- monitoring/prober/README.md | 2 +- monitoring/prober/run_locally.sh | 7 +++---- .../bin/generate_rid_test_definition.sh | 7 +++---- monitoring/uss_qualifier/bin/run.sh | 7 +++---- monitoring/uss_qualifier/run_locally.sh | 7 +++---- .../scripts/format_test_documentation.sh | 7 +++---- .../scripts/format_test_suite_docs.sh | 7 +++---- .../uss_qualifier/scripts/run_unit_tests.sh | 7 +++---- .../scripts/validate_test_definitions.sh | 7 +++---- schemas/manage_type_schemas.sh | 7 +++---- 18 files changed, 70 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index b074ce18f4..3caab29d58 100644 --- a/Makefile +++ b/Makefile @@ -49,9 +49,9 @@ json-schema-lint: .PHONY: hygiene-tests hygiene-tests: check-hygiene -.PHONY: build-monitoring -build-monitoring: - cd monitoring && make build +.PHONY: image +image: + cd monitoring && make image tag: scripts/tag.sh $(UPSTREAM_OWNER)/monitoring/v$(VERSION) diff --git a/monitoring/.gitignore b/monitoring/.gitignore index 9ed27cd019..73f2ddb3e4 100644 --- a/monitoring/.gitignore +++ b/monitoring/.gitignore @@ -1,4 +1,7 @@ report.json config.json run_locally_list.txt -run_locally_scd_deploy_others.sh \ No newline at end of file +run_locally_scd_deploy_others.sh + +# Make target placeholders +image diff --git a/monitoring/Makefile b/monitoring/Makefile index 90b1301200..a04912bb51 100644 --- a/monitoring/Makefile +++ b/monitoring/Makefile @@ -19,8 +19,8 @@ format: cd monitorlib && make format cd prober && make format -.PHONY: build -build: +image: ../requirements.txt $(shell find . -type f ! -path "*/output/*" ! -name image) $(shell find ../interfaces -type f) + # Building image due to changes in the following files: $? ./build.sh .PHONY: test diff --git a/monitoring/atproxy/run_locally.sh b/monitoring/atproxy/run_locally.sh index eb8262fe34..653acd722e 100755 --- a/monitoring/atproxy/run_locally.sh +++ b/monitoring/atproxy/run_locally.sh @@ -10,10 +10,9 @@ else fi cd "${BASEDIR}/../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +make image +cd .. CLIENT_BASIC_AUTH="local_client:local_client" PUBLIC_KEY="/var/test-certs/auth2.pem" diff --git a/monitoring/build.sh b/monitoring/build.sh index e767e69fc9..ac027a0dcb 100755 --- a/monitoring/build.sh +++ b/monitoring/build.sh @@ -21,3 +21,4 @@ docker image build \ --build-arg commit_hash="$(git rev-parse HEAD)" \ . \ || exit 1 +touch monitoring/image diff --git a/monitoring/mock_uss/run_locally_msgsigning.sh b/monitoring/mock_uss/run_locally_msgsigning.sh index 742fef289d..6d366e7de5 100755 --- a/monitoring/mock_uss/run_locally_msgsigning.sh +++ b/monitoring/mock_uss/run_locally_msgsigning.sh @@ -1,10 +1,18 @@ #!/usr/bin/env bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - "${SCRIPT_DIR}/../build.sh" || exit 1 - export DO_NOT_BUILD_MONITORING=true +# Find and change to repo root directory +OS=$(uname) +if [[ "$OS" == "Darwin" ]]; then + # OSX uses BSD readlink + BASEDIR="$(dirname "$0")" +else + BASEDIR=$(readlink -e "$(dirname "$0")") fi +cd "${BASEDIR}/../.." || exit 1 + +cd monitoring +make image +cd .. AUTH="DummyOAuth(http://host.docker.internal:8085/token,uss1)" DSS="http://host.docker.internal:8082" @@ -32,7 +40,7 @@ docker run ${docker_args} --name ${container_name} \ -e MOCK_USS_BASE_URL="${BASE_URL}" \ -e MOCK_USS_SERVICES="scdsc,msgsigning" \ -p ${PORT}:5000 \ - -v "${SCRIPT_DIR}/../../build/test-certs:/var/test-certs:ro" \ + -v "$(pwd)/build/test-certs:/var/test-certs:ro" \ "$@" \ interuss/monitoring \ mock_uss/start.sh diff --git a/monitoring/mock_uss/run_locally_test_geoawareness.sh b/monitoring/mock_uss/run_locally_test_geoawareness.sh index d2c6f98168..87e9bda62c 100755 --- a/monitoring/mock_uss/run_locally_test_geoawareness.sh +++ b/monitoring/mock_uss/run_locally_test_geoawareness.sh @@ -1,10 +1,18 @@ #!/usr/bin/env bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - "${SCRIPT_DIR}/../build.sh" || exit 1 - export DO_NOT_BUILD_MONITORING=true +# Find and change to repo root directory +OS=$(uname) +if [[ "$OS" == "Darwin" ]]; then + # OSX uses BSD readlink + BASEDIR="$(dirname "$0")" +else + BASEDIR=$(readlink -e "$(dirname "$0")") fi +cd "${BASEDIR}/../.." || exit 1 + +cd monitoring +make image +cd .. PUBLIC_KEY="/var/test-certs/auth2.pem" container_name="mock_uss_geoawareness_test" @@ -27,7 +35,7 @@ docker run ${docker_args} --rm --name ${container_name} \ -e MOCK_USS_TOKEN_AUDIENCE="${AUD}" \ -e MOCK_USS_SERVICES="geoawareness" \ -p ${PORT}:5000 \ - -v "${SCRIPT_DIR}/../../build/test-certs:/var/test-certs:ro" \ + -v "$(pwd)/build/test-certs:/var/test-certs:ro" \ "$@" \ interuss/monitoring \ ${docker_command} diff --git a/monitoring/mock_uss/start_all_local_mocks.sh b/monitoring/mock_uss/start_all_local_mocks.sh index 9f7776b812..7c1f860a9c 100755 --- a/monitoring/mock_uss/start_all_local_mocks.sh +++ b/monitoring/mock_uss/start_all_local_mocks.sh @@ -12,10 +12,9 @@ else fi cd "${BASEDIR}/../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - ./monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +make image +cd .. ./monitoring/mock_uss/run_locally.sh up -d diff --git a/monitoring/prober/README.md b/monitoring/prober/README.md index f4568f8c8e..61468e0b36 100644 --- a/monitoring/prober/README.md +++ b/monitoring/prober/README.md @@ -36,7 +36,7 @@ First, build the monitoring image: (from the repo root) ```shell script -monitoring/build.sh +make image ``` ...then run prober: diff --git a/monitoring/prober/run_locally.sh b/monitoring/prober/run_locally.sh index 2babedc80f..a9cc78e64f 100755 --- a/monitoring/prober/run_locally.sh +++ b/monitoring/prober/run_locally.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/../.." || exit 1 -if [ -z "$DO_NOT_BUILD_MONITORING" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +make image +cd .. CORE_SERVICE_CONTAINER="local_infra-dss-1" OAUTH_CONTAINER="local_infra-oauth-1" diff --git a/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh b/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh index 33e00a296c..0157afe19f 100755 --- a/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh +++ b/monitoring/uss_qualifier/bin/generate_rid_test_definition.sh @@ -12,10 +12,9 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 92872cf1d9..0ff2a942fb 100755 --- a/monitoring/uss_qualifier/bin/run.sh +++ b/monitoring/uss_qualifier/bin/run.sh @@ -30,10 +30,9 @@ AUTH="${2:-NoAuth()}" QUALIFIER_OPTIONS="--auth $AUTH --config /config.json --report output/report.json" -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - "$(pwd)"/monitoring/build.sh - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 7d57257a96..c327dda8f0 100755 --- a/monitoring/uss_qualifier/run_locally.sh +++ b/monitoring/uss_qualifier/run_locally.sh @@ -12,10 +12,9 @@ else fi cd "${BASEDIR}/../.." || exit 1 -if [ -z "$DO_NOT_BUILD_MONITORING" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 189f72856a..c7d6503ffa 100755 --- a/monitoring/uss_qualifier/scripts/format_test_documentation.sh +++ b/monitoring/uss_qualifier/scripts/format_test_documentation.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 22c421155d..6a1cb1ffea 100755 --- a/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh +++ b/monitoring/uss_qualifier/scripts/format_test_suite_docs.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 9db531c10a..f120dd8055 100755 --- a/monitoring/uss_qualifier/scripts/run_unit_tests.sh +++ b/monitoring/uss_qualifier/scripts/run_unit_tests.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +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 a39c8a1cc2..1c13b60336 100755 --- a/monitoring/uss_qualifier/scripts/validate_test_definitions.sh +++ b/monitoring/uss_qualifier/scripts/validate_test_definitions.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/../../.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +make image +cd .. # shellcheck disable=SC2086 docker run --name test_definition_validator \ diff --git a/schemas/manage_type_schemas.sh b/schemas/manage_type_schemas.sh index 3d1eae8cf2..aa3e296bf5 100755 --- a/schemas/manage_type_schemas.sh +++ b/schemas/manage_type_schemas.sh @@ -13,10 +13,9 @@ else fi cd "${BASEDIR}/.." || exit 1 -if [ -z "${DO_NOT_BUILD_MONITORING}" ]; then - monitoring/build.sh || exit 1 - export DO_NOT_BUILD_MONITORING=true -fi +cd monitoring +make image +cd .. action=${1:?The action must be specified as --check or --generate}