Skip to content

Commit

Permalink
refactor: use generic bash scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-greffe committed Apr 9, 2024
1 parent b53ad15 commit 00ef64d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 41 deletions.
3 changes: 2 additions & 1 deletion e2e-tests.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ WORKDIR /opt/kalisio/$APP/scripts
RUN chmod +x run_e2e_test.sh

# Run tests
# SLACK_WEBHOOK & CC_TEST_REPORTER_ID are set upon Kubernetes container startup
WORKDIR /opt/kalisio/$APP
CMD ["bash", "-c", "/opt/kalisio/$APP/scripts/run_e2e_test.sh $APP"]
CMD ["bash", "-c", "/opt/kalisio/$APP/scripts/run_e2e_test.sh $APP" "$SLACK_WEBHOOK" "$CC_TEST_REPORTER_ID"]
44 changes: 6 additions & 38 deletions scripts/build_e2e_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -euo pipefail
THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}")
THIS_DIR=$(dirname "$THIS_FILE")
ROOT_DIR=$(dirname "$THIS_DIR")
WORKSPACE_DIR="$(dirname "$ROOT_DIR")"

. "$THIS_DIR/kash/kash.sh"

Expand All @@ -22,46 +23,13 @@ while getopts "p" option; do
esac
done

## Init workspace
## Report to slack
##

WORKSPACE_DIR="$(dirname "$ROOT_DIR")"
init_app_infos "$ROOT_DIR" "$WORKSPACE_DIR/development/workspaces/apps"

APP=$(get_app_name)
VERSION=$(get_app_version)
FLAVOR=$(get_app_flavor)

echo "About to build ${APP} v${VERSION}-$FLAVOR ..."

load_env_files "$WORKSPACE_DIR/development/common/kalisio_harbor.enc.env"
load_value_files "$WORKSPACE_DIR/development/common/KALISIO_HARBOR_PASSWORD.enc.value"
load_env_files "$WORKSPACE_DIR/development/common/SLACK_WEBHOOK_APPS.enc.env"
trap 'slack_ci_report "$ROOT_DIR" "Build e2e tests" "$?" "$SLACK_WEBHOOK_APPS"' EXIT

## Build container
## Build e2e tests
##

IMAGE_NAME="$KALISIO_HARBOR_URL/kalisio/$APP-e2e-tests"
IMAGE_TAG="$VERSION-$FLAVOR"

begin_group "Building container ..."

docker login --username "$KALISIO_HARBOR_USERNAME" --password-stdin "$KALISIO_HARBOR_URL" < "$KALISIO_HARBOR_PASSWORD"
# DOCKER_BUILDKIT is here to be able to use Dockerfile specific dockerginore (e2e-tests.Dockerfile.dockerignore)
DOCKER_BUILDKIT=1 docker build \
--build-arg APP="$APP" \
--build-arg NODE_APP_INSTANCE="$FLAVOR" \
--build-arg SUBDOMAIN="$FLAVOR.kalisio.xyz" \
--build-arg HEADLESS=true \
-f e2e-tests.Dockerfile \
-t "$IMAGE_NAME:$IMAGE_TAG" \
"$WORKSPACE_DIR"
docker tag "$IMAGE_NAME:$IMAGE_TAG" "$IMAGE_NAME:$FLAVOR"

if [ "$PUBLISH" = true ]; then
docker push "$IMAGE_NAME:$IMAGE_TAG"
docker push "$IMAGE_NAME:$FLAVOR"
fi

docker logout "$KALISIO_HARBOR_URL"

end_group "Building container ..."
build_e2e_tests "$ROOT_DIR" "$PUBLISH"
2 changes: 1 addition & 1 deletion scripts/kash
Submodule kash updated 1 files
+71 −8 kash.sh
7 changes: 6 additions & 1 deletion scripts/run_e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ set -uo pipefail
# set -x

APP=$1
SLACK_WEBHOOK=$2
CC_TEST_REPORTER_ID=$3

THIS_FILE=$(readlink -f "${BASH_SOURCE[0]}")
THIS_DIR=$(dirname "$THIS_FILE")
ROOT_DIR=$(dirname "$THIS_DIR")

. "$THIS_DIR/kash/kash.sh"

run_e2e_tests "$ROOT_DIR" "$APP"
## Run e2e tests
##

run_e2e_tests "$ROOT_DIR" "$APP" "$SLACK_WEBHOOK" "$CC_TEST_REPORTER_ID"

0 comments on commit 00ef64d

Please sign in to comment.