From 086d381c6606614fc7638ddfd99fe878cbd184ae Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 14:39:41 +0100 Subject: [PATCH 01/22] organized test cases for clear reporting. --- .github/workflows/ci.yml | 82 ++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad5072f..e2298b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,8 @@ jobs: lint-and-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout Code + uses: actions/checkout@v4 - name: Validate action.yml Metadata run: | @@ -27,7 +28,7 @@ jobs: label: "test-success-path-defaults" script: | console.log("✅ github-script-post-comment action executed in CI."); - return "Self-test successful."; + return "✅ Test Case 1 - Composite Action - Success Path with Defaults."; - name: Upload Embedded JavaScript uses: actions/upload-artifact@v4 @@ -43,41 +44,84 @@ jobs: npm ci npx eslint . - - name: Test Case 2 - Composite Action - No Return + - name: Test Case 2 - Composite Action - Success Path with github-step-summary + uses: ./ + id: test-success-path-github-step-summary + with: + label: "test-success-path-github-step-summary" + post-target: github-step-summary + script: | + console.log("✅ github-script-post-comment action executed in CI."); + return "✅ Test Case 2 - Composite Action - Success Path with github-step-summary."; + + - name: Test Case 3 - Composite Action - Success Path with pull-request + uses: ./ + id: test-success-path-pull-request + with: + label: "test-success-path-pull-request" + post-target: pull-request + script: | + console.log("✅ github-script-post-comment action executed in CI."); + return "✅ Test Case 3 - Composite Action - Success Path with pull-request."; + + negative-tests: + name: Negative Test - Expected to Fail + runs-on: ubuntu-latest + outputs: + # Define an output for the job + final_result: ${{ steps.verify-failure.conclusion }} + steps: + - name: Test Case 4 - Composite Action - No Return uses: ./ id: test-no-return continue-on-error: true with: label: "test-no-return" script: | + console.log("Test Case 2 - Composite Action - No Return"); console.log("Expect error: script does not return string."); - - name: Test Case 3 - Composite Action - Return Non-String + - name: Test Case 5 - Composite Action - Return Non-String uses: ./ id: test-return-non-string continue-on-error: true with: label: "test-return-non-string" script: | + console.log("Test Case 3 - Composite Action - Return Non-String"); console.log("Expect error: script returns non-string."); return {title: "Test Case 3", message: "test case return non-string", score: 50}; - - name: Test Case 4 - Composite Action - Success Path with github-step-summary - uses: ./ - id: test-success-path-github-step-summary - with: - label: "test-success-path-github-step-summary" - post-target: github-step-summary - script: | - console.log("✅ github-script-post-comment action executed in CI."); - return "Self-test successful."; + - name: Verify both expected failures occurred + id: verify-failure + if: steps.test-no-return.outcome == 'failure' && steps.test-return-non-string.outcome == 'failure' + run: | + echo "✅ All expected negative tests failed as anticipated." - - name: Test Case 5 - Composite Action - Success Path with pull-request + - name: Fail job if any expected failure did NOT occur + if: steps.test-no-return.outcome != 'failure' || steps.test-return-non-string.outcome != 'failure' + run: | + echo "❌ One or more expected negative tests did not fail." + exit 1 + + test-summary: + name: Test Summary + runs-on: ubuntu-latest + needs: [lint-and-test, negative-tests] + if: always() + + steps: + - name: Checkout Code + uses: actions/checkout@v5 + - name: Add Test Summary uses: ./ - id: test-success-path-pull-request with: - label: "test-success-path-pull-request" - post-target: pull-request + label: "Test Summary" script: | - console.log("✅ github-script-post-comment action executed in CI."); - return "Self-test successful."; \ No newline at end of file + let body = "## 🔒 Test Summary\n\n" + + "| Check | Status |\n" + + "|-------|--------|\n" + + "| Lint & Test | ${{ needs.lint-and-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + + "| Negative Test | ${{ needs.negative-tests.outputs.final_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; + + return body; \ No newline at end of file From 6ea2b75208ad566ba718c08f6d2d2422e7543165 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 14:49:38 +0100 Subject: [PATCH 02/22] corrected final-result to test for skipped steps --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2298b9..c2a278f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest outputs: # Define an output for the job - final_result: ${{ steps.verify-failure.conclusion }} + final_result: ${{ steps.verify-failure.conclusion }} && ${{ steps.verify-not-failure.conclusion }} steps: - name: Test Case 4 - Composite Action - No Return uses: ./ @@ -99,6 +99,7 @@ jobs: echo "✅ All expected negative tests failed as anticipated." - name: Fail job if any expected failure did NOT occur + id: verify-not-failure if: steps.test-no-return.outcome != 'failure' || steps.test-return-non-string.outcome != 'failure' run: | echo "❌ One or more expected negative tests did not fail." From 14ff134e64b59736dc07ff348007a7f930b27c77 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 14:50:11 +0100 Subject: [PATCH 03/22] added missing checkout step --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2a278f..c2ecd1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,9 @@ jobs: # Define an output for the job final_result: ${{ steps.verify-failure.conclusion }} && ${{ steps.verify-not-failure.conclusion }} steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Test Case 4 - Composite Action - No Return uses: ./ id: test-no-return From 2ba1ce39d74242487803f7979b5b0f3fdf6780ee Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 14:53:52 +0100 Subject: [PATCH 04/22] corrected final result logic --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2ecd1e..3615571 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest outputs: # Define an output for the job - final_result: ${{ steps.verify-failure.conclusion }} && ${{ steps.verify-not-failure.conclusion }} + final_result: ${{ steps.verify-failure.conclusion == 'success' && steps.verify-not-failure.conclusion != 'success'}} steps: - name: Checkout Code uses: actions/checkout@v4 From d61f981fac8a244e70f660fd847eac5b48d8e915 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:09:35 +0100 Subject: [PATCH 05/22] reverted to testing --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5e2971c..7711c26 100644 --- a/action.yml +++ b/action.yml @@ -143,7 +143,7 @@ runs: console.error(`❌ Error processing ${{ inputs.label }} results:`, error); // Detect when user forgot to return a value (causing body = undefined) - if (error.status === 'ERR_INVALID_ARG_TYPE' && /The "data" argument must be of type string/i.test(error.message)) { + if (error.code === 'ERR_INVALID_ARG_TYPE' && /The "data" argument must be of type string/i.test(error.message)) { console.error(`💡 Hint: Your script returned a non-string value (e.g., object, array, or undefined) — or nothing at all.\n` + `Please return a string, or serialize your result using JSON.stringify.\n\n` + `For example:\n\n` From fb5ffa9eed45b0684c85fa02925ad3c63e0c1bdb Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:16:07 +0100 Subject: [PATCH 06/22] added outcome step --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3615571..fd020ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,6 +108,13 @@ jobs: echo "❌ One or more expected negative tests did not fail." exit 1 + - name: Job Outcome + id: negative-tests-outcome + if: always() + run: | + echo "steps.verify-failure.conclusion = ${{ steps.verify-failure.conclusion }}" + echo "steps.verify-not-failure.conclusion = ${{steps.verify-not-failure.conclusion }}" + test-summary: name: Test Summary runs-on: ubuntu-latest From 21e4ea834d2d044c9035752b695af56404d8ff51 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:19:52 +0100 Subject: [PATCH 07/22] switched to test outcomes --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd020ab..701b189 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,8 +112,8 @@ jobs: id: negative-tests-outcome if: always() run: | - echo "steps.verify-failure.conclusion = ${{ steps.verify-failure.conclusion }}" - echo "steps.verify-not-failure.conclusion = ${{steps.verify-not-failure.conclusion }}" + echo "steps.test-no-return.outcome = ${{ steps.test-no-return.outcome }}" + echo "steps.test-return-non-string.outcome = ${{ steps.test-return-non-string.outcome }}" test-summary: name: Test Summary From 2817f69345af02d0745e8e003003bd9708dc7d4a Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:21:44 +0100 Subject: [PATCH 08/22] Debugging test case logic --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 701b189..0044ca7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,7 @@ jobs: script: | console.log("Test Case 2 - Composite Action - No Return"); console.log("Expect error: script does not return string."); + return "true"; - name: Test Case 5 - Composite Action - Return Non-String uses: ./ From 9224e48303fa297f43410213b20689b12dffab2e Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:26:41 +0100 Subject: [PATCH 09/22] adjusted test outcome logic --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0044ca7..f296a5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,7 +69,7 @@ jobs: runs-on: ubuntu-latest outputs: # Define an output for the job - final_result: ${{ steps.verify-failure.conclusion == 'success' && steps.verify-not-failure.conclusion != 'success'}} + test_result: ${{ steps.negative-tests-outcome.outcome }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -116,6 +116,13 @@ jobs: echo "steps.test-no-return.outcome = ${{ steps.test-no-return.outcome }}" echo "steps.test-return-non-string.outcome = ${{ steps.test-return-non-string.outcome }}" + if(steps.test-no-return.outcome == 'failure' && steps.test-return-non-string.outcome == 'failure'){ + echo "✅ All negative tests failed as expected." + } else { + echo "❌ One or more expected negative tests did not fail." + exit 1 + } + test-summary: name: Test Summary runs-on: ubuntu-latest @@ -134,6 +141,6 @@ jobs: + "| Check | Status |\n" + "|-------|--------|\n" + "| Lint & Test | ${{ needs.lint-and-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" - + "| Negative Test | ${{ needs.negative-tests.outputs.final_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; + + "| Negative Test | ${{ needs.negative-tests.outputs.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; return body; \ No newline at end of file From d86b2ac112ebec7d7dfa79dd0bff5140389cdd8f Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:33:35 +0100 Subject: [PATCH 10/22] corrected invalid Bash script --- .github/workflows/ci.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f296a5e..6a1e5fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,19 +96,6 @@ jobs: console.log("Expect error: script returns non-string."); return {title: "Test Case 3", message: "test case return non-string", score: 50}; - - name: Verify both expected failures occurred - id: verify-failure - if: steps.test-no-return.outcome == 'failure' && steps.test-return-non-string.outcome == 'failure' - run: | - echo "✅ All expected negative tests failed as anticipated." - - - name: Fail job if any expected failure did NOT occur - id: verify-not-failure - if: steps.test-no-return.outcome != 'failure' || steps.test-return-non-string.outcome != 'failure' - run: | - echo "❌ One or more expected negative tests did not fail." - exit 1 - - name: Job Outcome id: negative-tests-outcome if: always() @@ -116,12 +103,12 @@ jobs: echo "steps.test-no-return.outcome = ${{ steps.test-no-return.outcome }}" echo "steps.test-return-non-string.outcome = ${{ steps.test-return-non-string.outcome }}" - if(steps.test-no-return.outcome == 'failure' && steps.test-return-non-string.outcome == 'failure'){ + if [[ "${{ steps.test-no-return.outcome }}" == "failure" && "${{ steps.test-return-non-string.outcome }}" == "failure" ]]; then echo "✅ All negative tests failed as expected." - } else { + else echo "❌ One or more expected negative tests did not fail." exit 1 - } + fi test-summary: name: Test Summary From 233ffea6aafb6a2b82966c2073f4231da1e84cc1 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:38:07 +0100 Subject: [PATCH 11/22] removed debugging; Adjust output to be more readable --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a1e5fa..98b60b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ permissions: jobs: lint-and-test: + name: Lint and Test runs-on: ubuntu-latest steps: - name: Checkout Code @@ -68,7 +69,6 @@ jobs: name: Negative Test - Expected to Fail runs-on: ubuntu-latest outputs: - # Define an output for the job test_result: ${{ steps.negative-tests-outcome.outcome }} steps: - name: Checkout Code @@ -83,7 +83,6 @@ jobs: script: | console.log("Test Case 2 - Composite Action - No Return"); console.log("Expect error: script does not return string."); - return "true"; - name: Test Case 5 - Composite Action - Return Non-String uses: ./ @@ -106,7 +105,7 @@ jobs: if [[ "${{ steps.test-no-return.outcome }}" == "failure" && "${{ steps.test-return-non-string.outcome }}" == "failure" ]]; then echo "✅ All negative tests failed as expected." else - echo "❌ One or more expected negative tests did not fail." + echo "❌ One or more negative tests did not fail as expected." exit 1 fi From 45015aa62694a23d0468602c1307007a6c590ead Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:44:21 +0100 Subject: [PATCH 12/22] change test summary icon; write negative test outcome to GITHUB_STEP_SUMMARY --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98b60b8..f2d7dd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,8 +104,10 @@ jobs: if [[ "${{ steps.test-no-return.outcome }}" == "failure" && "${{ steps.test-return-non-string.outcome }}" == "failure" ]]; then echo "✅ All negative tests failed as expected." + echo "✅ All negative tests failed as expected." >> $GITHUB_STEP_SUMMARY else echo "❌ One or more negative tests did not fail as expected." + echo "❌ One or more negative tests did not fail as expected." >> $GITHUB_STEP_SUMMARY exit 1 fi @@ -123,7 +125,7 @@ jobs: with: label: "Test Summary" script: | - let body = "## 🔒 Test Summary\n\n" + let body = "## 🧪 Test Summary\n\n" + "| Check | Status |\n" + "|-------|--------|\n" + "| Lint & Test | ${{ needs.lint-and-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" From 1acd72d5fd1304b4500a56637676ee22e3c836f1 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 16:48:10 +0100 Subject: [PATCH 13/22] debugging failure of positive test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2d7dd2..fe25cee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: post-target: github-step-summary script: | console.log("✅ github-script-post-comment action executed in CI."); - return "✅ Test Case 2 - Composite Action - Success Path with github-step-summary."; + return {ID: 1, MESSAGE: "✅ Test Case 2 - Composite Action - Success Path with github-step-summary."}; - name: Test Case 3 - Composite Action - Success Path with pull-request uses: ./ From ad0a2096ede538a98dd58535e4e8161b6716d05d Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:20:35 +0100 Subject: [PATCH 14/22] Added more grainular results --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe25cee..5a165a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,15 @@ jobs: lint-and-test: name: Lint and Test runs-on: ubuntu-latest + outputs: + test_result: ${{ steps.lint-and-test-outcome.outcome }} + lint_result: ${{ steps.negative-tests-outcome.outcome }} steps: - name: Checkout Code uses: actions/checkout@v4 - name: Validate action.yml Metadata + id: validate-action-yml run: | yq eval '.' action.yml > /dev/null @@ -39,6 +43,7 @@ jobs: path: 'final_script.js' - name: Lint Embedded JavaScript and project files + id: lint-check env: NODE_ENV: development run: | @@ -64,6 +69,35 @@ jobs: script: | console.log("✅ github-script-post-comment action executed in CI."); return "✅ Test Case 3 - Composite Action - Success Path with pull-request."; + - name: Lint Outcome + id: lint-outcome + if: always() + run: | + echo "steps.validate-action-yml.outcome = ${{ steps.validate-action-yml.outcome }}" + echo "steps.lint-check.outcome = ${{ steps.lint-check.outcome }}" + + if [[ "${{ steps.validate-action-yml.outcome }}" == "success" && "${{ steps.lint-check.outcome }}" == "success" ]]; then + echo "✅ Linting passed." + echo "✅ Linting passed." >> $GITHUB_STEP_SUMMARY + else + echo "❌ One or more lint rules failed." + echo "❌ One or more lint rules failed." >> $GITHUB_STEP_SUMMARYs + fi + - name: Job Outcome + id: positive-test-outcome + if: always() + run: | + echo "steps.test-success-path-defaults.outcome = ${{ steps.test-success-path-defaults.outcome }}" + echo "steps.test-success-path-github-step-summary.outcome = ${{ steps.test-success-path-github-step-summary.outcome }}" + echo "steps.test-success-path-pull-request.outcome = ${{ steps.test-success-path-pull-request.outcome }}" + + if [[ "${{ steps.test-success-path-defaults.outcome }}" == "success" && "${{ steps.test-success-path-github-step-summary.outcome }}" == "success" && "${{ steps.test-success-path-pull-request.outcome }}" == "success" ]]; then + echo "✅ All positive tests passed." + echo "✅ All positive tests passed." >> $GITHUB_STEP_SUMMARY + else + echo "❌ One or more positive tests failed." + echo "❌ One or more positive tests failed." >> $GITHUB_STEP_SUMMARY + fi negative-tests: name: Negative Test - Expected to Fail @@ -128,7 +162,8 @@ jobs: let body = "## 🧪 Test Summary\n\n" + "| Check | Status |\n" + "|-------|--------|\n" - + "| Lint & Test | ${{ needs.lint-and-test.result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" - + "| Negative Test | ${{ needs.negative-tests.outputs.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; + + "| Lint Rules | ${{ needs.lint-and-test.lint_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + + "| Positive Tests | ${{ needs.lint-and-test.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + + "| Negative Tests | ${{ needs.negative-tests.outputs.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; return body; \ No newline at end of file From 7dcc4546499b05f218e34fdc94be853628028d3b Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:24:48 +0100 Subject: [PATCH 15/22] corrected ouputs assignments --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a165a3..f0bf178 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,11 @@ permissions: jobs: lint-and-test: - name: Lint and Test + name: Lint and Positive Tests runs-on: ubuntu-latest outputs: - test_result: ${{ steps.lint-and-test-outcome.outcome }} - lint_result: ${{ steps.negative-tests-outcome.outcome }} + test_result: ${{ steps.positive-test-outcome.outcome }} + lint_result: ${{ steps.lint-outcome.outcome }} steps: - name: Checkout Code uses: actions/checkout@v4 @@ -100,7 +100,7 @@ jobs: fi negative-tests: - name: Negative Test - Expected to Fail + name: Negative Tests - Expected to Fail runs-on: ubuntu-latest outputs: test_result: ${{ steps.negative-tests-outcome.outcome }} From af04859ca3668ddc874857a158a04fa6a6551f90 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:27:33 +0100 Subject: [PATCH 16/22] corrected ouputs assignments use --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0bf178..9123dee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ permissions: jobs: lint-and-test: - name: Lint and Positive Tests + name: Linting and Positive Tests runs-on: ubuntu-latest outputs: test_result: ${{ steps.positive-test-outcome.outcome }} @@ -162,8 +162,8 @@ jobs: let body = "## 🧪 Test Summary\n\n" + "| Check | Status |\n" + "|-------|--------|\n" - + "| Lint Rules | ${{ needs.lint-and-test.lint_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" - + "| Positive Tests | ${{ needs.lint-and-test.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + + "| Lint Rules | ${{ needs.lint-and-test.outputs.lint_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + + "| Positive Tests | ${{ needs.lint-and-test.outputs.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n" + "| Negative Tests | ${{ needs.negative-tests.outputs.test_result == 'success' && '✅ Passed' || '❌ Failed' }} |\n\n"; return body; \ No newline at end of file From a602b56ba42e9fbbff8dfffddae768ca42088e40 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:29:13 +0100 Subject: [PATCH 17/22] added exit fail --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9123dee..2acd170 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,8 @@ jobs: echo "✅ Linting passed." >> $GITHUB_STEP_SUMMARY else echo "❌ One or more lint rules failed." - echo "❌ One or more lint rules failed." >> $GITHUB_STEP_SUMMARYs + echo "❌ One or more lint rules failed." >> $GITHUB_STEP_SUMMARY + exit 1 fi - name: Job Outcome id: positive-test-outcome @@ -97,6 +98,7 @@ jobs: else echo "❌ One or more positive tests failed." echo "❌ One or more positive tests failed." >> $GITHUB_STEP_SUMMARY + exit 1 fi negative-tests: From af1acfe2c2713224cd734dd099004aad2a73bb9f Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:40:58 +0100 Subject: [PATCH 18/22] added body type validation check --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 7711c26..9b22720 100644 --- a/action.yml +++ b/action.yml @@ -113,6 +113,14 @@ runs: // Store the result as an output for downstream steps core.setOutput('result', JSON.stringify(body)); + // Validate that the returned body is a string + if (typeof body !== 'string') { + throw new TypeError( + `Returned value from user script must be a string. Received type '${typeof body}'. ` + + `Please return a string, or serialize your result using JSON.stringify.` + ); + } + // Output to GITHUB_STEP_SUMMARY if (postTarget === 'both' || postTarget === 'github-step-summary') { const summaryPath = process.env.GITHUB_STEP_SUMMARY; From 7f382df39b3ae27e213224796398037cb7c7ddf0 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:45:06 +0100 Subject: [PATCH 19/22] fixed linting errors --- action.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 9b22720..b41afc9 100644 --- a/action.yml +++ b/action.yml @@ -115,10 +115,8 @@ runs: // Validate that the returned body is a string if (typeof body !== 'string') { - throw new TypeError( - `Returned value from user script must be a string. Received type '${typeof body}'. ` + - `Please return a string, or serialize your result using JSON.stringify.` - ); + throw new TypeError(`Returned value from user script must be a string. Received type '${typeof body}'. ` + + `Please return a string, or serialize your result using JSON.stringify.`); } // Output to GITHUB_STEP_SUMMARY From 4952c34dcd18c811301fa0971f0388ab83d5f132 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:51:28 +0100 Subject: [PATCH 20/22] adjust exception handling for new exception; added clear messages --- .github/workflows/ci.yml | 4 ++-- action.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2acd170..d37539b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,8 @@ jobs: echo "✅ All positive tests passed." echo "✅ All positive tests passed." >> $GITHUB_STEP_SUMMARY else - echo "❌ One or more positive tests failed." - echo "❌ One or more positive tests failed." >> $GITHUB_STEP_SUMMARY + echo "❌ One or more positive tests failed or did not run." + echo "❌ One or more positive tests failed or did not run." >> $GITHUB_STEP_SUMMARY exit 1 fi diff --git a/action.yml b/action.yml index b41afc9..33b0578 100644 --- a/action.yml +++ b/action.yml @@ -149,7 +149,7 @@ runs: console.error(`❌ Error processing ${{ inputs.label }} results:`, error); // Detect when user forgot to return a value (causing body = undefined) - if (error.code === 'ERR_INVALID_ARG_TYPE' && /The "data" argument must be of type string/i.test(error.message)) { + if (error instanceof TypeError && /Returned value from user script must be a string/i.test(error.message)) { console.error(`💡 Hint: Your script returned a non-string value (e.g., object, array, or undefined) — or nothing at all.\n` + `Please return a string, or serialize your result using JSON.stringify.\n\n` + `For example:\n\n` From c4d337c805ea9a3b3a44bce3f7aef0c0d5f9d2bc Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 17:59:10 +0100 Subject: [PATCH 21/22] removed redundant message; incremented version --- action.yml | 3 +-- package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 33b0578..fa76ff3 100644 --- a/action.yml +++ b/action.yml @@ -115,8 +115,7 @@ runs: // Validate that the returned body is a string if (typeof body !== 'string') { - throw new TypeError(`Returned value from user script must be a string. Received type '${typeof body}'. ` - + `Please return a string, or serialize your result using JSON.stringify.`); + throw new TypeError(`Returned value from user script must be a string. Received type '${typeof body}'. `); } // Output to GITHUB_STEP_SUMMARY diff --git a/package.json b/package.json index 85ab168..3e5eaa8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aguilita1/github-script-post-comment", - "version": "1.1.2", + "version": "1.1.3", "description": "GitHub Action to run custom JavaScript and post results to GitHub summary and Pull Request", "author": "Daniel I. Kelley", "license": "MIT", From c89b554f83555ddc538fbf28194f650deadc2915 Mon Sep 17 00:00:00 2001 From: "Daniel I. Kelley" Date: Sat, 25 Oct 2025 19:01:26 +0100 Subject: [PATCH 22/22] reverted debugging; added dependabot --- .github/dependabot.yml | 10 ++++++++++ .github/workflows/ci.yml | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e8756e2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'weekly' + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'weekly' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d37539b..7106f52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: post-target: github-step-summary script: | console.log("✅ github-script-post-comment action executed in CI."); - return {ID: 1, MESSAGE: "✅ Test Case 2 - Composite Action - Success Path with github-step-summary."}; + return "✅ Test Case 2 - Composite Action - Success Path with github-step-summary."; - name: Test Case 3 - Composite Action - Success Path with pull-request uses: ./