Skip to content

feat: add ability to use OIDC to report coverage #34

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

Open
wants to merge 2 commits into
base: master
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
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ inputs:
description: 'HEAD commit for which the Test Coverage report is being sent'
required: false
default: ${{ github.event.pull_request.head.sha }}
use-oidc:
description: 'Use OIDC token instead of DSN. Allowed values are — true, false'
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] Clarify the 'use-oidc' input description by replacing the em dash with clear language (e.g. 'Allowed values: "true" or "false"').

Copilot uses AI. Check for mistakes.

required: false
default: 'false'
branding:
color: 'green'
icon: 'umbrella'
Expand Down
11 changes: 7 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"dsn": "INPUT_DSN",
"fail_ci_on_error": "INPUT_FAIL-CI-ON-ERROR",
"commit_sha": "INPUT_COMMIT-SHA",
"use_oidc": "INPUT_USE-OIDC",
}

DEEPSOURCE_CLI_PATH = "/app/bin/deepsource"
Expand Down Expand Up @@ -54,6 +55,9 @@ def main() -> None:
input_data["coverage_file"],
]

if input_data["use_oidc"] == "true":
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider converting the input value to a native boolean (e.g., using a lower case conversion or a boolean cast) to simplify condition checking and mitigate case sensitivity issues.

Suggested change
if input_data["use_oidc"] == "true":
if input_data["use_oidc"]:

Copilot uses AI. Check for mistakes.

command.append("--use-oidc")

# change the current working directory to the GitHub repository's context
os.chdir(GITHUB_WORKSPACE_PATH)

Expand All @@ -68,10 +72,9 @@ def main() -> None:
capture_output=True,
)

if process.returncode != 0:
if input_data["fail_ci_on_error"] == "true":
print(f"::error file:main.py::{process.stdout.decode('utf-8')}")
sys.exit(1)
if process.returncode != 0 and input_data["fail_ci_on_error"] == "true":
print(f"::error file:main.py::{process.stdout.decode('utf-8')}")
sys.exit(1)

print(process.stdout.decode("utf-8"))
print(process.stderr.decode("utf-8"), file=sys.stderr)
Expand Down