sdepold / octo.erl Goto Github PK
View Code? Open in Web Editor NEWErlang wrapper for the Github API.
License: MIT License
Erlang wrapper for the Github API.
License: MIT License
Guess I will have to mock the test requests :(
So I've been looking into how others test their GitHub bindings, and it looks like the best way is employing two sets of tests:
Unit tests are run by Travis; integration ones are run by developers themselves. Integration tests require the developer to create an account for testing purposes.
What we have at the moment can be described as "integration tests implemented using unit testing framework". Furthermore, it's nailed to one specific repo, sdepold/octo.erl-test
.
So here's an outline of what I'm (awfully lazily) doing:
Does that make sense?
Of all the functions that work with pull requests, merge_pull_request
is the only one that doesn't lift JSON response into Erlang record. That should be fixed.
(This is a memo.)
So I looked into edoc, the goal being to see if it can:
Edoc excels with the first goal, but totally fails the second.
I couldn't find a way to group functions—they're always in the alphabetical order.
I couldn't find a way to document two clauses differently—for each combination of function and its arity there's only one block of docs. This is really painful because we try to make pagination as unobtrusive as possible, which forces us to make things like octo:list_pull_requests(A, B)
behave differently depending on the types of A
and B
. But if we can't document these behaviours separately, the docs are going to confuse people instead of enlightening them.
We'll have to keep using one big Markdown file for this, but I need to come up with a better, more readable formatting for it.
octo:update_reference
take optional parameters again (removed in 957771a)This function turns refs/heads/A
into A
and refs/tags/B
into B
. It is sometimes applied to API responses.
I am starting to doubt its utility. I wholeheartedly agree that it's nice to write create_branch("user", "repo", "branchname")
instead of create_reference("user", "repo", "refs/heads/branchname")
, but I'd argue that responses should be the same regardless of what function we used. (And they are the same on API level, i.e. in JSON—it's Erlang side that's starting messing with things.)
#Some GitHub API endpoints accept optional arguments, e.g. body
in "Create pull request" or all the stuff in "List pull requests". We don't have a set approach for handling those.
octo.erl
itself has some internal options that are always passed in a list as last argument:
All_PRs = octo:list_pull_requests("sdepold", "octo.erl", [all_pages]).
%% Convenience overload passes empty list as options
Some_PRs = octo:list_pull_requests("sdepold", "octo.erl").
The question is: should I pass GitHub's options as a separate list (let's call this option №1), or should they be merged with octo.erl's options (options №2)?
Pros of option №1:
Cons of option №1:
All_PRs = octo:list_pull_requests("sdepold", "octo.erl", [], [all_pages]).
octo:f(X, Options)
will suddenly become octo:f(X, Payload, Options)
.)The options are symmetrical so the cons of option №1 are pros of option №2 and vice versa.
I'm told Rebar 3 is much, much better than Rebar 2. We should consider migrating. A migration tutorial is available.
The scope is not clear, need to go through the docs first.
This is inconsistent with the rest of the functions; an ordinary record should be returned, with message
and documentation_url
fields populated from the response.
GitHub provides access to certain yet-unreleased features if we pass some value in Accept
header. Our users might need it, so we should provide a way to set the header safely.
GitHub docs make pretty poor job of describing what fields the returned objects will contain. The only way to get them all is to paste all example responses together and run them through bits of sed
and uniq
, which is quite lame in my opinion. And we do need to get them all, otherwise we'll hide parts of response from the user, which is bad.
Clearly, we have to abandon records altogether. Unfortunately, maps aren't fully ready yet, so we'll have to use dict
s.
Any thoughts?
octo:update_organization
take optional parameters again (removed in 3bb8dfc)GitHub's API documentation specifically warns against the approach taken by octo.erl:
Keep in mind that you should always rely on these link relations provided to you. Don't try to guess or construct your own URL. Some API calls, like listing commits on a repository, use pagination results that are based on SHA values, not numbers.
Bumped into this while writing tests (yep, #24 ain't dead :), thought it's better to file an issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.