Skip to content

Commit

Permalink
[ISV-3980] detect-changed-operators handles incorrectly rebased PRs (#…
Browse files Browse the repository at this point in the history
…501)

* [ISV-3980] detect-changed-operators handles incorrectly rebased PRs

Signed-off-by: Maurizio Porrato <[email protected]>

* Remove some pylint exceptions

* Replace nested ifs loop with set comprehensions

Signed-off-by: Maurizio Porrato <[email protected]>

---------

Signed-off-by: Maurizio Porrato <[email protected]>
  • Loading branch information
mporrato authored Sep 15, 2023
1 parent 258ff3a commit b2c3158
Show file tree
Hide file tree
Showing 4 changed files with 403 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
- name: env
value: $(params.env)

# Clone the repository contents from the PR branch
- name: clone-repository
taskRef:
name: git-clone
Expand All @@ -102,8 +103,6 @@ spec:
value: "$(params.git_fork_url)"
- name: revision
value: "$(params.git_pr_branch)"
- name: depth
value: 25
- name: gitInitImage
value: registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:bc551c776fb3d0fcc6cfd6d8dc9f0030de012cb9516fac42b1da75e6771001d9
workspaces:
Expand All @@ -113,23 +112,53 @@ spec:
- name: ssh-directory
workspace: ssh-dir

# Clone the repository contents from the base branch
- name: clone-repository-base
taskRef:
name: git-clone
kind: Task
runAfter:
- clone-repository
params:
- name: url
value: "$(params.git_fork_url)"
- name: revision
value: "$(params.git_commit_base)"
- name: gitInitImage
value: registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:bc551c776fb3d0fcc6cfd6d8dc9f0030de012cb9516fac42b1da75e6771001d9
workspaces:
- name: output
workspace: repository
subPath: base
- name: ssh-directory
workspace: ssh-dir

- name: detect-changes
taskRef:
name: parse-repo-changes
kind: Task
runAfter:
- clone-repository
- clone-repository-base
params:
- name: pipeline_image
value: "$(params.pipeline_image)"
- name: head_commit
value: "$(params.git_commit)"
- name: base_commit
value: "$(params.git_commit_base)"
- name: request_url
value: "$(params.git_pr_url)"
- name: github_token_secret_name
value: "$(params.github_token_secret_name)"
- name: github_token_secret_key
value: "$(params.github_token_secret_key)"
workspaces:
- name: repo
- name: pr
workspace: repository
subPath: src
- name: base
workspace: repository
subPath: base

# parse ci.yaml file and look for the reviewer and or author of the PR
- name: get-ci-reviewer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ spec:
description: Commit ID of the head of the PR
- name: base_commit
description: Commit ID of the base of the PR
- name: request_url
description: URL of the GitHub pull request we want to check
type: string
- name: github_token_secret_name
description: Name of the Kubernetes Secret that contains the GitHub token
default: github
- name: github_token_secret_key
description: Key within the Kubernetes Secret that contains the GitHub token
default: token
results:
- name: added_operator
description: >
Expand All @@ -20,23 +29,28 @@ spec:
New bundle version that have been added.
Bundle version is in the format "bundle_version".
workspaces:
- name: repo
description: Local repo clone
- name: pr
description: Clone of the repo at the PR head
- name: base
description: Clone of the repo at head of the base branch
steps:
- name: parse-repo-changes
image: "$(params.pipeline_image)"
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: $(params.github_token_secret_name)
key: $(params.github_token_secret_key)
script: |
#! /usr/bin/env bash
set -xe
cd "$(workspaces.repo.path)"
git config --global --add safe.directory "$(workspaces.repo.path)"
detect-changed-operators \
--repo-path="$(workspaces.repo.path)" \
--head-commit="$(params.head_commit)" \
--base-commit="$(params.base_commit)" \
--output-file /tmp/changes.json \
--repo-path="$(workspaces.pr.path)" \
--base-repo-path="$(workspaces.base.path)" \
--pr-url="$(params.request_url)" \
--output-file /tmp/changes.json \
--verbose
function fail() {
Expand Down
Loading

0 comments on commit b2c3158

Please sign in to comment.