From 88297fcb5137deb8826cc6ee4f4e58159afb8a8c Mon Sep 17 00:00:00 2001 From: aliciaaevans Date: Mon, 17 Jun 2024 16:29:02 -0400 Subject: [PATCH 1/4] fix: token for CircleCI artifacts --- images/bot/src/bioconda_bot/common.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/images/bot/src/bioconda_bot/common.py b/images/bot/src/bioconda_bot/common.py index c465f47..d925d4f 100644 --- a/images/bot/src/bioconda_bot/common.py +++ b/images/bot/src/bioconda_bot/common.py @@ -144,9 +144,14 @@ def parse_azure_build_id(url: str) -> str: # Find artifact zip files, download them and return their URLs and contents async def fetch_circleci_artifacts(session: ClientSession, workflowId: str) -> [(str, str)]: artifacts = [] + token = os.environ["CIRCLECI_TOKEN"] + headers = { + "Circle-Token": token, + "User-Agent": "BiocondaCommentResponder", + } url_wf = f"https://circleci.com/api/v2/workflow/{workflowId}/job" - async with session.get(url_wf) as response: + async with session.get(url_wf, headers=headers) as response: # Sometimes we get a 301 error, so there are no longer artifacts available if response.status == 301: return artifacts @@ -160,13 +165,13 @@ async def fetch_circleci_artifacts(session: ClientSession, workflowId: str) -> [ for job in res_wf_object["items"]: if job["name"].startswith(f"build_and_test-"): circleci_job_num = job["job_number"] - url = f"https://circleci.com/api/v1.1/project/gh/bioconda/bioconda-recipes/{circleci_job_num}/artifacts" + url = f"https://circleci.com/api/v2/project/gh/bioconda/bioconda-recipes/{circleci_job_num}/artifacts" - async with session.get(url) as response: + async with session.get(url, headers=headers) as response: response.raise_for_status() res = await response.text() res_object = safe_load(res) - for artifact in res_object: + for artifact in res_object["items"]: zipUrl = artifact["url"] pkg = artifact["path"] if zipUrl.endswith((".conda", ".tar.bz2")): # (currently excluding container images) or zipUrl.endswith(".tar.gz"): From 8b5be2ef64f02997991df08b5c7903eedb4fd48a Mon Sep 17 00:00:00 2001 From: aliciaaevans Date: Mon, 17 Jun 2024 16:31:03 -0400 Subject: [PATCH 2/4] update bot version --- images/bot/setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/bot/setup.cfg b/images/bot/setup.cfg index 3b6fde4..2abb8c6 100644 --- a/images/bot/setup.cfg +++ b/images/bot/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = bioconda-bot -version = 0.0.5 +version = 0.0.6 [options] python_requires = >=3.8 From 8c940caccae23169bda36acd6cd0853e83c762da Mon Sep 17 00:00:00 2001 From: aliciaaevans Date: Mon, 17 Jun 2024 16:35:43 -0400 Subject: [PATCH 3/4] image version --- .github/workflows/bot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bot.yaml b/.github/workflows/bot.yaml index 89ae3bf..257c299 100644 --- a/.github/workflows/bot.yaml +++ b/.github/workflows/bot.yaml @@ -30,7 +30,7 @@ jobs: options: --privileged env: IMAGE_NAME: bot - IMAGE_VERSION: '1.4.0' + IMAGE_VERSION: '1.4.1' steps: - uses: actions/checkout@v4 From 82312d933aa81bdd1834f1b57381ea0c6223fea3 Mon Sep 17 00:00:00 2001 From: aliciaaevans Date: Mon, 17 Jun 2024 16:36:28 -0400 Subject: [PATCH 4/4] fix typo while we are here --- images/bot/src/bioconda_bot/comment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/bot/src/bioconda_bot/comment.py b/images/bot/src/bioconda_bot/comment.py index 305962b..c4ae242 100644 --- a/images/bot/src/bioconda_bot/comment.py +++ b/images/bot/src/bioconda_bot/comment.py @@ -36,7 +36,7 @@ async def make_artifact_comment(session: ClientSession, pr: int, sha: str) -> No if ci_platform == "azure": comment += compose_azure_comment(artifacts) elif ci_platform == "circleci": - comment += compose_circlci_comment(artifacts) + comment += compose_circleci_comment(artifacts) elif ci_platform == "github-actions": comment += compose_gha_comment(artifacts) if len(comment) == 0: @@ -91,7 +91,7 @@ def compose_azure_comment(artifacts: List[Tuple[str, str]]) -> str: return comment -def compose_circlci_comment(artifacts: List[Tuple[str, str]]) -> str: +def compose_circleci_comment(artifacts: List[Tuple[str, str]]) -> str: nPackages = len(artifacts) if nPackages < 1: