Skip to content

Apidiff test runs only if the changes are in api/ and exp/api/ #2206

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
Apr 13, 2022

Conversation

meghanajangi
Copy link
Member

@meghanajangi meghanajangi commented Mar 30, 2022

What type of PR is this?
/kind failing-test

What this PR does / why we need it:
This PR will limit the apidiff test to run only if there are changes made in the directory api/ and exp/api/

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2051

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 30, 2022
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 30, 2022
@mboersma
Copy link
Contributor

mboersma commented Mar 30, 2022

Thanks @meghanajangi! I've tested the essential command here git --no-pager diff --name-only FETCH_HEAD | grep "api/" locally and read up on FETCH_HEAD. This seems like it should do the right thing.

But looking more closely, I see that the pull-cluster-api-provider-azure-apidiff job ran as usual. Since this PR itself didn't change anything under api/ or exp/api/, it should have been a no-op.

The Makefile actually isn't used in this case. Instead, ./scripts/ci-apidiff.sh is called directly by the job defined here in kubernetes/test-infra.

If you can make a similar change to the ci-apidiff.sh script instead, it should work in all cases. And maybe it should print out "No files under api/ or exp/api/ changed" or "nothing to do" in that case.

@mboersma
Copy link
Contributor

Another approach that might be preferable in this case is to configure the presubmit prow job with a run_if_changed regular expression. Then it won't even show up in the list of GitHub checks below unless it was needed.

Also see testing prow jobs locally.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 1, 2022
@meghanajangi meghanajangi force-pushed the apidiff-restrict branch 4 times, most recently from a76f0a5 to 6c6ae81 Compare April 1, 2022 10:08
@meghanajangi
Copy link
Member Author

Another approach that might be preferable in this case is to configure the presubmit prow job with a run_if_changed regular expression. Then it won't even show up in the list of GitHub checks below unless it was needed.

Also see testing prow jobs locally.

Thank you for the comments @mboersma . I made the changes to ci-apidiff script as you suggested in the first comment.
I also made a change in the script and Makefile similar to this CAPI PR to deduplicate apidiff logic.

@mboersma
Copy link
Contributor

mboersma commented Apr 1, 2022

/retest

Unrelated provisioning flake.

Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2022
@CecileRobertMichon
Copy link
Contributor

/approve

thank you!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 Apr 4, 2022
cd "${REPO_ROOT}"
APICHANGE=$(git --no-pager diff --name-only FETCH_HEAD)
if echo "${APICHANGE}" | grep "api/"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we grep'd for "/api/" (both forward and trailing slashes) we'd be a bit more defensive (in a good way) going forward. For example, if someone created a subdirectory somewhere with a substring suffix of "capi" this would match, which we wouldn't want.

Thanks for doing this!

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change with the leading slash will work correctly, though:

% git --no-pager diff --name-only FETCH_HEAD | grep "/api/"
% echo dummy >> api/v1beta1/doc.go                         
% git --no-pager diff --name-only FETCH_HEAD | grep "/api/"
% git --no-pager diff --name-only FETCH_HEAD | grep "api/" 
api/v1beta1/doc.go

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point @mboersma. I think grep "^api/\|/api/" is what we want (it will match both the api/ dir and the exp/api/ dir)

@CecileRobertMichon
Copy link
Contributor

/hold
/lgtm cancel

to address @jackfrancis' comment above

@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 Apr 4, 2022
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 4, 2022
@meghanajangi
Copy link
Member Author

@jackfrancis @CecileRobertMichon I have made the requested change. PTAL 🙃

@meghanajangi meghanajangi requested a review from jackfrancis April 7, 2022 09:25
@meghanajangi
Copy link
Member Author

/retest

Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm

This should work, as far as I can tell in local testing.

Thanks for your patience @meghanajangi!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2022
Copy link
Contributor

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

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

lgtm

@jackfrancis
Copy link
Contributor

@mboersma after this merges could you create a draft PR that validates this? (I'd do it myself, but I'm not familiar enough with how to trip up apidiff using present config)

@mboersma
Copy link
Contributor

could you create a draft PR that validates this?

Good call–sure, I'll do that.

@mboersma
Copy link
Contributor

/hold cancel

@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 Apr 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit ad1fb13 into kubernetes-sigs:main Apr 13, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.3 milestone Apr 13, 2022
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. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

Change apidiff test to only fail for actual breaking API changes
5 participants