Skip to content

Commit

Permalink
check-task-pipeline-bundle-repos.sh check for PRs
Browse files Browse the repository at this point in the history
Passes the pull request commit id to the
`check-task-pipeline-repo-existence` step to make the validation
consider pull request image references; otherwise the check checks for
images that are have resulted from changes pushed to the default branch.
  • Loading branch information
zregvart committed Jan 27, 2023
1 parent 237b876 commit 94b327b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
8 changes: 7 additions & 1 deletion .tekton/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,20 @@ spec:
oc delete --ignore-not-found deployment --all -n $(params.e2e_test_namespace)
oc delete --ignore-not-found eventlisteners --all -n $(params.e2e_test_namespace)
- name: check-task-pipeline-repo-existence
params:
- name: pr_commit
value: "$(tasks.fetch-repository.results.commit)"
taskSpec:
params:
- name: pr_commit
type: string
steps:
- name: fail-when-repo-is-missed
image: registry.redhat.io/openshift4/ose-cli:v4.11
workingDir: $(workspaces.source.path)
script: |
#!/usr/bin/env bash
.tekton/scripts/check-task-pipeline-bundle-repos.sh
PULL_REQUEST_COMMIT="$(params.pr_commit)" .tekton/scripts/check-task-pipeline-bundle-repos.sh
workspaces:
- name: source
workspaces:
Expand Down
16 changes: 12 additions & 4 deletions .tekton/scripts/check-task-pipeline-bundle-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ cd "$SCRIPTDIR/../.."
QUAY_ORG=redhat-appstudio-tekton-catalog

locate_bundle_repo() {
local -r repo_name=$1
curl -I -s -L -w "%{http_code}\n" -o /dev/null "https://quay.io/api/v1/repository/${QUAY_ORG}/${repo_name}"
local -r type="$1"
local -r object="$2"

local repo_and_tag
if [ -z ${PULL_REQUEST_COMMIT+x} ]; then
repo_and_tag="${type}-${object}"
else
repo_and_tag="pull-request-builds:${object}-${PULL_REQUEST_COMMIT}"
fi
curl -I -s -L -w "%{http_code}\n" -o /dev/null "https://quay.io/api/v1/repository/${QUAY_ORG}/${repo_and_tag}"
}

has_missing_repo=
Expand All @@ -17,7 +25,7 @@ echo "Checking existence of task and pipeline bundle repositories ..."
# tasks
for task_file in task/*/*/*.yaml; do
task_name=$(oc apply --dry-run=client -f "$task_file" -o jsonpath='{.metadata.name}')
found=$(locate_bundle_repo "task-$task_name")
found=$(locate_bundle_repo task "$task_name")
if [ "$found" != "200" ]; then
echo "Missing task bundle repo: task-$task_name"
has_missing_repo=yes
Expand All @@ -26,7 +34,7 @@ done

# pipelines
for pl_name in $(oc kustomize pipelines/ | oc apply --dry-run=client -f - -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'); do
found=$(locate_bundle_repo "pipeline-$pl_name")
found=$(locate_bundle_repo pipeline "$pl_name")
if [ "$found" != "200" ]; then
echo "Missing pipeline bundle repo: pipeline-$pl_name"
has_missing_repo=yes
Expand Down

0 comments on commit 94b327b

Please sign in to comment.