Skip to content

Commit

Permalink
frontend: ping frontend on docker image release
Browse files Browse the repository at this point in the history
Why

The frontend is now part of quickstart-vdk.
On changes to the docker image, the helm
chart needs to be redeployed. We need to
make sure that the frontend is operational
once the helm chart is deployed.

What

Introduce new post_release_image stage to ci
Introduce new post_release_image_test stage to ci
Trigger deployment of test control service on frontend changes
merged into main
Ping the frontend using heartbeat once control service is deployed
Tag the frontend image as stable once heartbeat test passes

How has this been tested

n/a

What kind of change is this

feature/non-breaking

Signed-off-by: Dilyan Marinov <[email protected]>
  • Loading branch information
Dilyan Marinov committed Jun 1, 2023
1 parent 2cbc6ec commit 2da5375
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stages:
- pre_release_test
- release
- release_image
- post_release_image
- post_release_image_test
- end

build-check-prerequisites:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ global: {}
image:
registry: registry.hub.docker.com/versatiledatakit
repository: pipelines-control-service
tag: "99a4957"
tag: "stable"
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
Expand All @@ -32,7 +32,7 @@ operationsUi:
image:
registry: registry.hub.docker.com/versatiledatakit
repository: vdk-operations-ui
tag: "latest"
tag: "stable"
username:
password:
replicaCount: 1
Expand Down
52 changes: 50 additions & 2 deletions projects/frontend/cicd/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
- "projects/frontend/data-pipelines/gui/Dockerfile"
- "projects/frontend/data-pipelines/gui/config/nginx.conf"

.frontend_retry:
retry_options:
max: 1
when:
- always

frontend-data-pipelines-build:
image: "versatiledatakit/vdk-cicd-base-gui:2.0.0"
stage: build
Expand Down Expand Up @@ -102,7 +108,7 @@ frontend-data-pipelines-release:
expire_in: 1 week

frontend_publish_ui_image:
stage: release
stage: release_image
before_script:
- cd projects/frontend
script:
Expand All @@ -118,8 +124,50 @@ frontend_publish_ui_image:
changes: *frontend_data_pipelines_locations
extends: .frontend_publish_docker_image

frontend_deploy_testing_data_pipelines:
stage: post_release_image
image: docker:23.0.1
script:
- apk --no-cache add bash openssl curl git gettext zip py-pip
- pip install --upgrade pip && pip install awscli
- export DESIRED_VERSION=v3.11.3 # helm version 3.11.3
- export TAG=latest
- export FRONTEND_TAG=$(git rev-parse --short HEAD)
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- bash -ex ./projects/control-service/cicd/deploy-testing-pipelines-service.sh
retry: !reference [.frontend_retry, retry_options]
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "main"'
changes: *frontend_shared_components_locations
- if: '$CI_COMMIT_BRANCH == "main"'
changes: *frontend_data_pipelines_locations

frontend_post_deployment_test:
stage: post_release_image_test
image: python:3.7
script:
- set -x
- pip install quickstart-vdk
- pip install vdk-heartbeat[trino]
- vdk version
- export IMAGE_TAG="$(git rev-parse --short HEAD)"
- export VDKCLI_OAUTH2_REFRESH_TOKEN=$VDK_API_TOKEN
- export VDK_HEARTBEAT_OP_ID="vdkcs-$CI_PIPELINE_ID"
- vdk-heartbeat -f projects/frontend/cicd/ping_frontend_heartbeat_config.ini
- bash -ex ./projects/control-service/cicd/tag_image_dockerhub.sh pipelines-control-service $IMAGE_TAG stable
retry: !reference [.frontend_retry, retry_options]
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "main"'
changes: *frontend_shared_components_locations
- if: '$CI_COMMIT_BRANCH == "main"'
changes: *frontend_data_pipelines_locations

frontend_publish_test_image:
stage: release
stage: release_image
script:
- docker login --username "${VDK_DOCKER_REGISTRY_USERNAME}" --password "${VDK_DOCKER_REGISTRY_PASSWORD}" "${VDK_DOCKER_REGISTRY_URL}"
- cd projects/frontend/cicd
Expand Down
5 changes: 5 additions & 0 deletions projects/frontend/cicd/ping_frontend_heartbeat_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[DEFAULT]
JOB_RUN_TEST_MODULE_NAME=vdk.internal.heartbeat.ping_frontend_test
JOB_RUN_TEST_CLASS_NAME=PingFrontendTest

CONTROL_API_URL=http://cicd-control-service-ui:80
3 changes: 2 additions & 1 deletion projects/frontend/cicd/publish_image_dockerhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ version_tag=$(awk -v id=$patch_version 'BEGIN { FS="."; OFS = "."; ORS = "" } {

image_repo="$VDK_DOCKER_REGISTRY_URL/$name"
image_tag="$image_repo:$version_tag"
commit_sha=$(git rev-parse --short HEAD)

docker build -t "$image_tag" -t "$image_repo:latest" $ui_path
docker build -t "$image_tag" -t "$image_repo:latest" -t "$image_repo:$commit_sha" $ui_path
docker push "$image_tag"
docker push "$image_repo:latest"

0 comments on commit 2da5375

Please sign in to comment.