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

chore(ci-issues): add junit upload CLI #550

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lecrepont01
Copy link
Contributor

Adds the cli mergify ci-issues junit-upload to upload JUnit xml reports to CI Issues.

Fixes MRGFY-4339

Copy link
Contributor

mergify bot commented Nov 20, 2024

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🔴 🔎 Reviews

This rule is failing.
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0
  • #review-requested = 0

🟢 Changelog requirements

Wonderful, this rule succeeded.
  • any of:
    • -title ~= ^feat
    • label = need changelog
    • label = skip changelog

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?:

@mergify mergify bot requested a review from a team November 20, 2024 17:05
jd
jd previously requested changes Nov 20, 2024
mergify_cli/ci_issues/cli.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/cli.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/cli.py Show resolved Hide resolved
mergify_cli/ci_issues/cli.py Show resolved Hide resolved
mergify_cli/ci_issues/cli.py Show resolved Hide resolved
mergify_cli/ci_issues/custom_types.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/custom_types.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/junit_upload.py Outdated Show resolved Hide resolved
sileht
sileht previously requested changes Nov 21, 2024
mergify_cli/ci_issues/junit_upload.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/junit_upload.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/utils.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/junit_upload.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/custom_types.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/utils.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/utils.py Outdated Show resolved Hide resolved
mergify_cli/ci_issues/utils.py Show resolved Hide resolved
mergify_cli/ci_issues/utils.py Outdated Show resolved Hide resolved
@mergify mergify bot dismissed stale reviews from sileht and jd November 21, 2024 16:21

Pull request has been modified.

@mergify mergify bot requested a review from a team November 21, 2024 16:22
@lecrepont01 lecrepont01 force-pushed the ci_issues_junit_upload branch 2 times, most recently from 2f24b3d to 003113a Compare November 22, 2024 09:29
Adds the cli `mergify ci-issues junit-upload` to upload JUnit xml reports to CI Issues.

Fixes MRGFY-4339
"-s",
help="Head SHA of the triggered job",
required=True,
envvar="HEAD_SHA",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go further and load default depending on where the client is run (Github Action or Circle). Otherwise, it means if we add a new CLI option or we want to update an existing one, we have to update the GitHub actions and the Circle CI orb.

help="URL of the Mergify API",
required=True,
envvar="MERGIFY_API_SERVER",
default="https://api.mergify.com/v1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default="https://api.mergify.com/v1",
default="https://api.mergify.com/",

I feel that should be the root server here, cc @sileht

"-t",
help="CI Issues Application Key",
required=True,
envvar="MERGIFY_CI_ISSUES_TOKEN",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the token is global right now, so should we use something like MERGIFY_TOKEN? cc @sileht

"-p",
help="CI provider",
default=None,
envvar="CI_PROVIDER",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem exported by any CI, what's the point?

The default should be smart and autodetect the CI based on env vars.

"-r",
help="Repository full name (owner/repo)",
required=True,
envvar="REPOSITORY",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean GITHUB_REPOSITORY more likely?

@@ -0,0 +1,82 @@
import click
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename everything to "CI" not "ci issues"

data=form_data,
files=files_to_upload,
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle status code != 200?

)


def get_files_to_upload(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only used once in upload so put it there?
especially since this just uploads XML file blindly so it really is not "utils" at all.

# TODO(leo): stream the files instead of loading them
with file_path.open("rb") as f:
files_to_upload.append(
("files", (file_path.name, f.read(), "application/xml")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong but it does not seem like you do not have to read the file content explicitly but you can just pass a file object to httpx.
That should prevent loading a lot of things in memory for nothing.

Comment on lines 214 to 215
event_hooks["request"].insert(0, log_httpx_request)
event_hooks["response"].insert(0, log_httpx_response)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we share this debug thing too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants