From 96b9357a71596dc2f2f0e4d7893de2bd49c80e09 Mon Sep 17 00:00:00 2001 From: Louis GERARD <186476141+lgerard-pass@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:23:39 +0100 Subject: [PATCH] (PC-33785)[API] ci: run sandbox only after helm chart is deployed --- .../dev_on_workflow_deploy_pullrequests.yml | 24 +++++++++++++++++++ .../templates/pullrequest-db-init-01.yaml | 2 -- .../templates/pullrequest-db-init-02.yaml | 2 -- .../templates/pullrequest-db-init-03.yaml | 2 -- .../templates/pullrequest-db-init-05.yaml | 2 -- .../templates/pullrequest-db-init.yaml | 2 -- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dev_on_workflow_deploy_pullrequests.yml b/.github/workflows/dev_on_workflow_deploy_pullrequests.yml index a8cb9b411ab..de2bd4592ea 100644 --- a/.github/workflows/dev_on_workflow_deploy_pullrequests.yml +++ b/.github/workflows/dev_on_workflow_deploy_pullrequests.yml @@ -256,3 +256,27 @@ jobs: app_name: pcapi-pr-${{ github.event.pull_request.number }} argocd_app_wait: true prune: true + + - name: "Run sandbox" + run: | + set -e + VERSION="${{ inputs.app_version }}" + export ENVIRONMENT="${{ inputs.environment }}" + IMAGE="europe-west1-docker.pkg.dev/passculture-infra-prod/pass-culture-artifact-registry/pcapi" + export IMAGE="${IMAGE}:${VERSION}" + export PRID=${{ github.event.pull_request.number }} + + echo "=== exec: flask sandbox -n industrial" + export DATE=$(date +"%Y-%m-%d-%H-%M-%S") + start=$(date +%s.%N) + envsubst < .github/workflows/templates/pullrequest-db-init-05.yaml | kubectl -n pcapi-pr-${{ github.event.pull_request.number }} apply -f - + while true; + do + kubectl logs -n pcapi-pr-${{ github.event.pull_request.number }} -f jobs/pullrequest-db-init-05-${DATE} && break + done + kubectl wait --for=condition=complete --timeout=1800s -n pcapi-pr-${{ github.event.pull_request.number }} jobs/pullrequest-db-init-05-${DATE} + end=$(date +%s.%N) + duration=`date -d@$(bc <<< "$end - $start") -u +%H:%M:%S` + { + echo "| flask sandbox -n industrial | $duration |" + } >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/templates/pullrequest-db-init-01.yaml b/.github/workflows/templates/pullrequest-db-init-01.yaml index be9527313b6..7ce635fe75f 100644 --- a/.github/workflows/templates/pullrequest-db-init-01.yaml +++ b/.github/workflows/templates/pullrequest-db-init-01.yaml @@ -27,13 +27,11 @@ spec: envFrom: - configMapRef: name: testing-pcapi-api - optional: true - configMapRef: name: testing-pcapi-api-specific optional: true - secretRef: name: testing-pcapi - optional: true - secretRef: name: testing-pcapi-pgsql command: diff --git a/.github/workflows/templates/pullrequest-db-init-02.yaml b/.github/workflows/templates/pullrequest-db-init-02.yaml index b337028b4ed..b5f366f6be2 100644 --- a/.github/workflows/templates/pullrequest-db-init-02.yaml +++ b/.github/workflows/templates/pullrequest-db-init-02.yaml @@ -27,13 +27,11 @@ spec: envFrom: - configMapRef: name: testing-pcapi-api - optional: true - configMapRef: name: testing-pcapi-api-specific optional: true - secretRef: name: testing-pcapi - optional: true - secretRef: name: testing-pcapi-pgsql command: diff --git a/.github/workflows/templates/pullrequest-db-init-03.yaml b/.github/workflows/templates/pullrequest-db-init-03.yaml index c92a4471972..bc605401988 100644 --- a/.github/workflows/templates/pullrequest-db-init-03.yaml +++ b/.github/workflows/templates/pullrequest-db-init-03.yaml @@ -27,13 +27,11 @@ spec: envFrom: - configMapRef: name: testing-pcapi-api - optional: true - configMapRef: name: testing-pcapi-api-specific optional: true - secretRef: name: testing-pcapi - optional: true - secretRef: name: testing-pcapi-pgsql command: diff --git a/.github/workflows/templates/pullrequest-db-init-05.yaml b/.github/workflows/templates/pullrequest-db-init-05.yaml index 9b729526764..67dbbe33622 100644 --- a/.github/workflows/templates/pullrequest-db-init-05.yaml +++ b/.github/workflows/templates/pullrequest-db-init-05.yaml @@ -27,13 +27,11 @@ spec: envFrom: - configMapRef: name: testing-pcapi-api - optional: true - configMapRef: name: testing-pcapi-api-specific optional: true - secretRef: name: testing-pcapi - optional: true - secretRef: name: testing-pcapi-pgsql command: diff --git a/.github/workflows/templates/pullrequest-db-init.yaml b/.github/workflows/templates/pullrequest-db-init.yaml index 00603c00813..e9f10992e87 100644 --- a/.github/workflows/templates/pullrequest-db-init.yaml +++ b/.github/workflows/templates/pullrequest-db-init.yaml @@ -26,13 +26,11 @@ spec: envFrom: - configMapRef: name: testing-pcapi-api - optional: true - configMapRef: name: testing-pcapi-api-specific optional: true - secretRef: name: testing-pcapi - optional: true - secretRef: name: testing-pcapi-pgsql command: