-
Notifications
You must be signed in to change notification settings - Fork 33
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
GitHub sync #1007
GitHub sync #1007
Conversation
@zacck looking like this is taking shape, we're going to need a lot more tests though - especially in the GithubClient and token stuff... |
a288fa1
to
8401834
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1007 +/- ##
==========================================
- Coverage 85.90% 85.78% -0.12%
==========================================
Files 179 184 +5
Lines 5071 5206 +135
==========================================
+ Hits 4356 4466 +110
- Misses 715 740 +25
☔ View full report in Codecov by Sentry. |
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.
Ran out of time for today - will pick up the rest of this first thing in the AM, for now I've left a few comments around the config/env changes.
config/runtime.exs
Outdated
# If you've booted up with a SENTRY_DSN environment variable, use Sentry! | ||
config :sentry, | ||
filter: Lightning.SentryEventFilter, | ||
environment_name: config_env(), | ||
included_environments: | ||
if(System.get_env("SENTRY_DSN"), do: [config_env()], else: []) | ||
|
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.
Why is this here? Sentry is/was configured at the bottom of the file?
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 is an error, didn't notice it before
config/runtime.exs
Outdated
decoded_cert = | ||
case github_cert do | ||
:noset -> :notset | ||
other -> Base.decode64!(other) | ||
end |
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.
What is :noset
? Why not default to nil? I don't see notset
or noset
used anywhere.
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.
The intention was to leave a message for one to configure github, this can be achieved with nil as well will ammend
.env.example
Outdated
# | ||
# Set this up to handle Github App configuration | ||
GITHUB_APP_ID=12345 | ||
GITHUB_CERT_PATH=/path/to/cert/pem |
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.
Please change it to reflect the correct cert env variable.
If there is no default to set in the example then prepend the env vars with a hash.
I don't think there is any default we can provide for this.
config/test.exs
Outdated
|
||
System.put_env("GITHUB_CERT", Base.encode64(cert)) | ||
System.put_env("GITHUB_APP_ID", "111111") | ||
|
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.
Please don't use System.put_env
, instead of implicitly coupling this to runtime.exs
- rather use config :lightning, :github_app, ...
and then have runtime.exs
override only if ENV vars are present...
config/3
overrides conflicting keys on subsequent calls, so we can call it as many times as we want..
Hey @zacck! Systems/Flow/Design It looks like you can only have one redirect url after a Github app installation, this is currently set to Not without having a separate GitHub app for staging, production and development. Opening a new tab and using a broadcast to update the settings page was an approach that was discussed - I'm not sure why it wasn't the road we took. From looking around the documentation it appears that you can use a The webhook url is set to
Code/Tests
Features/UX
I've made a bunch of small-ish changes, and rebase off main. |
0632f60
to
7e8b2ad
Compare
Hey @NickOpenFn @taylordowns2000 Here is how the click test looks at the moment Screenshare.-.2023-08-17.9_52_08.AM.mp4 |
- Remove tooltip - Test that repo/branch setup
Yaml via api
Run formatter, use provisioning permissions
add :project_id, references(:projects, type: :binary_id) | ||
add :user_id, references(:users, type: :binary_id) |
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 need some kind of :on_delete
behaviour here... @taylordowns2000 your thoughts?
So right now if a project is about to be deleted (or the user) it won't be possible because of this outstanding relationship.
Do we manage this in the delete/purge logic or add a nillify or delete_all cascade option in the schema?
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.
good catch, let me know and I'll add it 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.
@zacck , please add an on_delete cascade for when a project is deleted and an on_delete nillify for when a user is deleted.
in other words: if the user who set the thing up is deleted, the PRC will stay. if the project is deleted, the PRC will also be deleted.
thank you!
diff --git a/test/lightning/version_control/github_client_test.exs b/test/lightning/version_control/github_client_test.exs
index 1b63a5df5..9aaddb969 100644
--- a/test/lightning/version_control/github_client_test.exs
+++ b/test/lightning/version_control/github_client_test.exs
@@ -19,6 +19,9 @@ defmodule Lightning.VersionControl.GithubClientTest do
"https://github.com/gitapi/app/installations/some-id/access_tokens" ->
%Tesla.Env{status: 200, body: %{"token" => "some-token"}}
+ "https://github.com/gitapi/app/installations/invalid/access_tokens" ->
+ %Tesla.Env{status: 401, body: %{"message" => "Bad credentials"}}
+
"https://github.com/gitapi/installation/repositories" ->
%Tesla.Env{
status: 200,
@@ -44,6 +47,11 @@ defmodule Lightning.VersionControl.GithubClientTest do
test "client can fetch repo branches" do
p_repo = insert(:project_repo)
+ assert {:ok, ["master"]} =
+ VersionControl.fetch_repo_branches(p_repo.project_id, p_repo.repo)
+
+ p_repo = insert(:project_repo, github_installation_id: "invalid")
+
assert {:ok, ["master"]} =
VersionControl.fetch_repo_branches(p_repo.project_id, p_repo.repo)
end @zacck check this out, we spoke about this the other day - it's really easy to get a cryptic error when the installation has been removed on the other side (or a failure of any kind):
When I intentionally change We need to handle these known sad paths, at the very least to stop server errors, but probably getting some kind of feedback to the user that something went wrong. |
hey @zacck , i spoke with Stu today and this is looking good. if you address his two points above (the on_delete stuff and this one) the recommendation would be to then merge this to main and iron out any additional changes/bugs/whatever once it's already deployed on demo.openfn.org (we do "edge" deployment, triggered by commits to the the hope is that this will be much easier to make the finishing touches on once it's running on a real server and we can see how it feels to hook up several projects to github. sound good? |
Notes for the reviewer
Draft pr for github sync, still some clean up to do but so far working
Related issue
Fixes #970
Review checklist