From 02cd95cdd1921f5c045abcac6b98f68f49d755ec Mon Sep 17 00:00:00 2001 From: Srijan Saurav Date: Thu, 24 Aug 2023 11:27:11 +0530 Subject: [PATCH 1/2] feat: Pick up PR's head commit from GitHub context This allows the CLI to not execute any git commands thus making the action work all the time. --- action.yml | 6 +++++- main.py | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 8eb3471..fb4d3b6 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ description: 'GitHub Action that uploads test coverage reports to DeepSource for author: 'Sanket Saurav ' inputs: key: - description: 'Programming language shortcode for which coverage is reported. Allowed values are — python, go' + description: 'Programming language shortcode for which coverage is reported. Allowed values are — python, go, javascript, ruby, java, kotlin, scala, php, csharp, cxx, rust, swift' required: true coverage-file: description: 'Path to the coverage data file. e.g. ./coverage.xml' @@ -14,6 +14,10 @@ inputs: fail-ci-on-error: description: 'Should the CI build fail if there is an error while uploading the report to DeepSource? Allowed values are — true, false' default: false + commit-sha: + description: 'HEAD commit for which the Test Coverage report is being sent' + required: false + default: ${{ github.event.pull_request.head.sha }} branding: color: 'green' icon: 'umbrella' diff --git a/main.py b/main.py index b936fa3..287d3ca 100755 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ "coverage_file": "INPUT_COVERAGE-FILE", "dsn": "INPUT_DSN", "fail_ci_on_error": "INPUT_FAIL-CI-ON-ERROR", + "commit_sha": "INPUT_COMMIT-SHA" } DEEPSOURCE_CLI_PATH = "/app/bin/deepsource" @@ -45,7 +46,11 @@ def main() -> None: # skipcq: BAN-B603, PYL-W1510 process = subprocess.run( command, - env=dict(os.environ, DEEPSOURCE_DSN=input_data["dsn"]), + env=dict( + os.environ, + DEEPSOURCE_DSN=input_data["dsn"], + GHA_HEAD_COMMIT_SHA=input_data["commit_sha"], + ), capture_output=True, ) From cef4142cbc2aec2bc002fdcd22295d1a89b3097b Mon Sep 17 00:00:00 2001 From: "deepsource-enterprise-internal[bot]" <111794875+deepsource-enterprise-internal[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 05:59:26 +0000 Subject: [PATCH 2/2] style: Format code with black --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 287d3ca..54333ca 100755 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ "coverage_file": "INPUT_COVERAGE-FILE", "dsn": "INPUT_DSN", "fail_ci_on_error": "INPUT_FAIL-CI-ON-ERROR", - "commit_sha": "INPUT_COMMIT-SHA" + "commit_sha": "INPUT_COMMIT-SHA", } DEEPSOURCE_CLI_PATH = "/app/bin/deepsource"