From 2d728ebd2a3821dc81fb32542151533232a1b51f Mon Sep 17 00:00:00 2001 From: Marcel Bargull Date: Wed, 27 Mar 2024 19:30:33 +0100 Subject: [PATCH] bot: Add support for .conda artifacts Signed-off-by: Marcel Bargull --- .github/workflows/bot.yaml | 2 +- images/bot/setup.cfg | 2 +- images/bot/src/bioconda_bot/comment.py | 4 ++-- images/bot/src/bioconda_bot/common.py | 8 ++++++-- images/bot/src/bioconda_bot/merge.py | 10 +++++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bot.yaml b/.github/workflows/bot.yaml index 3b6371db..e7a9f34b 100644 --- a/.github/workflows/bot.yaml +++ b/.github/workflows/bot.yaml @@ -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 diff --git a/images/bot/setup.cfg b/images/bot/setup.cfg index 81a40baf..c4173742 100644 --- a/images/bot/setup.cfg +++ b/images/bot/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = bioconda-bot -version = 0.0.2 +version = 0.0.3 [options] python_requires = >=3.8 diff --git a/images/bot/src/bioconda_bot/comment.py b/images/bot/src/bioconda_bot/comment.py index c2b7aa32..673efe4d 100644 --- a/images/bot/src/bioconda_bot/comment.py +++ b/images/bot/src/bioconda_bot/comment.py @@ -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= @@ -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"]) diff --git a/images/bot/src/bioconda_bot/common.py b/images/bot/src/bioconda_bot/common.py index a4328ce2..3d392b03 100644 --- a/images/bot/src/bioconda_bot/common.py +++ b/images/bot/src/bioconda_bot/common.py @@ -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 @@ -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 diff --git a/images/bot/src/bioconda_bot/merge.py b/images/bot/src/bioconda_bot/merge.py index c772a63e..70c842c4 100644 --- a/images/bot/src/bioconda_bot/merge.py +++ b/images/bot/src/bioconda_bot/merge.py @@ -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"] @@ -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) @@ -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