-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(ci): utilize file_not_deleted predicate #74
base: main
Are you sure you want to change the base?
Conversation
@@ -104,6 +104,9 @@ func TestMakeApprovalRule(t *testing.T) { | |||
Paths: mustRegexpsFromGlobs(t, []string{"src/**"}), | |||
IgnorePaths: mustRegexpsFromGlobs(t, []string{"docs/**"}), | |||
}, | |||
FileNotDeleted: &predicate.FileNotDeleted{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you perhaps also have a test-case there that exactly covers the "workflow was deleted" scenario? Or did I just miss it? Am new to the policybot codebase 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I fully understand. I think these tests just ensure the generated policy has the structure and values it is supposed to. In terms of the actual functionality of the predicates once part of a policy, there are tests for that in the policy-bot repo itself.
Would you mind clarifying? Thanks Horst.
go.mod
Outdated
// Includes PRs to test: | ||
// - https://github.com/palantir/policy-bot/pull/796 | ||
// - https://github.com/palantir/policy-bot/pull/794 | ||
// - https://github.com/palantir/policy-bot/pull/789 | ||
replace github.com/palantir/policy-bot => github.com/iainlane/policy-bot v1.35.1-0.20240904124510-b6b6121c33c8 | ||
replace github.com/palantir/policy-bot => github.com/iainlane/policy-bot v1.35.1-0.20250320104329-186fca2e2d94 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool news: this should be able to be dropped now if we use palantir/policy-bot@6245c9d or newer 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks!
f21b734
to
68c3c23
Compare
It looks good to me! Can you confirm how you've tested this please? Definitely the kind of check which it's easy to subtly get wrong in a way that a review is hard to catch. One way to do it would be to upgrade to a fixed version of |
@iainlane the only testing I've done so far is generating a policy and making sure the |
Okay I did some testing but... First I tried to test this using the grafana/github-policy-bot-dev, but the generated file got an invalid policy error. I am guessing it's because the policy-bot GitHub App attached to this repo does not contain the new commit to palantir/policy-bot that defined the logic for the I created this repo and installed a policy-bot GitHub App, ran the policy-bot server locally using ngrok to create a webhook URL. As you can see in the repo I have two test workflows. I used grafana/generate-policy-bot-config to generate a policy config and it spit out: policy:
approval:
- or:
- and:
- Workflow .github/workflows/test-a.yml succeeded or skipped
- Workflow .github/workflows/test-b.yml succeeded or skipped
- default to approval ...at the top-level. However, my understanding is that this setup says that each workflow must succeed in order for the PR to be approved. This negates the purpose of the policy:
approval:
- and:
- or:
- Workflow .github/workflows/test-a.yml succeeded or skipped
- or:
- Workflow .github/workflows/test-b.yml succeeded or skipped ...to ensure that each workflow must succeed or be skipped (and a deleted workflow definition file will result in a skipped rule). However, in testing this I found that even when one rule succeeds and another is skipped, the final evaluation is stuck in a pending state indefinitely--not approved as I want. I feel like this is not the correct/optimal setup here. I still don't fully understand how different teams are using this tool, but I assume most start with a base policy config? Is it the intention of this tool/this change that individual teams set up this top-level logic sufficient to enable the functionality of the new Thanks for any clarification you can give! |
aa2740e
to
28755fe
Compare
When a workflow file that a policy rule depends on is deleted in a PR, the rule should be skipped rather than fail. This is achieved by adding the file_not_deleted predicate to each workflow-based policy rule.
28755fe
to
6123029
Compare
When a workflow file that a policy rule depends on is deleted in a PR, the rule should be skipped rather than fail. This is achieved by adding the
file_not_deleted
predicate to each workflow-based policy rule.Closes #178851.