From 332c41c4f09e2dbebd1c7fb36094125d4f9996a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:01:41 +0200 Subject: [PATCH 01/14] Add nightly run pipeline, modify existing for new tags --- .github/workflows/ci.yml | 9 ++++++ .github/workflows/nightly.yml | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd6cce98b3..dcb6cde9fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,13 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Determine branch-specific tag + id: vars + run: | + branch_name=${GITHUB_REF##*/} + sanitized_branch_name=$(echo "${branch_name}" | tr -cd '[:alnum:]-' | tr '[:upper:]' '[:lower:]') + echo "branch_name=${sanitized_branch_name}" >> $GITHUB_ENV + - name: Push dev run: | docker buildx create --use @@ -68,6 +75,7 @@ jobs: --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.branch_name }}-latest-dev \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev \ -f ./docker/Dockerfile \ --target dev \ @@ -174,6 +182,7 @@ jobs: --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.branch_name }}-latest-dist \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }} \ -f ./docker/Dockerfile \ --target dist \ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..5ff0046568 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,52 @@ +name: Nightly E2E Tests + +on: + schedule: + # Run at 2:00 AM every day + - cron: '0 2 * * *' + +jobs: + e2e_tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: DockerHub login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest Docker Images + run: | + docker pull ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dist + docker pull ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dev + + - name: Run Selenium Nightly E2E tests + run: | + dist_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dist \ + dev_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dev \ + docker compose \ + -f ./deployment/docker-compose.selenium-night.yml \ + run selenium + + - name: Upload Nightly Test Artifacts + uses: actions/upload-artifact@v4 + if: always() + continue-on-error: true + with: + name: nightly-e2e-report + path: ./backend/report/ + retention-days: 5 + + - name: Upload Nightly Coverage to Codecov + uses: codecov/codecov-action@v4 + if: always() + continue-on-error: true + with: + files: ./backend/coverage.xml + flags: nightly-e2e + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true From fe7a590e8b7576d9c88f93e8ef6109317470407b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:06:49 +0200 Subject: [PATCH 02/14] Add trigger to test pipeline --- .github/workflows/nightly.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5ff0046568..7948f45acf 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,9 +1,14 @@ name: Nightly E2E Tests on: + workflow_dispatch: schedule: # Run at 2:00 AM every day - cron: '0 2 * * *' + # temporary trigger for testing + pull_request: + branches: + - develop jobs: e2e_tests: From 892a01169f902d131596285c752bfd74e7893142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:10:36 +0200 Subject: [PATCH 03/14] set BRANCH_NAME --- .github/workflows/ci.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcb6cde9fe..cd1961244c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,12 +59,9 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Determine branch-specific tag - id: vars - run: | - branch_name=${GITHUB_REF##*/} - sanitized_branch_name=$(echo "${branch_name}" | tr -cd '[:alnum:]-' | tr '[:upper:]' '[:lower:]') - echo "branch_name=${sanitized_branch_name}" >> $GITHUB_ENV + - name: Extract branch name + id: extract_branch + run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Push dev run: | @@ -75,7 +72,7 @@ jobs: --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.branch_name }}-latest-dev \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev \ -f ./docker/Dockerfile \ --target dev \ @@ -182,7 +179,7 @@ jobs: --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.branch_name }}-latest-dist \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }} \ -f ./docker/Dockerfile \ --target dist \ From 2facb182efabe8522c630a0dd1a97c88e2bd68ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:12:56 +0200 Subject: [PATCH 04/14] fix for branch name --- .github/workflows/ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd1961244c..876e4eebe5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,9 +59,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Extract branch name - id: extract_branch - run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + - name: Determine Branch Name + id: branch_name + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + else + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + fi - name: Push dev run: | From 861d062af9f4f7b1d5bc650f635c8163ad99679c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:25:50 +0200 Subject: [PATCH 05/14] fix branch name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 876e4eebe5..7aa18a6676 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: id: branch_name run: | if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV + echo "BRANCH_NAME=${{ github.base_ref }}" >> $GITHUB_ENV else echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV fi From a3a176fe52b10c36c3047899e6c858be8a0ee82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:37:24 +0200 Subject: [PATCH 06/14] add branch name for dist img --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7aa18a6676..9787fd3bfd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,6 +170,15 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Determine Branch Name + id: branch_name + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + echo "BRANCH_NAME=${{ github.base_ref }}" >> $GITHUB_ENV + else + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + fi + - name: Push dist run: | docker buildx create --use From 79987c8c93e0ae7f51c7245184720a29857de717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:49:42 +0200 Subject: [PATCH 07/14] fix service name --- deployment/docker-compose.selenium-night.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/docker-compose.selenium-night.yml b/deployment/docker-compose.selenium-night.yml index ffe2d860b7..7d17e14278 100644 --- a/deployment/docker-compose.selenium-night.yml +++ b/deployment/docker-compose.selenium-night.yml @@ -2,7 +2,7 @@ version: '3.7' volumes: backend-web-app: services: - selenium-night: + selenium: stdin_open: true environment: - REDIS_INSTANCE=redis:6379 From fd22477d2e22908814ddc1cc9d99f60f929457c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:51:14 +0200 Subject: [PATCH 08/14] rm temporary pr rule --- .github/workflows/nightly.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 7948f45acf..e1cf0389f6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -5,10 +5,6 @@ on: schedule: # Run at 2:00 AM every day - cron: '0 2 * * *' - # temporary trigger for testing - pull_request: - branches: - - develop jobs: e2e_tests: From 7064c9cde4b9e8a1c0b03836481656af845cb236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:53:37 +0200 Subject: [PATCH 09/14] disable deploy --- .github/workflows/ci.yml | 104 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9787fd3bfd..cff3d5cc39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -287,58 +287,58 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - deploy: - runs-on: ubuntu-latest - needs: [e2e_tests, unit_tests, isort, black, flake8, mypy, frontend_tests] - if: | - github.event_name == 'push' && - ( - github.ref == 'refs/heads/develop' || - github.ref == 'refs/heads/staging' || - github.ref == 'refs/heads/master' || - github.ref == 'refs/heads/ephemeral-1' || - github.ref == 'refs/heads/ephemeral-2' || - github.ref == 'refs/heads/ephemeral-3' - ) - steps: - - name: Trigger deploy - run: | - # TODO: make it prettier - if [ ${{ github.ref }} == 'refs/heads/develop' ]; then - pipelineId=1159 - elif [ ${{ github.ref }} == 'refs/heads/staging' ]; then - pipelineId=1160 - elif [ ${{ github.ref }} == 'refs/heads/master' ]; then - pipelineId=1161,1165 - elif [ ${{ github.ref }} == 'refs/heads/ephemeral-1' ]; then - pipelineId=1164 - elif [ ${{ github.ref }} == 'refs/heads/ephemeral-2' ]; then - pipelineId=1253 - elif [ ${{ github.ref }} == 'refs/heads/ephemeral-3' ]; then - pipelineId=1283 - else - echo "No pipeline to trigger for ref ${{ github.ref }}" - exit 0 - fi + # deploy: + # runs-on: ubuntu-latest + # needs: [e2e_tests, unit_tests, isort, black, flake8, mypy, frontend_tests] + # if: | + # github.event_name == 'push' && + # ( + # github.ref == 'refs/heads/develop' || + # github.ref == 'refs/heads/staging' || + # github.ref == 'refs/heads/master' || + # github.ref == 'refs/heads/ephemeral-1' || + # github.ref == 'refs/heads/ephemeral-2' || + # github.ref == 'refs/heads/ephemeral-3' + # ) + # steps: + # - name: Trigger deploy + # run: | + # # TODO: make it prettier + # if [ ${{ github.ref }} == 'refs/heads/develop' ]; then + # pipelineId=1159 + # elif [ ${{ github.ref }} == 'refs/heads/staging' ]; then + # pipelineId=1160 + # elif [ ${{ github.ref }} == 'refs/heads/master' ]; then + # pipelineId=1161,1165 + # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-1' ]; then + # pipelineId=1164 + # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-2' ]; then + # pipelineId=1253 + # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-3' ]; then + # pipelineId=1283 + # else + # echo "No pipeline to trigger for ref ${{ github.ref }}" + # exit 0 + # fi - IFS=',' read -ra pipelines <<< "$pipelineId" - for pipeline in "${pipelines[@]}"; do - jsonBody='{"variables": {"sha": {"isSecret": false, "value": "${{ github.sha }}"}, "tag": {"isSecret": false, "value": "core-${{ github.sha }}"}}}' - contentLength=$(echo -n $jsonBody | wc -c) - project=ICTD-HCT-MIS - organization=unicef + # IFS=',' read -ra pipelines <<< "$pipelineId" + # for pipeline in "${pipelines[@]}"; do + # jsonBody='{"variables": {"sha": {"isSecret": false, "value": "${{ github.sha }}"}, "tag": {"isSecret": false, "value": "core-${{ github.sha }}"}}}' + # contentLength=$(echo -n $jsonBody | wc -c) + # project=ICTD-HCT-MIS + # organization=unicef - echo Triggering deploy for pipeline $pipeline - echo JSON body: $jsonBody + # echo Triggering deploy for pipeline $pipeline + # echo JSON body: $jsonBody - curl -v -L \ - -u ":${{ secrets.AZURE_PAT }}" \ - -H "Content-Type: application/json" \ - -H "Content-Length: $contentLength" \ - -d "$jsonBody" \ - https://dev.azure.com/$organization/$project/_apis/pipelines/$pipeline/runs?api-version=7.1-preview.1 - if [ $? -ne 0 ]; then - echo "Failed to trigger deploy for pipeline $pipeline" - exit 1 - fi - done + # curl -v -L \ + # -u ":${{ secrets.AZURE_PAT }}" \ + # -H "Content-Type: application/json" \ + # -H "Content-Length: $contentLength" \ + # -d "$jsonBody" \ + # https://dev.azure.com/$organization/$project/_apis/pipelines/$pipeline/runs?api-version=7.1-preview.1 + # if [ $? -ne 0 ]; then + # echo "Failed to trigger deploy for pipeline $pipeline" + # exit 1 + # fi + # done From 5631506becbdb1959ce46b2bcf9bc47e04532ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:54:19 +0200 Subject: [PATCH 10/14] add temporary rule on push to this branch --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cff3d5cc39..07d57f858a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: - staging - master - ephemeral-* + - feat/nightly-e2e-run pull_request: branches: - develop From ea787da50d571b3a53f7a385acad27eabebb775a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:59:13 +0200 Subject: [PATCH 11/14] add tag with latest branch only on pushes --- .github/workflows/ci.yml | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07d57f858a..9af1c1d71c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,23 +63,28 @@ jobs: - name: Determine Branch Name id: branch_name run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "BRANCH_NAME=${{ github.base_ref }}" >> $GITHUB_ENV - else + if [ "${{ github.event_name }}" = "push" ]; then echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV fi - name: Push dev run: | docker buildx create --use + + tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev" + + if [ -n "${{ env.BRANCH_NAME }}" ]; then + tags="$tags -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev" + fi + docker buildx build \ --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev \ + $tags \ -f ./docker/Dockerfile \ --target dev \ --push \ @@ -174,9 +179,7 @@ jobs: - name: Determine Branch Name id: branch_name run: | - if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "BRANCH_NAME=${{ github.base_ref }}" >> $GITHUB_ENV - else + if [ "${{ github.event_name }}" = "push" ]; then echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV fi @@ -184,6 +187,14 @@ jobs: run: | docker buildx create --use + tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}" + + if [ -n "${{ env.BRANCH_NAME }}" ]; then + tags="$tags -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist" + fi + # Base part of the command build_command="docker buildx build \ --progress=plain \ @@ -193,9 +204,7 @@ jobs: --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }} \ + $tags \ -f ./docker/Dockerfile \ --target dist \ --push ./" From 97f27f6b38aa7f48765de997d7f6d618f7c5d6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:01:02 +0200 Subject: [PATCH 12/14] Revert "disable deploy" This reverts commit 7064c9cde4b9e8a1c0b03836481656af845cb236. --- .github/workflows/ci.yml | 104 +++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9af1c1d71c..c051d72031 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -297,58 +297,58 @@ jobs: ignore-unfixed: true vuln-type: 'os,library' severity: 'CRITICAL,HIGH' - # deploy: - # runs-on: ubuntu-latest - # needs: [e2e_tests, unit_tests, isort, black, flake8, mypy, frontend_tests] - # if: | - # github.event_name == 'push' && - # ( - # github.ref == 'refs/heads/develop' || - # github.ref == 'refs/heads/staging' || - # github.ref == 'refs/heads/master' || - # github.ref == 'refs/heads/ephemeral-1' || - # github.ref == 'refs/heads/ephemeral-2' || - # github.ref == 'refs/heads/ephemeral-3' - # ) - # steps: - # - name: Trigger deploy - # run: | - # # TODO: make it prettier - # if [ ${{ github.ref }} == 'refs/heads/develop' ]; then - # pipelineId=1159 - # elif [ ${{ github.ref }} == 'refs/heads/staging' ]; then - # pipelineId=1160 - # elif [ ${{ github.ref }} == 'refs/heads/master' ]; then - # pipelineId=1161,1165 - # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-1' ]; then - # pipelineId=1164 - # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-2' ]; then - # pipelineId=1253 - # elif [ ${{ github.ref }} == 'refs/heads/ephemeral-3' ]; then - # pipelineId=1283 - # else - # echo "No pipeline to trigger for ref ${{ github.ref }}" - # exit 0 - # fi + deploy: + runs-on: ubuntu-latest + needs: [e2e_tests, unit_tests, isort, black, flake8, mypy, frontend_tests] + if: | + github.event_name == 'push' && + ( + github.ref == 'refs/heads/develop' || + github.ref == 'refs/heads/staging' || + github.ref == 'refs/heads/master' || + github.ref == 'refs/heads/ephemeral-1' || + github.ref == 'refs/heads/ephemeral-2' || + github.ref == 'refs/heads/ephemeral-3' + ) + steps: + - name: Trigger deploy + run: | + # TODO: make it prettier + if [ ${{ github.ref }} == 'refs/heads/develop' ]; then + pipelineId=1159 + elif [ ${{ github.ref }} == 'refs/heads/staging' ]; then + pipelineId=1160 + elif [ ${{ github.ref }} == 'refs/heads/master' ]; then + pipelineId=1161,1165 + elif [ ${{ github.ref }} == 'refs/heads/ephemeral-1' ]; then + pipelineId=1164 + elif [ ${{ github.ref }} == 'refs/heads/ephemeral-2' ]; then + pipelineId=1253 + elif [ ${{ github.ref }} == 'refs/heads/ephemeral-3' ]; then + pipelineId=1283 + else + echo "No pipeline to trigger for ref ${{ github.ref }}" + exit 0 + fi - # IFS=',' read -ra pipelines <<< "$pipelineId" - # for pipeline in "${pipelines[@]}"; do - # jsonBody='{"variables": {"sha": {"isSecret": false, "value": "${{ github.sha }}"}, "tag": {"isSecret": false, "value": "core-${{ github.sha }}"}}}' - # contentLength=$(echo -n $jsonBody | wc -c) - # project=ICTD-HCT-MIS - # organization=unicef + IFS=',' read -ra pipelines <<< "$pipelineId" + for pipeline in "${pipelines[@]}"; do + jsonBody='{"variables": {"sha": {"isSecret": false, "value": "${{ github.sha }}"}, "tag": {"isSecret": false, "value": "core-${{ github.sha }}"}}}' + contentLength=$(echo -n $jsonBody | wc -c) + project=ICTD-HCT-MIS + organization=unicef - # echo Triggering deploy for pipeline $pipeline - # echo JSON body: $jsonBody + echo Triggering deploy for pipeline $pipeline + echo JSON body: $jsonBody - # curl -v -L \ - # -u ":${{ secrets.AZURE_PAT }}" \ - # -H "Content-Type: application/json" \ - # -H "Content-Length: $contentLength" \ - # -d "$jsonBody" \ - # https://dev.azure.com/$organization/$project/_apis/pipelines/$pipeline/runs?api-version=7.1-preview.1 - # if [ $? -ne 0 ]; then - # echo "Failed to trigger deploy for pipeline $pipeline" - # exit 1 - # fi - # done + curl -v -L \ + -u ":${{ secrets.AZURE_PAT }}" \ + -H "Content-Type: application/json" \ + -H "Content-Length: $contentLength" \ + -d "$jsonBody" \ + https://dev.azure.com/$organization/$project/_apis/pipelines/$pipeline/runs?api-version=7.1-preview.1 + if [ $? -ne 0 ]; then + echo "Failed to trigger deploy for pipeline $pipeline" + exit 1 + fi + done From c911d2caa577091abc9346e21254266a1c043b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:01:07 +0200 Subject: [PATCH 13/14] Revert "add temporary rule on push to this branch" This reverts commit 5631506becbdb1959ce46b2bcf9bc47e04532ec4. --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c051d72031..ba48420a1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: - staging - master - ephemeral-* - - feat/nightly-e2e-run pull_request: branches: - develop From 83f2c188f4cc587d316d362008b0d4e4583cb62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Wo=C5=BAniak?= <17177420+wozniakpl@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:02:00 +0200 Subject: [PATCH 14/14] fix copy-paste error --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba48420a1f..02d68ceaa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,7 +71,6 @@ jobs: docker buildx create --use tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev" if [ -n "${{ env.BRANCH_NAME }}" ]; then @@ -187,7 +186,6 @@ jobs: docker buildx create --use tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist \ -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}" if [ -n "${{ env.BRANCH_NAME }}" ]; then