Skip to content
48 changes: 48 additions & 0 deletions .github/workflows/pipelines-ci.yaml
Original file line number Diff line number Diff line change
@@ -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}`,
});
59 changes: 59 additions & 0 deletions components/pipeline-service/ci/check_bundle_is_upgrade.sh
Original file line number Diff line number Diff line change
@@ -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}"

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@
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

Check warning on line 2659 in components/pipeline-service/staging/stone-stage-p01/deploy.yaml

View workflow job for this annotation

GitHub Actions / validate-pipelines-index

Index references bundle version 5.0.5-596 which is not higher than previous bundle version 5.0.5-697
sourceType: grpc
updateStrategy:
registryPoll:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2668,7 +2668,7 @@
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

Check warning on line 2671 in components/pipeline-service/staging/stone-stg-rh01/deploy.yaml

View workflow job for this annotation

GitHub Actions / validate-pipelines-index

Index references bundle version 5.0.5-596 which is not higher than previous bundle version 5.0.5-697
sourceType: grpc
updateStrategy:
registryPoll:
Expand Down