Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace prow build job waiting with github action #639

Merged
merged 8 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.BOT_PAT }} # 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:
Expand All @@ -199,15 +200,14 @@ jobs:
RELEASE_ID=$(./hack/ci/create_draft_release.sh $VERSION)
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT

- name: Trigger prow job 'release-eventing-manager-build'
- name: Add lightweight tag to trigger release build job
env:
GITHUB_TOKEN: ${{ secrets.BOT_PAT }} # 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: |
# The job release-eventing-manager-build will be triggered by pushing a new tag (format: x.y.z) to the repo.
# The build job will be triggered by pushing a new tag (format: x.y.z) to the repo.
git tag $VERSION
git push origin $VERSION

- name: Wait for job 'release-eventing-manager-build' to succeed
run: ./hack/ci/wait-for-release-build-job.sh ${{ github.ref_name }} 600 10 30 # Inputs: repo (format: "owner/repo"), timeout, interval and initial wait time.

- name: Create and upload eventing-manager.yaml and eventing-default-cr.yaml
env:
PULL_BASE_REF: ${{ needs.generate-version.outputs.VERSION }}
Expand All @@ -218,11 +218,20 @@ jobs:
run: |
./hack/ci/render_and_upload_manifests.sh

wait-until-build-succeeds:
needs: [generate-version, create-draft]
uses: "kyma-project/eventing-tools/.github/workflows/wait-build-reusable.yml@main"
with:
repository: ${{ github.repository_owner }}/eventing-manager
git_ref: ${{ needs.generate-version.outputs.VERSION }}
git_check_run_name: "build-${{ needs.generate-version.outputs.VERSION }} / Build image"

bump-sec-scanners-config-main:
name: Bump sec-scanners-config.yaml on main branch
needs:
- create-draft
- generate-version
- wait-until-build-succeeds
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.generate-version.outputs.VERSION }}
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/e2e-upgrade-test-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ on:
required: true
type: string
description: "The image tag of the Eventing Manager after the upgrade"
build-job-name:
type: string
description: "The name of the build job to wait for"
commit-sha:
type: string
description: "The commit sha of the new version"
Expand Down Expand Up @@ -88,20 +85,6 @@ jobs:
make e2e-setup
make e2e-eventing-setup

- name: Wait for the ${{ inputs.build-job-name }} job to succeed
Copy link
Member Author

@mfaizanse mfaizanse Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we will wait when calling this reusable workflow.

if: ${{ inputs.build-job-name != '' }}
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: ${{ inputs.build-job-name }}
commit_ref: "${{ inputs.commit-sha }}"
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
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "eventing-manager"

- name: Upgrade Eventing manager
id: upgrade-eventing-manager
run: |
Expand Down
86 changes: 39 additions & 47 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,60 +35,52 @@ on:
- PROJECT

jobs:
wait-until-build-succeeds:
export-info:
runs-on: ubuntu-latest
outputs:
image-name: ${{ steps.extract-image.outputs.image_name }}
git-ref: ${{ steps.extract-image.outputs.git_ref }}
steps:
- uses: actions/checkout@v4

- name: Wait for the 'pull-eventing-manager-build' job to succeed
id: pull-wait-build
if: github.event_name == 'pull_request'
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: "pull-eventing-manager-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
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "eventing-manager"

- name: Wait for the 'post-eventing-manager-build' job to succeed
id: push-wait-build
if: github.event_name == 'push'
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: "post-eventing-manager-build"
commit_ref: "${{ github.sha }}"
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
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "eventing-manager"

- name: Extract container image name from build logs (pull)
- name: export correct info based on event (PR or Push)
id: extract-image
env:
# Refernce: https://docs.github.com/en/actions/learn-github-actions/expressions#example
COMMIT_STATUS_JSON: "${{ github.event_name == 'push' && steps.push-wait-build.outputs.json || steps.pull-wait-build.outputs.json }}"
GIT_EVENT_NAME: "${{ github.event_name }}"
PR_NUMBER: "${{ github.event.number }}"
PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}"
HEAD_SHA: "${{ github.sha }}"
run: |
if [[ $GIT_EVENT_NAME == "pull_request" ]]
then
echo "exporting info for pull request..."
echo "image_name=europe-docker.pkg.dev/kyma-project/dev/eventing-manager:PR-${PR_NUMBER}" >> "$GITHUB_OUTPUT"
echo "git_ref=${PR_HEAD_SHA}" >> "$GITHUB_OUTPUT"
else
echo "exporting info for push..."
echo "image_name=europe-docker.pkg.dev/kyma-project/prod/eventing-manager:${HEAD_SHA}" >> "$GITHUB_OUTPUT"
echo "git_ref=${HEAD_SHA}" >> "$GITHUB_OUTPUT"
fi
- name: Print info
env:
IMAGE_NAME: ${{ steps.extract-image.outputs.image_name }}
GIT_REF: ${{ steps.extract-image.outputs.git_ref }}
run: |
./scripts/extract_image_from_build_logs.sh
# export value to job output
export IMAGE_NAME="$(cat image.name)"
echo "IMAGE_NAME: ${IMAGE_NAME}"
echo "image_name=${IMAGE_NAME}" >> "$GITHUB_OUTPUT"
echo "IMAGE: $IMAGE_NAME"
echo "Git ref: $GIT_REF"


wait-until-build-succeeds:
needs: export-info
uses: "kyma-project/eventing-tools/.github/workflows/wait-build-reusable.yml@main"
with:
repository: ${{ github.repository_owner }}/eventing-manager
git_ref: ${{ needs.export-info.outputs.git-ref }}
git_check_run_name: "build / Build image"

nats:
runs-on: ubuntu-latest
needs: wait-until-build-succeeds
needs: [export-info, wait-until-build-succeeds]
env:
MANAGER_IMAGE: ${{ needs.wait-until-build-succeeds.outputs.image-name }}
MANAGER_IMAGE: ${{ needs.export-info.outputs.image-name }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -152,9 +144,9 @@ jobs:

PeerAuthentication:
runs-on: ubuntu-latest
needs: wait-until-build-succeeds
needs: [export-info, wait-until-build-succeeds]
env:
MANAGER_IMAGE: ${{ needs.wait-until-build-succeeds.outputs.image-name }}
MANAGER_IMAGE: ${{ needs.export-info.outputs.image-name }}

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -200,10 +192,10 @@ jobs:
kubectl get peerauthentications.security.istio.io -A -o yaml

backend-switching:
needs: wait-until-build-succeeds
needs: [export-info, wait-until-build-succeeds]
if: github.event_name == 'push'
uses: "./.github/workflows/e2e-backend-switching-reuseable.yml"
with:
eventing-manager-image: ${{ needs.wait-until-build-succeeds.outputs.image-name }}
eventing-manager-image: ${{ needs.export-info.outputs.image-name }}
cluster-name-prefix: "ghem-"
secrets: inherit
9 changes: 8 additions & 1 deletion .github/workflows/pull-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ on:
- PROJECT

jobs:
wait-until-build-succeeds:
uses: "kyma-project/eventing-tools/.github/workflows/wait-build-reusable.yml@main"
with:
repository: ${{ github.repository_owner }}/eventing-manager
git_ref: ${{ github.event.pull_request.head.sha }}
git_check_run_name: "build / Build image"

upgrade-test:
needs: wait-until-build-succeeds
uses: ./.github/workflows/e2e-upgrade-test-reusable.yaml
with:
pre-upgrade-image-tag: main
post-upgrade-image-tag: PR-${{ github.event.number }}
build-job-name: pull-eventing-manager-build
commit-sha: ${{ github.event.pull_request.head.sha }}
secrets: inherit
20 changes: 5 additions & 15 deletions .github/workflows/pull-target-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,12 @@ jobs:
./scripts/is_pr_approved.sh

wait-until-build-succeeds:
runs-on: ubuntu-latest
needs: is-pr-approved
steps:
- name: Wait for the 'pull-eventing-manager-build' job to succeed
id: pull-wait-build
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: "pull-eventing-manager-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
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "eventing-manager"
uses: "kyma-project/eventing-tools/.github/workflows/wait-build-reusable.yml@main"
with:
repository: ${{ github.repository_owner }}/eventing-manager
git_ref: ${{ github.event.pull_request.head.sha }}
git_check_run_name: "build / Build image"

backend-switching:
needs: wait-until-build-succeeds
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/push-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ jobs:
run: |
echo "latest_release_tag=$(curl -s https://api.github.com/repos/kyma-project/eventing-manager/releases/latest | jq -r '.tag_name')" >> "$GITHUB_OUTPUT"

wait-until-build-succeeds:
uses: "kyma-project/eventing-tools/.github/workflows/wait-build-reusable.yml@main"
with:
repository: ${{ github.repository_owner }}/eventing-manager
git_ref: ${{ github.sha }}
git_check_run_name: "build / Build image"

upgrade-test:
uses: ./.github/workflows/e2e-upgrade-test-reusable.yaml
needs: get-latest-release
needs: [get-latest-release, wait-until-build-succeeds]
with:
pre-upgrade-image-tag: ${{ needs.get-latest-release.outputs.latest_release_tag }}
post-upgrade-image-tag: main
build-job-name: post-eventing-manager-build
commit-sha: ${{ github.sha }}
secrets: inherit
Loading