-
Notifications
You must be signed in to change notification settings - Fork 86
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
Integration of Tasks with GitHub issues #805
Conversation
lib/code_corps/github.ex
Outdated
title: attributes[:title], | ||
body: attributes[:body] | ||
} | ||
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.
This seems sort of redundant, but my guess is, the intention was to have an explicit adapter function?
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.
Pulled it out because I was thinking of reusing it for the future update_issue
function. Also was thinking we might expand it to be more fields (when we want to be able to assign users, labels, etc.)
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.
Never mind, we can come back and use this once we add the functionality for that, will update
web/controllers/task_controller.ex
Outdated
current_user = Guardian.Plug.current_resource(conn) | ||
github_id = github_module().create_issue(attributes, project, current_user) | ||
attributes = Map.merge(attributes, %{"github_id" => github_id}) | ||
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.
I apologise if I'm reviewing too early and it was already your intention to do this, but this behavior would be what we'd expect to put into the task_service module described in #804
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.
Hey @begedin, I initially did that and was wondering the reasoning for pulling this out into a service? There really isnt a lot of complicated logic (most of that happens in the Github service) and wondering why we would create a task service just to copy the lines we have here? Are we thinking of using it beyond the CRUD actions? thanks!
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.
There are no strong reasons right now, but
- It's more in line with how Phoenix 1.3 will structure modules.
- A clean, non-controller module will be easier to test for various outcomes.
- The code will very likely grow beyond these few lines.
- Generally, we like to keep our controller code as tiny as possible.
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, thanks for the points! Will make the change
web/controllers/task_controller.ex
Outdated
|
||
defp github_module do | ||
Application.get_env(:code_corps, :github) | ||
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.
I'm thinking maybe we call this github_client
or even just github
@begedin Mind looking over this for me? Thanks! |
lib/code_corps/github.ex
Outdated
Map.take(task, [:title, :body]), | ||
client | ||
) | ||
case request do |
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 call this a result
or a request_result
. Not a big deal, though.
lib/code_corps/github_testing.ex
Outdated
task | ||
|> Task.github_changeset(%{"github_id" => 1}) | ||
|> Repo.update() | ||
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.
Great work on this one.
def change do | ||
alter table(:projects) do | ||
add :github_repo, :string | ||
add :github_owner, :string |
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 this means we will no longer require a github_id
. Same would go with ember's side. Would you agree?
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.
Yeah, reviewing the Github docs more it looks like we can use the repo name for everything we need
@npendery This is great work and something that's going to get merged ASAP, but sadly, not before we're done with the connect feature. |
@npendery we're working to get the GitHub connect stuff merged now and then can focus on this again shortly. |
a486932
to
fca52bf
Compare
Hey @npendery We're finally at a point with the rest of the project where this can be continued and hopefully wrapped up. If you're still interested in doing so, please let me know and feel free to start by resolving conflicts, etc. Also note that, with the new knowledge, I've updated the issue a good amount, so feel free to go back to it for the update. For converting task attributes into github issue attributes, you'll probably want to extend the Finally, if you're able to only get parts of this done, feel free to do so. If it's a self contained part of the solution, we will be more then happy to merge so other parts can be done separately. Feel free to also submit separate smaller PRs, for parts of the solution, such as the adapter. |
ed17814
to
945277c
Compare
@npendery I've rebased this, but it looks like most of the changes here are also contained in #806 and it may be easier to just continue from there. I've added some much overdue information into that one. Let me know how you feel about continuing this, but my guess is, either way, we will be closing this one and focusing on #806 |
Started moving this towards the new approach. TODOS:
|
@begedin I'm curious what you mean here. |
In our client project, I've found a relatively simple way to do mocks of the whole api layer. Basically, there is a think api module which wraps external requests. This module is then mocked in tests that need it using a macro. What that ends up looking like is something along the lines of with_mock_api(MockModule) do
do_stuff
end In that project, we have a basic success mock, where all requests return the default successful response, a basic failure module, where all requests return the default failure response, and with the way the macro works, we can define simple modules with specific responses, "inline". In our specific case, we would probably mock the |
da7d128
to
e6baaaf
Compare
@joshsmith I've been having trouble finding a nice way to implement things here. The way I see it, we have two issues
My latest commit is just a bunch of scattered things that I'm not sure should be kept in, but I wanted to at least show some of it, so I pushed it up. Feel free to remove if you don't find it useful. I would like to direct your attention to the In order for this to work, we cannot load our api module from the config using a module I've defined it due to the way we use a similar approach with These could be useful tools depending on how we continue. Really, though, the issue here is I'm sorry I'm just listing problems instead of offering solutions, but I'm having difficulties wrapping my head around this yet. Considerations
Approaches for mocking
If we use tentacat, approach 2 is still compatible. For example, I'm leaning towards 2 if we decide to stick with tentacat and 1 if we decide to drop it. |
Also note that we can close #806 as well, when this is merged. |
@begedin it appears there's a merge conflict now from the recent merge in the policy. |
e6f5493
to
b4ee66f
Compare
@joshsmith Rebased and resolved |
b4ee66f
to
ab09f38
Compare
0cf146d
to
0261a04
Compare
d138594
to
8e9e980
Compare
0b0ec6d
to
f494d39
Compare
defp convert?("user_role_id"), do: true | ||
defp convert?("user_skill_id"), do: true | ||
defp convert?("user_task_id"), do: true | ||
defp convert?(_other), do: false |
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.
Would it not make more sense to here to check if it's in a list? i.e. like how Ecto validations work?
f494d39
to
d13b138
Compare
I just pushed up some fixes that I identified in a new commit. Possibly outside the scope of this PR, but some other things I've noticed while testing:
We can break these out into some follow-up issues if necessary since I'm not positive any of this relates to the PR at hand (aside from the bot situation above). I was ultimately able to create issues effectively (see https://github.com/code-corps/test/issues). 7-11 are tests created from my localhost, and 12 is the test created on GH that then failed to sync properly to my localhost. |
|
…refactors - if task params containg a "github_repo_id", an issue is created on github alongside task and task is associated with issue - refactors: - removed reliance on ja_resource and canary from task controller - extracted task creation into separate module - extracted task-related queries into separate module - removed some unused code - moved some code around to follow boundex context convention - fixed several dialyzer warnings
8db93a3
to
ce0c874
Compare
@joshsmith I rebased and resolved conflicts again. I think we need the longs, but I also think we should mute them in the test environment, since they pollute the output.
Some notes on rebasing if there's a need for you to do so:
|
@begedin should we place these rebasing notes in the README somewhere? Seems like it might end up being a fairly common thing to accidentally pull in these changes from the 2.0 branch since we're not locked to a particular commit hash or anything. |
Closes #803, #804, #806
What's in this PR?
create_issue\3
functiongithub_owner
andgithub_repo
fieldsTo do
References
Fixes #804