From 0961aae49e8549fea50f35b0b6a72749c563784b Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 11:08:27 +0200 Subject: [PATCH] replace prow build job waiting with github action --- .github/workflows/create-release.yaml | 48 +++++++++++++++++++++++---- .github/workflows/e2e.yml | 37 +++++++++++++++------ 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/.github/workflows/create-release.yaml b/.github/workflows/create-release.yaml index 437591d..f495dbb 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/create-release.yaml @@ -53,12 +53,20 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GIT_BOT_TOKEN }} # creating git tag using bot token because GITHUB_TOKEN would not trigger build workflow (https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow). - name: Create changelog env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./scripts/create_changelog.sh $RELEASE_VERSION + - name: Add lightweight tag to trigger release EPP build job + env: + GITHUB_TOKEN: ${{ secrets.GIT_BOT_TOKEN }} # creating git tag using bot token because GITHUB_TOKEN would not trigger build workflow (https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow). + run: | + git tag $RELEASE_VERSION + git push origin $RELEASE_VERSION + - name: Create the draft release id: create-draft env: @@ -67,17 +75,45 @@ jobs: RELEASE_ID=$(./scripts/create_draft_release.sh $RELEASE_VERSION) echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT - - name: Add lightweight tag to trigger release EPP build job + wait-for-build-job: + name: Wait for prow jobs + needs: [ verify-release, create-draft ] + runs-on: ubuntu-latest + + steps: + - name: Checkout eventing-tools + uses: actions/checkout@v4 + with: + repository: 'kyma-project/eventing-tools' + path: 'kyma-project/eventing-tools' + ref: main + sparse-checkout: 'scripts/wait-for-commit-check' + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + + - name: Install requirements run: | - git tag $RELEASE_VERSION - git push origin $RELEASE_VERSION + pip install -r $GITHUB_WORKSPACE/kyma-project/eventing-tools/scripts/wait-for-commit-check/requirements.txt - - name: Verify build job status - run: ./scripts/verify_prow_post_job_status.sh ${{ github.ref_name }} 600 10 30 + - name: wait for build + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY_FULL_NAME: ${{ github.repository_owner }}/eventing-publisher-proxy + GIT_REF: ${{ needs.verify-release.outputs.release_version }} + # The re-usable image-builder workflow from neighbors appends the "Build image" suffix to the check run name. + GIT_CHECK_RUN_NAME: "build-${{ needs.verify-release.outputs.release_version }} / Build image" + INTERVAL: 60 + TIMEOUT: 900 + run: | + python $GITHUB_WORKSPACE/kyma-project/eventing-tools/scripts/wait-for-commit-check/run.py publish-release: name: Publish release - needs: [verify-release, create-draft] + needs: [verify-release, create-draft, wait-for-build-job] runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index c34ae3e..b801b39 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -64,18 +64,35 @@ jobs: echo "Using Eventing Manager image:" kubectl get -n kyma-system deployment eventing-manager -o=jsonpath='{$.spec.template.spec.containers[:1].image}' - - name: Wait for build job to succeed - uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20 + - name: Wait for build job - Checkout eventing-tools + uses: actions/checkout@v4 + with: + repository: 'kyma-project/eventing-tools' + path: 'kyma-project/eventing-tools' + ref: main + sparse-checkout: 'scripts/wait-for-commit-check' + + - name: Wait for build job - Setup python + uses: actions/setup-python@v5 with: - context: "pull-eventing-publisher-proxy-build" - commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. - timeout: 600000 # 10 minutes in milliseconds - # The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting) - check_interval: 60000 # 1 minute in milliseconds + python-version: '3.10' + cache: 'pip' + + - name: Wait for build job - Install requirements + run: | + pip install -r $GITHUB_WORKSPACE/kyma-project/eventing-tools/scripts/wait-for-commit-check/requirements.txt + + - name: Wait for build job env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_OWNER: "${{ github.repository_owner }}" - GITHUB_REPO: "eventing-publisher-proxy" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY_FULL_NAME: ${{ github.repository_owner }}/eventing-publisher-proxy + GIT_REF: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests. + # The re-usable image-builder workflow from neighbors appends the "Build image" suffix to the check run name. + GIT_CHECK_RUN_NAME: "build / Build image" + INTERVAL: 60 + TIMEOUT: 900 + run: | + python $GITHUB_WORKSPACE/kyma-project/eventing-tools/scripts/wait-for-commit-check/run.py - name: Setup Eventing Manager with new EPP image run: |