ci: implement citest skip for push events [citest_skip]#201
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdate the ansible-lint GitHub Actions workflow condition so that the job is skipped not only for pull requests with [citest_skip] in the title but also for push events whose head commit message contains [citest_skip]. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The
ifcondition appears to use incorrect context fields for GitHub Actions:github.event_typeshould begithub.event_name, and for push events the commit message is available asgithub.event.head_commit.messagerather thangithub.event.push.head_commit.commit.message. - Consider simplifying the multiline
ifexpression (e.g., by extracting the skip logic into a reusable expression or using intermediate environment variables) to make the conditions easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `if` condition appears to use incorrect context fields for GitHub Actions: `github.event_type` should be `github.event_name`, and for push events the commit message is available as `github.event.head_commit.message` rather than `github.event.push.head_commit.commit.message`.
- Consider simplifying the multiline `if` expression (e.g., by extracting the skip logic into a reusable expression or using intermediate environment variables) to make the conditions easier to read and maintain.
## Individual Comments
### Comment 1
<location> `.github/workflows/ansible-lint.yml:23-24` </location>
<code_context>
+ # or if this is a push and the head commit message contains [citest_skip]
ansible_lint:
- if: "!contains(github.event.pull_request.title, '[citest_skip]')"
+ if: |
+ !((github.event_type == "pull_request" && contains(github.event.pull_request.title, "[citest_skip]")) ||
+ (github.event_type == "push" && contains(github.event.push.head_commit.commit.message, "[citest_skip]")))
runs-on: ubuntu-latest
</code_context>
<issue_to_address>
**issue (bug_risk):** Use `github.event_name` instead of `github.event_type` in workflow conditions.
`github.event_type` is not a valid GitHub Actions context field, so these conditions will never match and the job will always run. Please switch both checks to `github.event_name == 'pull_request'` and `github.event_name == 'push'` so the skip logic works as intended.
</issue_to_address>
### Comment 2
<location> `.github/workflows/ansible-lint.yml:24-25` </location>
<code_context>
ansible_lint:
- if: "!contains(github.event.pull_request.title, '[citest_skip]')"
+ if: |
+ !((github.event_type == "pull_request" && contains(github.event.pull_request.title, "[citest_skip]")) ||
+ (github.event_type == "push" && contains(github.event.push.head_commit.commit.message, "[citest_skip]")))
runs-on: ubuntu-latest
steps:
</code_context>
<issue_to_address>
**issue (bug_risk):** Correct the path to the commit message in the push event payload.
In `push` events the commit message is at `github.event.head_commit.message`; `github.event.push.head_commit.commit.message` doesn’t exist in the documented payload, so this condition will not work as intended. Please update the push branch to `contains(github.event.head_commit.message, "[citest_skip]")` to match the expected behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
809a7ee to
9df6faa
Compare
9df6faa to
71bf534
Compare
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
71bf534 to
5d2125f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhancement:
Reason:
Result:
Issue Tracker Tickets (Jira or BZ if any):
Summary by Sourcery
CI: