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

ci: Add condition to skip job when PR author is Bot #3433

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

raffifu
Copy link
Contributor

@raffifu raffifu commented Oct 18, 2023

Fixes #3415

Constraint

Job will skip if match this condition:

  • The author is github-actions[bot]
  • Source branch start with 'chore'

Description

This approach is different from my comment on the issue because i see there's a pattern on the PR created by github-actions. Also, I see several workflow file for automatic update on this repo (sbom, js dependencies, etc). I think this changes has pros and cons described below.

I use github context to retrieve information about the PR author and the source branch ref

Pros

  • More simple compared to my proposed approach
  • Will skip all PR created by github-actions[bot]

Cons

  • Manually update in the folder sbom/ will trigger the tests

Testing

I've test this on my private repo, here's the screenshot
image

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

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

I need documentation tests to run on the update-checkers workflows (e.g. #3411) so this isn't going to work as-is, but maybe it could be tweaked to look for a bit more than just startsWith "chore" so it looks specifically for sbom vs checker updates and does the right thing?

There's also a third type of bot action we use right now for updating the pre-commit config (e.g. #3120 ) and that one definitely needs to run linters but it's ok to skip tests and docs, so this PR shouldn't affect it poorly.

There's also a bot action for updating the year in the SPDX stub we provide, but we don't need to run tests there either so these should be fine.

I think longer-term something that checked what files were changed would be applicable in more cases (e.g. it would be nice to not run tests if you only change .md files or somesuch) , but short-term this seems like a bit of tweaking could make this at least solve the problem for the sbom and checker PRs.

@codecov-commenter
Copy link

Codecov Report

Merging #3433 (d3c69b0) into main (fb39948) will decrease coverage by 5.70%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #3433      +/-   ##
==========================================
- Coverage   80.49%   74.79%   -5.70%     
==========================================
  Files         758      758              
  Lines       11616    11616              
  Branches     1571     1571              
==========================================
- Hits         9350     8688     -662     
- Misses       1842     2584     +742     
+ Partials      424      344      -80     
Flag Coverage Δ
longtests 74.79% <ø> (-5.70%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 15 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@raffifu
Copy link
Contributor Author

raffifu commented Oct 18, 2023

Hii @terriko , I think it would be nice to check the branch name for specific case. I've create a recap all of the bot action, this recap only contains job on the test workflow. I need to confirm is the list below is correct? Also if there's need to skip job on the another workflow (Dependency Review/CodeQL/Linting) I can also add to next commit

Bot Action Branch Name Running Job
Update SBOM chore-sbom-py${{ matrix.python }} -
Update Checkers Table chore-update-table Documentation
Update Pre-Commit chore-precommit-config -
Update SPDX Header chore-spdx-header -
Update JS Dependencies chore-js-dependencies -
Update Database data chore-update_database-copy -

@terriko
Copy link
Contributor

terriko commented Oct 18, 2023

We probably want to run tests (but not documentation) on update-js-dependencies.

I'm pretty sure the chore-update_database-copy one is only available to run manually at the moment. I should probably delete that job entirely, since it's been replaced by the global mirror. If you want a very easy PR for hacktoberfest, feel free to go ahead and do separate one that git rm's the associated yml file, since you reminded me that it exists. :)

Skip the job if:
- Author is github-actions[bot]
- Branch name is listed on jobs
@raffifu
Copy link
Contributor Author

raffifu commented Oct 19, 2023

New commit changes the logic, now test will skipped if:

  1. PR author is github-actions
  2. The branch name is listed on if statement

Anyway, I'll delete chore-update_database-copy after this PR is merged

Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

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

Looks good; let's get this merged and hopefully we'll have much faster SBOM jobs when they trigger next week!

@terriko terriko merged commit 4cb46d8 into intel:main Oct 19, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ci: avoid running unecessary tests on SBOM PRs
3 participants