Skip to content

Commit

Permalink
fix: use circleci api v1.1 to avoid login error (#982)
Browse files Browse the repository at this point in the history
This is to fix bioconda/bioconda-recipes#47663 for fetching artifacts
from a PR that was just merged to master in order to upload to the
channel

We may want to follow it up with updates to use a token, but I wanted to
get it to a working state for right now
  • Loading branch information
aliciaaevans authored May 3, 2024
1 parent 125c9ea commit ebafe92
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bioconda_utils/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def parse_azure_build_id(url: str) -> str:

def get_circleci_artifacts(check_run, platform):
circleci_workflow_id = json.loads(check_run.external_id)["workflow-id"]
# Use API v2 because v1.1 does not have a workflow endpoint
url_wf = f"https://circleci.com/api/v2/workflow/{circleci_workflow_id}/job"
res_wf = requests.get(url_wf)
json_wf = json.loads(res_wf.text)
Expand All @@ -206,13 +207,15 @@ def get_circleci_artifacts(check_run, platform):
for job in json_wf["items"]:
if job["name"].startswith(f"build_and_test-{platform}"):
circleci_job_num = job["job_number"]
url = f"https://circleci.com/api/v2/project/gh/bioconda/bioconda-recipes/{circleci_job_num}/artifacts"
# Use API v1.1 because v2 requires authentication
url = f"https://circleci.com/api/v1.1/project/gh/bioconda/bioconda-recipes/{circleci_job_num}/artifacts"
res = requests.get(url)
res.raise_for_status()
json_job = json.loads(res.text)
if len(json_job["items"]) == 0:
if len(json_job) == 0:
raise ValueError("No artifacts found!")
else:
for artifact in json_job["items"]:
for artifact in json_job:
artifact_url = artifact["url"]
if artifact_url.endswith((".html", ".json", ".json.bz2", ".json.zst")):
continue
Expand Down

0 comments on commit ebafe92

Please sign in to comment.