This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a release after uploading (#19)
- Loading branch information
1 parent
9fd4968
commit 52460ac
Showing
8 changed files
with
364 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
async def create(gh, releases_url, version, body): | ||
# https://developer.github.com/v3/repos/releases/#create-a-release | ||
details = {"tag_name": f"v{version}", "body": body} | ||
result = await gh.post(releases_url, data=details) | ||
return result["upload_url"] | ||
|
||
|
||
async def add_artifact(gh, artifact_path): | ||
# XXX https://developer.github.com/v3/repos/releases/#upload-a-release-asset | ||
# XXX Requires changes to gidgethub for content-type upload | ||
# XXX application/gzip, application/zip | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"url": "https://api.github.com/repos/octocat/Hello-World/releases/1", | ||
"html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0", | ||
"assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets", | ||
"upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}", | ||
"tarball_url": "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0", | ||
"zipball_url": "https://api.github.com/repos/octocat/Hello-World/zipball/v1.0.0", | ||
"id": 1, | ||
"node_id": "MDc6UmVsZWFzZTE=", | ||
"tag_name": "v1.0.0", | ||
"target_commitish": "master", | ||
"name": "v1.0.0", | ||
"body": "Description of the release", | ||
"draft": false, | ||
"prerelease": false, | ||
"created_at": "2013-02-27T19:35:32Z", | ||
"published_at": "2013-02-27T19:35:32Z", | ||
"author": { | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
}, | ||
"assets": [ | ||
|
||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import json | ||
|
||
import trio | ||
|
||
from release_often import release | ||
from . import data | ||
|
||
|
||
class MockGitHubAPI: | ||
def __init__(self, to_return): | ||
self.to_return = to_return | ||
|
||
async def post(self, url, *, data): | ||
self.url = url | ||
self.data = data | ||
return self.to_return | ||
|
||
|
||
def test_create(data_path): | ||
webhook_event_path = data_path / "create_release.json" | ||
release_payload = webhook_event_path.read_text(encoding="utf-8") | ||
to_return = json.loads(release_payload) | ||
releases_url = "https://url/to/create/release" | ||
mock_gh = MockGitHubAPI(to_return) | ||
version = "1.2.3" | ||
body = "body of things" | ||
result = trio.run(release.create, mock_gh, releases_url, version, body) | ||
assert ( | ||
result | ||
== "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}" | ||
) | ||
assert mock_gh.url == releases_url | ||
assert mock_gh.data == {"tag_name": "v1.2.3", "body": body} |