-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support tracking state for multiple repos #97
Conversation
b47ab24
to
24e0c4f
Compare
0dce9e2
to
9112794
Compare
d983684
to
64c4582
Compare
64c4582
to
bdaa5e8
Compare
|
6741fb6
to
d306035
Compare
d3fe839
to
3e47dde
Compare
ec155eb
to
1792647
Compare
lib/state.ml
Outdated
let empty : State_t.state = { pipeline_statuses = StringMap.empty; bot_user_id = None } | ||
type t = { | ||
state : State_t.state; | ||
lock : Lwt_mutex.t; |
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.
lock because pipeline_statuses
is a mutable field containing a string map (I think this was necessary even before multi-repo)
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.
this must be a comment in code
@@ -2,19 +2,45 @@ open Base | |||
open Common | |||
open Devkit | |||
|
|||
let empty : State_t.state = { pipeline_statuses = StringMap.empty; bot_user_id = None } | |||
type t = { |
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.
later should add mli and make opaque
@@ -85,16 +95,17 @@ let refresh_state ctx = | |||
match get_local_file path with | |||
| Error e -> fmt_error "error while getting local file: %s\nfailed to get state from file %s" e path | |||
| Ok file -> | |||
let state = State_j.state_of_string file in | |||
let state = { ctx.state with state = State_j.state_of_string file } in |
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.
later should move some of this fn into state.ml
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.
maybe leave that as a comment in code
documentation/secret_docs.md
Outdated
## `allowed_repos` | ||
|
||
Use this option to restrict incoming notifications from GitHub to approved repository URLs. | ||
|
||
Repository URLs should be fully qualified (include the protocol), with no trailing backslash. | ||
|
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.
I don't understand why this second value is required. Aren't all the whitelisted repos already listed under repos
?
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.
This was to 1) stay compatible with existing configs, 2) let repos be whitelisted without defining repo-specifc secrets, and 3) let whitelisting itself be optional. I could alternatively use repos
as the whitelist (and expect null for whitelisted repos that use default secret), or rename to something less confusing like repo_secrets
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.
I think we should break compatibility in such cases, or support two formats - legacy and new one (have one object per repository with secrets and any other configurations necessary per-repo)
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.
With repo-specific secrets, we'll need the repo name in order to obtain the webhook token used for signature validation. So parsing the request body for a GH payload needs to happen before, not after, the signature check.
Define custom getters for retrieving GH secret values. As the getter for each token type defaults to looking for a global value if a repo-specific vaue isn't found, existing deployments don't need to change.
For each test case, initializes a repo state from file if one exists.
9697bed
to
233543c
Compare
Description of the task
Separates config + pipeline status tracking by repository, so that the bot can send notifications for multiple repositories, each according to its own config file.
Changes:
documentation/config_docs.md
for details).Doesn't break existing deployments as this per-repo config is optional.This is now mandatory Support tracking state for multiple repos #97 (comment)state.json
files will be incompatible with new formatHow to test
Existing tests should pass (
make test
). Also tested with staging workspace.References