Skip to content

chore(ci): add verify-commits make target #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2021

Conversation

njhale
Copy link
Contributor

@njhale njhale commented Jul 28, 2021

Add the verify-commits Make target to verify that commits added between the current
head and master:

  • reference only one upstream, if any
  • if referencing an upstream, only make changes to the vendor,
    manifests, and/or respective staging directory

Also, include verify-commits under the verify target. This ensures the verification is executed by Prow w/o requiring any updates to the Prow config.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 28, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 28, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: njhale

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 28, 2021
Comment on lines 87 to 85
function fetch_remotes() {
local -a remotes
remotes=(
'api'
'operator-registry'
'operator-lifecycle-manager'
)
for r in "${remotes[@]}"; do
local url
url="[email protected]/operator-framework/${r}.git"
if git remote show "${r}"; then
git remote set-url "${r}" "${url}"
else
echo "remote ${r} doesn't exist"
git remote add "${r}" "${url}"
fi

git fetch "${r}" master
done
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a preexisting function for this hidden away, but it depends on the tracking file, which I don't think we need going forward. should I drop that and clean up the unused scripts in this PR too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be down to clean up any unused scripts here - I have a PR open that attempts to cleanup various things in the repository: #121. Might be worth cherrypicking the 18e10cf commit in that PR which removes the unused bash scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that commit could make a nice PR of its own. I typically tend towards smaller, more tightly scoped PRs. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's fine with me - we can keep those changes outside of this PR.

@njhale
Copy link
Contributor Author

njhale commented Jul 28, 2021

/test verify

kevinrizza pushed a commit to kevinrizza/operator-framework-olm that referenced this pull request Jul 30, 2021
…shift#138)

Upstream-repository: api
Upstream-commit: a3fa2bd8d7c7f540824cda1b06f6677f198cfbb8
@njhale njhale force-pushed the verify-commits branch 13 times, most recently from 4818336 to 0e040da Compare August 5, 2021 15:36
@njhale njhale changed the title WIP chore: add verify-commits make target chore: add verify-commits make target Aug 5, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 5, 2021
@njhale njhale changed the title chore: add verify-commits make target chore(ci): add verify-commits make target Aug 5, 2021
Comment on lines 71 to 105
function fetch_remotes() {
local -a remotes
remotes=(
'api'
'operator-registry'
'operator-lifecycle-manager'
)
for r in "${remotes[@]}"; do
local url
url="https://github.com/operator-framework/${r}.git"

git remote add "${r}" "${url}" || git remote set-url "${r}" "${url}"
git fetch "${r}" master
done
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably value in extracting this to a common/helper library such that people can source this in the future, but that can be done later down the line.

Comment on lines 102 to 135
mapfile -t sr < <(upstream_ref "${commit}" || exit 1)
if (( ${#sr[@]} < 2 )); then # the ref contains a tuple if the values were properly parsed from the commit message
# couldn't find upstream cherry-pick reference in the commit message
# assume it's downstream-only commit
info "${commit:0:7} does not reference upstream commit, verifying as downstream-only"
else
# found upstream cherry-pick reference in commit message
# verify as an upstream sync
info "${commit:0:7} references upstream commit (${sr[*]}), verifying as upstream sync"
verify_upstream_sync "${sr[0]}" "${commit}" || exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm it's possible I'm misreading this but this seems like it's avoiding the edge case where we're pulling in an upstream commit, but someone forgot to populate that upstream commit metadata into the pulled down commit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah I glossed over the commented text - it seems like we'd want to enforce this behavior as a stop gap until automation has been introduced. Would it be more reasonable to assume that anything that touches the staging tree needs to be treated as an upstream commit? I still need to dive into that upstream_ref function so I may be missing some context here.

@njhale njhale force-pushed the verify-commits branch 2 times, most recently from 69bbeb0 to 9a6a711 Compare August 18, 2021 00:29
if (( ${#upstream_repos[@]} != 1 )); then
err "downstream staging commit ${downstream_commit} references an invalid number of repos:"
err "${upstream_repos[@]}"
err "staging commits must reference reference a single upstream repo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: staging commits must reference a single upstream repo

return 1
fi

if git branch -r --contains "${upstream_commits[0]}" | grep -vq "${upstream_repos[0]}/.*"; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this cause problems if we need to revert commits upstream? I suppose in that case we need to explicitly revert the commit in order, but it could be a problem if we're on a release branch where that is not trivially possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this cause problems if we need to revert commits upstream?

reverting a commit is additive -- it creates a new commit that undoes the changes of the target -- so in theory, the original commit should still exist (if I didn't misunderstand the concern).

see https://git-scm.com/docs/git-revert#_description

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we just need to enforce that we're not tossing history and it's not a problem. I think this is fine I just wanted to call it out as a potential problem if upstream ever got borked.

local outside_staging
outside_staging="$(git show --name-only "${downstream_commit}" -- ":!${staging_dir}" ':!vendor :!manifests')"
if [[ -n "${outside_staging}" ]]; then
err "downstream staging commit ${downstream_commit} changes files outside of ${staging_dir}, vendor, and manifests directories"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick thought: would we necessary group an upstream-specific commit and the requisite manifest changes in the same commit? Grouping the staging tree changes + any vendor changes makes sense to me, especially in the reversion case, but still trying to wrap my head around whether we'd like to enforce that manifest changes need to also live in that same commit. Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but still trying to wrap my head around whether we'd like to enforce that manifest changes need to also live in that same commit. Any ideas?

The current code ensures that no staging commit touches a staging directory and a directory other than ./vendor or ./manifests. It doesn't enforce that changes to manifests occur in a staging commit, if that's the concern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my mistake likely glossed over too quickly - this implementation is fine with me.

Add a Make target that verifies commits added between the current
head and master:
- reference only one upstream, if any
- if referencing an upstream, only make changes to the vendor,
  manifests, and/or respective staging directory
- if not referencing an upstream, don't make changes to the staging
  directory
@timflannagan
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 18, 2021
@kevinrizza
Copy link
Member

/lgtm

@kevinrizza
Copy link
Member

This is a script change that doesn't affect any of the running e2e tests in any way. Overriding ci

/override ci/prow/e2e-aws-olm
/override ci/prow/e2e-gcp
/override ci/prow/e2e-upgrade

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 18, 2021

@kevinrizza: Overrode contexts on behalf of kevinrizza: ci/prow/e2e-aws-olm, ci/prow/e2e-gcp, ci/prow/e2e-upgrade

In response to this:

This is a script change that doesn't affect any of the running e2e tests in any way. Overriding ci

/override ci/prow/e2e-aws-olm
/override ci/prow/e2e-gcp
/override ci/prow/e2e-upgrade

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-merge-robot openshift-merge-robot merged commit 5bd4cad into openshift:master Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants