Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tooling] Use make image to build image #273

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion monitoring/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
report.json
config.json
run_locally_list.txt
run_locally_scd_deploy_others.sh
run_locally_scd_deploy_others.sh

# Make target placeholders
image
4 changes: 2 additions & 2 deletions monitoring/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions monitoring/atproxy/run_locally.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

set -eo pipefail

# Find and change to repo root directory
OS=$(uname)
if [[ "$OS" == "Darwin" ]]; then
Expand All @@ -10,10 +12,10 @@ 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 || exit 1
make image
)

CLIENT_BASIC_AUTH="local_client:local_client"
PUBLIC_KEY="/var/test-certs/auth2.pem"
Expand Down
1 change: 1 addition & 0 deletions monitoring/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ docker image build \
--build-arg commit_hash="$(git rev-parse HEAD)" \
. \
|| exit 1
touch monitoring/image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would it make sense to use a text file and write inside its purpose? Something like:
"File created by monitoring/build.sh to keep track of the latest build run date time."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wouldn't want to name it differently, despite the value of making its purpose clear via, e.g., image.maketarget, since having the file named anything other than the makefile target makes management difficult within make. But content sounds good; updated.

21 changes: 16 additions & 5 deletions monitoring/mock_uss/run_locally_msgsigning.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#!/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
set -eo pipefail

# 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 || exit 1
make image
)

AUTH="DummyOAuth(http://host.docker.internal:8085/token,uss1)"
DSS="http://host.docker.internal:8082"
Expand Down Expand Up @@ -32,7 +43,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
19 changes: 14 additions & 5 deletions monitoring/mock_uss/run_locally_test_geoawareness.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#!/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 || exit 1
make image
)

PUBLIC_KEY="/var/test-certs/auth2.pem"
container_name="mock_uss_geoawareness_test"
Expand All @@ -27,7 +36,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}
10 changes: 5 additions & 5 deletions monitoring/mock_uss/start_all_local_mocks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -eo pipefail

Expand All @@ -12,10 +12,10 @@ 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 || exit 1
make image
)

./monitoring/mock_uss/run_locally.sh up -d

Expand Down
2 changes: 1 addition & 1 deletion monitoring/prober/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ First, build the monitoring image:

(from the repo root)
```shell script
monitoring/build.sh
make image
```

...then run prober:
Expand Down
12 changes: 4 additions & 8 deletions monitoring/prober/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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 || exit 1
make image
)

CORE_SERVICE_CONTAINER="local_infra-dss-1"
OAUTH_CONTAINER="local_infra-oauth-1"
Expand All @@ -26,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
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/bin/generate_rid_test_definition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ 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 || exit 1
make image
)

CONFIG_LOCATION="monitoring/uss_qualifier/config_run_locally.json"
CONFIG='--config config_run_locally.json'
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ 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 || exit 1
make image
)

if [ "$CI" == "true" ]; then
docker_args="--add-host host.docker.internal:host-gateway" # Required to reach other containers in Ubuntu (used for Github Actions)
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ 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 || exit 1
make image
)

CONFIG_NAME="${1:-ALL}"

Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/scripts/format_test_documentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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 || exit 1
make image
)

# shellcheck disable=SC2086
docker run --name test_documentation_formatter \
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/scripts/format_test_suite_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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 || exit 1
make image
)

# shellcheck disable=SC2086
docker run --name test_suite_docs_formatter \
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/scripts/run_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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 || exit 1
make image
)

# shellcheck disable=SC2086
docker run --name uss_qualifier_unit_test \
Expand Down
8 changes: 4 additions & 4 deletions monitoring/uss_qualifier/scripts/validate_test_definitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ 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 || exit 1
make image
)

# shellcheck disable=SC2086
docker run --name test_definition_validator \
Expand Down
7 changes: 3 additions & 4 deletions schemas/manage_type_schemas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Loading