Skip to content
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

bot: add CircleCI token to call #85

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.5
version = 0.0.6

[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 @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions images/bot/src/bioconda_bot/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"):
Expand Down