Skip to content

Adding a job that enforce a single commit for each PR. #20

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 31, 2022

Conversation

ybettan
Copy link
Contributor

@ybettan ybettan commented Aug 30, 2022

Adding a job that enforce a single commit for each PR.

This job will make sure that all commits in a PR were squashed to a single
commit.

Signed-off-by: Yoni Bettan [email protected]

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 30, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @ybettan. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 30, 2022
@ybettan ybettan changed the title Adding a job that checks the PR and commit formats. [WIP]: Adding a job that checks the PR and commit formats. Aug 30, 2022
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 30, 2022
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 30, 2022
@ybettan
Copy link
Contributor Author

ybettan commented Aug 30, 2022

/cc @qbarrand
/cc @yevgeny-shnaidman
/cc @enriquebelarte

@k8s-ci-robot
Copy link
Contributor

@ybettan: GitHub didn't allow me to request PR reviews from the following users: enriquebelarte.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @qbarrand
/cc @yevgeny-shnaidman
/cc @enriquebelarte

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.

@ybettan ybettan force-pushed the check-commit branch 2 times, most recently from cc3dab4 to c50cec1 Compare August 30, 2022 19:28
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 30, 2022
@yevgeny-shnaidman
Copy link
Contributor

@ybettan why do we need the PR description and commit message to be identical? why is it a hard requirement?

@ybettan
Copy link
Contributor Author

ybettan commented Aug 31, 2022

@yevgeny-shnaidman I think that the commit message should be very descriptive and should include all the info required for understanding the code change.

By enforcing identical commit message and PR description, the reviewer of the PR can just look at the PR description without the need of also checking the commit message inside the PR in order to make sure the commit message wasn't neglected.

In addition, you can add additional info such as reviewers or any other text that is not relevant for describing the change by adding --- at the end of the PR description and all the text after that will be ignored by the API and doesn't have to match the commit message.

@qbarrand
Copy link
Contributor

/hold
Hold while we compare those requirements with what the Kubernetes contributor cheat sheet recommends.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 31, 2022
@ybettan
Copy link
Contributor Author

ybettan commented Aug 31, 2022

As agreed, this PR is going to be split into 2 PRs:

  • One PR to add a job to enforce a single commit per PR
  • One PR to enforce the sync between the PR description and the commit message

Both PR will start as optional jobs and the second one might be removed after some time if it causes more issues than benefits.

@ybettan ybettan changed the title [WIP]: Adding a job that checks the PR and commit formats. Adding a job that checks the PR and commit formats. Aug 31, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 31, 2022
@qbarrand
Copy link
Contributor

@ybettan please rebase.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 31, 2022
@qbarrand
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 31, 2022
Comment on lines 7 to 6
number_of_commits=$(curl -H 'Accept: application/vnd.github+json' \
https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/pulls/${PULL_NUMBER} | jq '.commits')
if [[ ${number_of_commits} != 1 ]]; then
Copy link
Contributor

@qbarrand qbarrand Aug 31, 2022

Choose a reason for hiding this comment

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

I think we could use git to do that: git rev-list --count HEAD ^main

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

Fixed.

@ybettan ybettan changed the title Adding a job that checks the PR and commit formats. Adding a job that enforce a single commit for each PR. Aug 31, 2022
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
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 rename this to ci/prow/check-commits-count. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

yevgeny-shnaidman pushed a commit to yevgeny-shnaidman/kernel-module-management-upstream that referenced this pull request Aug 31, 2022
Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.5 to 0.5.7.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](google/go-cmp@v0.5.5...v0.5.7)

---
updated-dependencies:
- dependency-name: github.com/google/go-cmp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@‌github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@‌users.noreply.github.com>
This job will make sure that all commits in a PR were squashed to a single
commit.

Signed-off-by: Yoni Bettan <[email protected]>
@qbarrand
Copy link
Contributor

/unhold
/lgtm
/approved

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 31, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2022
@qbarrand
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qbarrand, ybettan

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2022
@k8s-ci-robot k8s-ci-robot merged commit e0a5b43 into kubernetes-sigs:main Aug 31, 2022
@ybettan ybettan deleted the check-commit branch September 1, 2022 08:02
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants