From 1354048dd6d6b86600e72d9e4bb6ad9061052ef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linnea=20Gr=C3=A4f?= Date: Tue, 15 Aug 2023 19:43:58 +0200 Subject: [PATCH 1/5] Add github step summary --- reuse-action-wrapper.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reuse-action-wrapper.sh b/reuse-action-wrapper.sh index a728cba..1e02fda 100755 --- a/reuse-action-wrapper.sh +++ b/reuse-action-wrapper.sh @@ -11,5 +11,8 @@ git config --global --add safe.directory "$GITHUB_WORKSPACE" # Enter directory cd "$GITHUB_WORKSPACE" || exit 1 +# Add header to step summary +echo "# Reuse Stats" >>"$GITHUB_STEP_SUMMARY" + # Run REUSE -reuse "$@" +reuse "$@" | tee -a "$GITHUB_STEP_SUMMARY" From 774b0fe2a38d08a996bd633cb72c0b15561d4dcf Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 16 Aug 2023 12:31:03 +0200 Subject: [PATCH 2/5] Make summary configurable and optional --- action.yml | 7 +++++++ reuse-action-wrapper.sh | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 146cb05..4e25dbd 100644 --- a/action.yml +++ b/action.yml @@ -11,3 +11,10 @@ runs: branding: icon: 'check-circle' color: 'green' + +inputs: + summary: + description: "Show your REUSE compliance report in the github step summary using markdown (`markdown`), a json codeblock (`json`) or not at all (`none`)" + required: true + default: 'markdown' + diff --git a/reuse-action-wrapper.sh b/reuse-action-wrapper.sh index 1e02fda..8924030 100755 --- a/reuse-action-wrapper.sh +++ b/reuse-action-wrapper.sh @@ -11,8 +11,23 @@ git config --global --add safe.directory "$GITHUB_WORKSPACE" # Enter directory cd "$GITHUB_WORKSPACE" || exit 1 -# Add header to step summary -echo "# Reuse Stats" >>"$GITHUB_STEP_SUMMARY" +echo "Summary type (should be json, markdown, or none): $INPUT_SUMMARY" + +if ! [ "$INPUT_SUMMARY" = "none" ]; then + # Add header to step summary + echo "# REUSE Compliance Status" >>"$GITHUB_STEP_SUMMARY" +fi + +if [ "$INPUT_SUMMARY" = "json" ]; then + # Add code block header to step summary + printf '\n```json\n' >>"$GITHUB_STEP_SUMMARY" +fi # Run REUSE reuse "$@" | tee -a "$GITHUB_STEP_SUMMARY" + +if [ "$INPUT_SUMMARY" = "json" ]; then + # Add code block footer to step summary + printf '\n```\n' >>"$GITHUB_STEP_SUMMARY" +fi + From 23b8f5037f7f738e4cca753653077d6a38f5e117 Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 16 Aug 2023 12:48:17 +0200 Subject: [PATCH 3/5] Add new arguments to self test --- .github/workflows/selftest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/selftest.yml b/.github/workflows/selftest.yml index c668372..739e307 100644 --- a/.github/workflows/selftest.yml +++ b/.github/workflows/selftest.yml @@ -24,10 +24,12 @@ jobs: uses: ./ with: args: --include-submodules lint --json + summary: json - name: REUSE SPDX SBOM uses: ./ with: args: spdx + summary: none # Use all major version of the action test-v1: From b19cabb2adb5b879d9e4bcccc696349ccb8d78fd Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 16 Aug 2023 12:52:40 +0200 Subject: [PATCH 4/5] Add summary to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3498384..0aace8a 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ In the same fashion, it is possible to add optional arguments like `--include-su | Name | Requirement | Default | Description | | ------ | ----------- | ------- | ----------- | | `args` | _required_ | `lint` | The subcommand for the REUSE helper tool. Read the [tool's documentation](https://reuse.readthedocs.io/) for all available subcommands. | +| `summary` | _required_ | `markdown` | Whether or not to include the tool output in the github step summary markdown. Set to `json` to format the tools output in a codeblock or to `none` to disable this output. Regardless of this option the output will still be visible in the logs. | ## Versions From 140e81ab76b30d9c5641b7b11e28222b3a11f8f9 Mon Sep 17 00:00:00 2001 From: nea Date: Wed, 16 Aug 2023 12:57:19 +0200 Subject: [PATCH 5/5] Fix tool output leaking with output disabled --- reuse-action-wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reuse-action-wrapper.sh b/reuse-action-wrapper.sh index 8924030..d7d4cf9 100755 --- a/reuse-action-wrapper.sh +++ b/reuse-action-wrapper.sh @@ -24,7 +24,7 @@ if [ "$INPUT_SUMMARY" = "json" ]; then fi # Run REUSE -reuse "$@" | tee -a "$GITHUB_STEP_SUMMARY" +reuse "$@" | (if ! [ "$INPUT_SUMMARY" = "none" ]; then tee -a "$GITHUB_STEP_SUMMARY"; else cat; fi) if [ "$INPUT_SUMMARY" = "json" ]; then # Add code block footer to step summary