diff --git a/.github/workflows/pipelines-ci.yaml b/.github/workflows/pipelines-ci.yaml new file mode 100644 index 00000000000..cb53de4a66a --- /dev/null +++ b/.github/workflows/pipelines-ci.yaml @@ -0,0 +1,48 @@ +name: Openshift Pipelines CI + +on: + pull_request: + paths: + - 'components/pipeline-service/**/main-pipeline-service-configuration.yaml' + - 'components/pipeline-service/**/deploy.yaml' + +jobs: + validate-pipelines-index: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + id-token: write + steps: + - name: Checkout pull request head + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: head + sparse-checkout: components/pipeline-service + + - name: Checkout pull request base + uses: actions/checkout@v5 + with: + ref: ${{ github.event.pull_request.base.sha }} + path: base + sparse-checkout: components/pipeline-service + + - name: Compare pipelines indexes + id: compare_indexes + run: head/components/pipeline-service/ci/check_bundle_is_upgrade.sh + + - name: Comment warnings + if: ${{ steps.compare_indexes.outputs.comment != '' }} + uses: actions/github-script@v8 + env: + MESSAGE: ${{steps.compare_indexes.outputs.comment}} + with: + script: | + const message = process.env.MESSAGE.replace(/\\n/g, "\n"); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Warnings found\n${message}`, + }); diff --git a/components/pipeline-service/ci/check_bundle_is_upgrade.sh b/components/pipeline-service/ci/check_bundle_is_upgrade.sh new file mode 100755 index 00000000000..a15a89b8ea3 --- /dev/null +++ b/components/pipeline-service/ci/check_bundle_is_upgrade.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# Compare the changed pipelines bundle index images in two copies of the +# the repository: one at ./head and one at ./base. +# Emits any warnings to stdout and $GITHUB_OUTPUT. + +# Easiest way to identify all nested deploy.yaml files +shopt -s globstar + +function extract_index_catalog() { + IMAGE_REF="${1}" + CONTAINER=$(podman create "${IMAGE_REF}") + tmpdir=$(mktemp -d) + podman cp "${CONTAINER}:/configs/openshift-pipelines-operator-rh/catalog.json" "${tmpdir}" + podman container rm "${CONTAINER}" >/dev/null + cat "${tmpdir}/catalog.json" +} + +export OUTPUT="" + +for f in head/components/pipeline-service/**/deploy.yaml; do + CONFIG=$(echo "${f}" | cut -d '/' -f2-) + NEW_CONFIG="${f}" + OLD_CONFIG="base/${CONFIG}" + if [[ ! -e "${OLD_CONFIG}" ]]; then + echo "No corresponding manifest found for ${CONFIG} in base revision. Either the cluster is new or this is a CI bug. Skipping..." + continue + fi + + OLD_INDEX_IMAGE=$(yq 'select(.kind == "CatalogSource") | .spec.image' "${OLD_CONFIG}") + NEW_INDEX_IMAGE=$(yq 'select(.kind == "CatalogSource") | .spec.image' "${NEW_CONFIG}") + + if [[ "${OLD_INDEX_IMAGE}" == "${NEW_INDEX_IMAGE}" ]]; then + echo "No change in index image for ${CONFIG}" + continue + fi + + + OLD_CATALOG=$(extract_index_catalog "${OLD_INDEX_IMAGE}") + NEW_CATALOG=$(extract_index_catalog "${NEW_INDEX_IMAGE}") + + OLD_BUILD_VERSION=$(echo "${OLD_CATALOG}" | jq -r 'select(.name | startswith("openshift-pipelines-operator-rh.v5.0.5")) | .properties.[] | select(.type == "olm.package") | .value.version') + NEW_BUILD_VERSION=$(echo "${NEW_CATALOG}" | jq -r 'select(.name | startswith("openshift-pipelines-operator-rh.v5.0.5")) | .properties.[] | select(.type == "olm.package") | .value.version') + + OLD_BUILD_ID=$(echo "${OLD_BUILD_VERSION}" | cut -d '-' -f2) + NEW_BUILD_ID=$(echo "${NEW_BUILD_VERSION}" | cut -d '-' -f2) + + echo "Comparing old build ${OLD_BUILD_VERSION} (${OLD_BUILD_ID}) to new build ${NEW_BUILD_VERSION} (${NEW_BUILD_ID})" + + if (( "${OLD_BUILD_ID}" >= "${NEW_BUILD_ID}" )); then + OUTPUT="${OUTPUT}- :warning: New index image in ${CONFIG} uses a package version (${NEW_BUILD_VERSION}) which is not higher than currently applied package version (${OLD_BUILD_VERSION}). When applied, operator might not upgrade to new index\n" + LINE_NUMBER=$(grep --line-number "image: ${NEW_INDEX_IMAGE}" "${NEW_CONFIG}" | cut -d ':' -f1) + echo "::warning file=${CONFIG},line=${LINE_NUMBER}::Index references bundle version ${NEW_BUILD_VERSION} which is not higher than previous bundle version ${OLD_BUILD_VERSION}" + fi + +done + +echo "comment=${OUTPUT}" | tee -a "${GITHUB_OUTPUT:-out}" + diff --git a/components/pipeline-service/staging/base/main-pipeline-service-configuration.yaml b/components/pipeline-service/staging/base/main-pipeline-service-configuration.yaml index 8f39f097d1d..6a9b37c0c17 100644 --- a/components/pipeline-service/staging/base/main-pipeline-service-configuration.yaml +++ b/components/pipeline-service/staging/base/main-pipeline-service-configuration.yaml @@ -2070,7 +2070,7 @@ metadata: namespace: openshift-marketplace spec: displayName: custom-operators - image: quay.io/openshift-pipeline/pipelines-index-4.17@sha256:6c984e7de8a71c0291fe28c31234d144a6cc5658fdee43965b1e3aedc9600d80 + image: quay.io/openshift-pipeline/pipelines-index-4.15@sha256:4bd52b1e88fd0fc15a90f61b4bbf6a09c5976986ae647db1c25851715e47e610 sourceType: grpc updateStrategy: registryPoll: diff --git a/components/pipeline-service/staging/stone-stage-p01/deploy.yaml b/components/pipeline-service/staging/stone-stage-p01/deploy.yaml index 78a05e3f9a6..2d3eb8f9450 100644 --- a/components/pipeline-service/staging/stone-stage-p01/deploy.yaml +++ b/components/pipeline-service/staging/stone-stage-p01/deploy.yaml @@ -2656,7 +2656,7 @@ metadata: namespace: openshift-marketplace spec: displayName: custom-operators - image: quay.io/openshift-pipeline/pipelines-index-4.17@sha256:6c984e7de8a71c0291fe28c31234d144a6cc5658fdee43965b1e3aedc9600d80 + image: quay.io/openshift-pipeline/pipelines-index-4.15@sha256:4bd52b1e88fd0fc15a90f61b4bbf6a09c5976986ae647db1c25851715e47e610 sourceType: grpc updateStrategy: registryPoll: diff --git a/components/pipeline-service/staging/stone-stg-rh01/deploy.yaml b/components/pipeline-service/staging/stone-stg-rh01/deploy.yaml index 9284fda7f06..eae7383d2dd 100644 --- a/components/pipeline-service/staging/stone-stg-rh01/deploy.yaml +++ b/components/pipeline-service/staging/stone-stg-rh01/deploy.yaml @@ -2668,7 +2668,7 @@ metadata: namespace: openshift-marketplace spec: displayName: custom-operators - image: quay.io/openshift-pipeline/pipelines-index-4.17@sha256:6c984e7de8a71c0291fe28c31234d144a6cc5658fdee43965b1e3aedc9600d80 + image: quay.io/openshift-pipeline/pipelines-index-4.15@sha256:4bd52b1e88fd0fc15a90f61b4bbf6a09c5976986ae647db1c25851715e47e610 sourceType: grpc updateStrategy: registryPoll: