-
Notifications
You must be signed in to change notification settings - Fork 15
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
Download GitHub release artifacts #127
Closed
Closed
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
154cb98
Support downloading from Github
manics 8899b9b
Test downloading from Github
manics fed5375
Fix testDownloadRelease (py artifact no longer exists)
manics ae0dacd
Github typo
manics 44fb7a4
Use GitHub releases for Travis CI
sbesson b924b1a
Do not mix --github and --ice
sbesson a5a2608
Use full tags for travis tests so GitHub downloads work
manics c269e56
Temporarily pin flake8
manics 211b965
Travis: try a more recent icepy build
manics ec35ce8
Travis try bionic and pip>=20.2.3
manics 6176e60
Travis try ome/zeroc-ice-ubuntu1804
manics bc91592
More faffing with PATH
manics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
from builtins import str | ||
from past.builtins import basestring | ||
from builtins import object | ||
import json | ||
import os | ||
import logging | ||
|
||
|
@@ -51,7 +52,9 @@ def __init__(self, args): | |
args.ci = 'https://ci.openmicroscopy.org' | ||
if not args.branch: | ||
args.branch = 'latest' | ||
if args.build or re.match(r'[A-Za-z]\w+-\w+', args.branch): | ||
if args.github: | ||
self.artifacts = GithubArtifacts(args) | ||
elif args.build or re.match(r'[A-Za-z]\w+-\w+', args.branch): | ||
self.artifacts = JenkinsArtifacts(args) | ||
elif re.match('[0-9]+|latest$', args.branch): | ||
self.artifacts = ReleaseArtifacts(args) | ||
|
@@ -472,6 +475,56 @@ def read_downloads(dlurl): | |
return dl_icever | ||
|
||
|
||
class GithubArtifacts(ArtifactsList): | ||
""" | ||
Fetch artifacts from GitHub releases | ||
""" | ||
|
||
def __init__(self, args): | ||
super(GithubArtifacts, self).__init__() | ||
self.args = args | ||
|
||
if re.match(r'[0-9]+\.[0-9]+\.[0-9]+', args.branch): | ||
dl_url = 'https://api.github.com/repos/%s/releases/tags/v%s' % ( | ||
args.github, args.branch) | ||
else: | ||
raise ArtifactException( | ||
'Only GitHub tags are supported', args.branch) | ||
|
||
if args.ice: | ||
raise ArtifactException( | ||
'Ice argument not supported for GitHub releases', args.ice) | ||
|
||
artifacturls = self.read_downloads(dl_url) | ||
if len(artifacturls) <= 0: | ||
raise AttributeError( | ||
"No artifacts, please check the GitHub releases page.") | ||
self.find_artifacts(artifacturls) | ||
|
||
@staticmethod | ||
def read_downloads(dlurl): | ||
url = None | ||
d = None | ||
try: | ||
url = fileutils.open_url(dlurl) | ||
log.debug('Fetching html from %s code:%d', url.url, url.code) | ||
if url.code != 200: | ||
log.error('Failed to get HTML from %s (code %d)', | ||
url.url, url.code) | ||
raise Stop( | ||
20, 'Downloads page failed, is the version correct?') | ||
|
||
d = json.load(url) | ||
except HTTPError as e: | ||
log.error('Failed to get HTML from %s (%s)', dlurl, e) | ||
raise Stop(20, 'Downloads page failed, is the version correct?') | ||
finally: | ||
if url: | ||
url.close() | ||
|
||
return [a['browser_download_url'] for a in d['assets']] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Main caveat of this approach is that I found it only worked with release assets of public repositories. TO be reviewed if we want to investigate using it for private repositories |
||
|
||
|
||
class DownloadCommand(Command): | ||
""" | ||
Download an OMERO artifact from either a downloads or a Continuous | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could be renamed as
GitHubArtifacts
but not a blockerThere 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 was undecided on following the
GitHub
branding vsCapitalisedsubtypeArtifacts