From c7ac5da98548c5b4c9310945fa40786a260d47fd Mon Sep 17 00:00:00 2001 From: Gustavo Lira e Silva Date: Thu, 6 Mar 2025 12:25:02 -0300 Subject: [PATCH] chore(e2e): rhidp-6297 Automate E2E Runner Image Build and Push to Quay via GitHub Actions (#2524) * Add GitHub workflow to build and push e2e-runner image This workflow builds the e2e-runner Docker image and pushes it to Quay.io upon pull requests to the main branch. Signed-off-by: Gustavo Lira * Update README with OpenShift CI image workflow details Clarified the process for updating and deploying the `rhdh-e2e-runner` image, including workflows for `main` and other branches. Highlighted steps for local testing, GitHub Actions automation, and propagation delays in OpenShift CI's mirror Signed-off-by: Gustavo Lira --------- Signed-off-by: Gustavo Lira --- .github/workflows/push-e2e-runner.yaml | 57 ++++++++++++++++++++++++++ .ibm/images/README | 47 +++++++++++++-------- 2 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/push-e2e-runner.yaml diff --git a/.github/workflows/push-e2e-runner.yaml b/.github/workflows/push-e2e-runner.yaml new file mode 100644 index 0000000000..649c3f4b84 --- /dev/null +++ b/.github/workflows/push-e2e-runner.yaml @@ -0,0 +1,57 @@ +name: Build & Push e2e-runner Image to Quay.io + +on: + pull_request: + branches: + - main + paths: + - '.ibm/images/Dockerfile' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + REGISTRY: quay.io + REGISTRY_IMAGE: rhdh-community/rhdh-e2e-runner + IMAGE_TAG: main + +jobs: + build-image: + name: Build & Push e2e-runner Image + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04] + runs-on: ${{ matrix.os }} + permissions: + contents: read + packages: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Prepare Environment Variables + run: | + echo "PLATFORM=linux/amd64" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Quay.io + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build and Push Image + uses: docker/build-push-action@v5 + with: + context: .ibm/images/ + push: true + tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }} + platforms: ${{ env.PLATFORM }} diff --git a/.ibm/images/README b/.ibm/images/README index 5a59c613a5..ab936d3388 100644 --- a/.ibm/images/README +++ b/.ibm/images/README @@ -1,23 +1,38 @@ -This Dockerfile creates an image to be used by the IBM Cloud pipelines +# RHDH e2e Runner - OpenShift CI Integration -Currently this image is built by hand at intervals and pushed to https://quay.io/repository/rhdh-community/rhdh-e2e-runner?tab=tags when in need of an update. +## Overview +The `rhdh-e2e-runner` is a container image used in **OpenShift CI**, where it is deployed via a **mirror** that fetches the image from the Quay repository. -``` -SHA="$(git rev-parse --short=8 HEAD)" -# main or release-1.y -branch="$(git rev-parse --abbrev-ref HEAD)" -image="quay.io/rhdh-community/rhdh-e2e-runner:${branch}" +## Workflow for Updating the Image -# build and push -podman build . -f Dockerfile -t "${image}-${SHA}" && podman push "${image}-${SHA}" +### **Main Branch Workflow** +For changes to the image in `.ibm/images/Dockerfile`, follow these steps: +1. **Perform a Local Test:** + - Before updating the `Dockerfile`, perform a local test by running the e2e tests to ensure the changes are stable. -# update the floating (branch-named) tag too -skopeo --insecure-policy copy --all docker://${image}-${SHA} docker://${image} -``` +2. **Update the Dockerfile:** + - Once validated, update `.ibm/images/Dockerfile` with the required changes. -In future this might be automated so that if the contents of this folder changes, a new image is pushed automatically. +3. **GitHub Actions Build & Push:** + - The **GitHub Actions workflow** automatically builds and pushes the updated image to **Quay.io**. + - This only happens **after all tests are completed successfully**. -See also: +4. **Propagation to OpenShift CI Mirror:** + - After the image is pushed to Quay, OpenShift CI **does not** immediately use the new image. + - There is a delay while OpenShift updates its **mirror** with the new version. -* https://quay.io/repository/rhdh-community/rhdh-e2e-runner?tab=info -* https://issues.redhat.com/browse/RHIDP-6244 +5. **Merge to Main Branch:** + - The image update process happens **before merging into `main`**. + - Ensure that the updated image has been successfully used in e2e tests before merging. + +### **Other Branches Workflow** +For branches **other than `main`**, OpenShift CI does **not** fetch from Quay: +- Instead, **OpenShift CI builds the image directly** from `.ibm/images/Dockerfile`. +- Any changes made to the file will **immediately reflect** in the test execution. +- There is no need to wait for an image update in the mirror. + +## Key Considerations +- **Local testing is mandatory** before making any modifications. +- **GitHub Actions automates the push process** only for `main` branch updates. +- **OpenShift CI mirror has a delay** in updating the image after it is pushed to Quay. +- **Other branches build the image directly**, so changes take effect immediately.