Skip to content

Commit

Permalink
bot: Add support for .conda artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Mar 27, 2024
1 parent ecfb6b5 commit 2d728eb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-22.04
env:
IMAGE_NAME: bot
IMAGE_VERSION: '1.1.23'
IMAGE_VERSION: '1.2.0'

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion images/bot/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = bioconda-bot
version = 0.0.2
version = 0.0.3

[options]
python_requires = >=3.8
Expand Down
4 changes: 2 additions & 2 deletions images/bot/src/bioconda_bot/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def compose_azure_comment(artifacts: List[Tuple[str, str]]) -> str:

# Table of packages and zips
for URL, artifact in artifacts:
if not (package_match := re.match(r"^((.+)\/(.+)\/(.+)\/(.+\.tar\.bz2))$", artifact)):
if not (package_match := re.match(r"^((.+)\/(.+)\/(.+)\/(.+\.conda|.+\.tar\.bz2))$", artifact)):
continue
url, archdir, basedir, subdir, packageName = package_match.groups()
urlBase = URL[:-3] # trim off zip from format=
Expand Down Expand Up @@ -104,7 +104,7 @@ def compose_circlci_comment(artifacts: List[Tuple[str, str]]) -> str:

# Table of packages and repodata.json
for URL, artifact in artifacts:
if not (package_match := re.match(r"^((.+)\/(.+)\/(.+\.tar\.bz2))$", URL)):
if not (package_match := re.match(r"^((.+)\/(.+)\/(.+\.conda|.+\.tar\.bz2))$", URL)):
continue
url, basedir, subdir, packageName = package_match.groups()
repo_url = "/".join([basedir, subdir, "repodata.json"])
Expand Down
8 changes: 6 additions & 2 deletions images/bot/src/bioconda_bot/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ async def get_pr_info(session: ClientSession, pr: int) -> Any:

def list_zip_contents(fname: str) -> [str]:
f = ZipFile(fname)
return [e.filename for e in f.infolist() if e.filename.endswith('.tar.gz') or e.filename.endswith('.tar.bz2')]
return [
e.filename
for e in f.infolist()
if e.filename.endswith((".tar.gz", ".conda", ".tar.bz2"))
]


# Download a zip file from url to zipName.zip and return that path
Expand Down Expand Up @@ -165,7 +169,7 @@ async def fetch_circleci_artifacts(session: ClientSession, workflowId: str) -> [
for artifact in res_object["items"]:
zipUrl = artifact["url"]
pkg = artifact["path"]
if zipUrl.endswith(".tar.bz2"): # (currently excluding container images) or zipUrl.endswith(".tar.gz"):
if zipUrl.endswith((".conda", ".tar.bz2")): # (currently excluding container images) or zipUrl.endswith(".tar.gz"):
artifacts.append((zipUrl, pkg))
return artifacts

Expand Down
10 changes: 7 additions & 3 deletions images/bot/src/bioconda_bot/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def toggle_visibility(session: ClientSession, container_repo: str) -> None
# await sleep(5)
# if success:
# await toggle_visibility(session, basename.split("%3A")[0])
# elif x.endswith(".bz2"):
# elif x.endswith((".conda", ".tar.bz2")):
# # Package
# log("uploading package")
# ANACONDA_TOKEN = os.environ["ANACONDA_TOKEN"]
Expand Down Expand Up @@ -255,7 +255,7 @@ async def extract_and_upload(session: ClientSession, fName: str) -> int:
if os.path.exists(fName):
zf = ZipFile(fName)
for e in zf.infolist():
if e.filename.endswith('.tar.bz2'):
if e.filename.endswith((".conda", ".tar.bz2")):
await upload_package(session, zf, e)
elif e.filename.endswith('.tar.gz'):
await upload_image(session, zf, e)
Expand All @@ -274,7 +274,11 @@ async def upload_artifacts(session: ClientSession, pr: int) -> str:
artifactDict = await fetch_pr_sha_artifacts(session, pr, sha)
# Merge is deprecated, so leaving as Azure only
artifacts = artifactDict["azure"]
artifacts = [artifact for (URL, artifact) in artifacts if artifact.endswith((".gz", ".bz2"))]
artifacts = [
artifact
for (URL, artifact) in artifacts
if artifact.endswith((".gz", ".conda", ".tar.bz2"))
]
assert artifacts

# Download/upload Artifacts
Expand Down

0 comments on commit 2d728eb

Please sign in to comment.