Skip to content
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

Add condtional checks on jobs to skip on document changes. #5438

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

sarab97
Copy link
Member

@sarab97 sarab97 commented Nov 11, 2023

Fixes #5305

Tested on PR

This approach is used to ensure that workflow is run but jobs are skipped as this is how required github actions work. Link to github documentation

@k8s-ci-robot
Copy link
Contributor

This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 11, 2023
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 11, 2023
@sarab97 sarab97 marked this pull request as draft November 11, 2023 22:56
@sarab97 sarab97 marked this pull request as ready for review November 24, 2023 09:12
@sarab97 sarab97 changed the title [WIP] Add condtional checks on jobs to skip on document changes. Add condtional checks on jobs to skip on document changes. Nov 24, 2023
@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 Nov 24, 2023
with:
filters: |
doc:
- 'site/**'
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @sarab97 for the PR!

I suppose, we have to ignore:

  • somePath/*_test.go files
  • somePath/*.md files
  • and somePath/.gitignore files

I'm not sure what "Diff the API" means referred on the issue page, will ask further clarification on this and get back to you

Copy link
Contributor

Choose a reason for hiding this comment

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

I have confirmed that we need to add the condition for this job as well

//  .github/workflows/apidiff.yml

jobs:
  go-apidiff:
    name: Verify API differences
    runs-on: ubuntu-latest
...

Copy link
Member Author

Choose a reason for hiding this comment

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

I have confirmed that we need to add the condition for this job as well

//  .github/workflows/apidiff.yml

jobs:
  go-apidiff:
    name: Verify API differences
    runs-on: ubuntu-latest
...

Yes, I was looking through that and intentionally skipped that. As its single job in a different workflow so adding this condition would mean adding the same conditional job there too. And that will always run to check condition and then make decision to skip that single api diff job or not. I took judgement call to skip doing this there as incase of code changes we will be spending additional time and resources to the same workflow and incase of document changes a single job will run anyways crawling though the code. Im open to your suggestions and we surely can integrate it there as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @sarab97 for the PR!

I suppose, we have to ignore:

* somePath/*_test.go files

* somePath/*.md files

* and somePath/.gitignore files

I'm not sure what "Diff the API" means referred on the issue page, will ask further clarification on this and get back to you

Im not sure adding *_test.go files falls under doc changes scope. However *md file does make sense. I was thinking maybe we first stablize this then we can easily add any more conditions as per need.
"diif the api" refers to that apidiff workflow

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was looking through that and intentionally skipped that. As its single job in a different workflow so adding this condition would mean adding the same conditional job there too. And that will always run to check condition and then make decision to skip that single api diff job or not. I took judgement call to skip doing this there as incase of code changes we will be spending additional time and resources to the same workflow and incase of document changes a single job will run anyways crawling though the code. Im open to your suggestions and we surely can integrate it there as well.

Let's add the condition there in case apidiff workflow expands in the future. Or maybe we can make condition check job generic and can be referenced from these workflows, maybe we can use these strategies:

Im not sure adding *_test.go files falls under doc changes scope. However *md file does make sense. I was thinking maybe we first stablize this then we can easily add any more conditions as per need.
"diif the api" refers to that apidiff workflow

Ah you are right, I misunderstood the requirements, you don't need to ignore *_test after all. Speaking of detail of the check, does a code comment change counts as code change or docs change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's add the condition there in case apidiff workflow expands in the future. Or maybe we can make condition check job generic and can be referenced from these workflows, maybe we can use these strategies:

The apidiff is a single action workflow having a job. A workflow has single purpose. So checking for api diff that wont be expanding.

I have looked though link you provided. Those do seem interesting approach but have their own drawbacks like rerunning it again for each call which will be inefficient in our case.
I would prefer keeping this simple rather than overcomplicating.

Ah you are right, I misunderstood the requirements, you don't need to ignore *_test after all. Speaking of detail of the check, does a code comment change counts as code change or docs change?

We dont need to go in so deep wondering about comment change. We wont be having any way to check that. And even if possible it would be too much of effort for too little of a reward.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, let's just make sure the condition cover *.md and .gitignore for now

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah @antoooks I left it out to be done in future. But sure I will add both conditions.

@antoooks
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@antoooks: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

@natasha41575 natasha41575 self-assigned this Dec 11, 2023
@koba1t
Copy link
Member

koba1t commented Dec 11, 2023

/assign

lint:
name: Lint
needs: conditional-changes
if: needs.conditional-changes.outputs.doc == 'false'
Copy link
Member

Choose a reason for hiding this comment

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

@sarab97
Thanks for your contribution!

So, I think it looks like this condition checks only whether site/ was changed or not.
I worry that maybe this condition won't work with any PR changing code and documents.
Please tell me if I misunderstood your work!

Copy link
Member Author

Choose a reason for hiding this comment

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

As per my understanding of README from https://github.com/dorny/paths-filter. The condition will check for change and as per filter condition ensure the change is only in site directory. So if both document and code is changed it should evaluate to false.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/dorny/paths-filter?tab=readme-ov-file#outputs

'false' - if none of changed files matches any of filter rules

Oh. Thanks I understand.
I misunderstand false as meaning the reverse of true.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 13, 2024
@koba1t
Copy link
Member

koba1t commented Feb 13, 2024

Thanks @sarab97. This PR looks good.

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: koba1t, sarab97

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 merged commit 537c4fa into kubernetes-sigs:master Feb 13, 2024
8 checks passed
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. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

Disable code tests for documentation changes
5 participants