From a1d3e5eda254bfaf65da728ba604d21fb9f862aa Mon Sep 17 00:00:00 2001 From: f-peverali <112709306+f-peverali@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:53:03 +0200 Subject: [PATCH] add output as comment --- .github/workflows/test_python_script.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_python_script.yml b/.github/workflows/test_python_script.yml index e5c5c32b..7b8c5b96 100644 --- a/.github/workflows/test_python_script.yml +++ b/.github/workflows/test_python_script.yml @@ -39,4 +39,20 @@ jobs: pip install coverage coverage run -m unittest discover -s scripts -p 'test*.py' coverage xml -o coverage/coverage.xml - coverage report \ No newline at end of file + coverage report + + + - name: Post test results as comment + if: always() + uses: actions/github-script@v4 + with: + script: | + const fs = require('fs'); + const results = fs.readFileSync('coverage/coverage.xml', 'utf8'); + const comment = `## Test Results\n\n\`\`\`xml\n${results}\n\`\`\``; + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); \ No newline at end of file