-
Notifications
You must be signed in to change notification settings - Fork 71
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
Conversation
[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 |
scripts/verify_commits
Outdated
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
/test verify |
…shift#138) Upstream-repository: api Upstream-commit: a3fa2bd8d7c7f540824cda1b06f6677f198cfbb8
4818336
to
0e040da
Compare
scripts/verify_commits.sh
Outdated
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 | ||
} |
There was a problem hiding this comment.
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.
scripts/verify_commits.sh
Outdated
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
69bbeb0
to
9a6a711
Compare
scripts/verify_commits.sh
Outdated
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
/lgtm |
/lgtm |
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 |
@kevinrizza: Overrode contexts on behalf of kevinrizza: ci/prow/e2e-aws-olm, ci/prow/e2e-gcp, ci/prow/e2e-upgrade In response to this:
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. |
Add the
verify-commits
Make target to verify that commits added between the currenthead and master:
manifests, and/or respective staging directory
Also, include
verify-commits
under theverify
target. This ensures the verification is executed by Prow w/o requiring any updates to the Prow config.