Skip to content

Commit

Permalink
test(flow): comments on failed
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed Aug 9, 2024
1 parent 1fb2b90 commit 4490b99
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/comment-on-failed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: Publish Check Results

on:

38 changes: 37 additions & 1 deletion .github/workflows/test-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,43 @@ jobs:
skip_builds: true
turborepo-server-port: ${{ steps.toolchain.outputs.port }}
- name: Run unit tests
run: pnpm desktop test:jest:coverage
id: run_tests
run: pnpm desktop test:jest:coverage --json --outputFile=test-results.json
- name: Parse test results
id: parse_results
run: |
failed_tests=$(jq '.testResults[] | select(.status == "failed") | .fullName' test-results.json)
succeeded_tests=$(jq '.testResults[] | select(.status == "passed") | .fullName')
echo "::set-output name=failed_tests::$failed_tests"
echo "::set-output name=succeeded_tests::$succeeded_tests"
- name: Comment on PR with test results
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const failedTests = `{{ steps.parse_results.outputs.failed_tests }}`.split('\n').filter(Boolean);
const succeededTests = `{{ steps.parse_results.outputs.succeeded_tests }}`.split('\n').filter(Boolean);
let body = '';
if (failedTests.length > 0) {
body += '### ❌ Failed Tests:\n';
body += failedTests.map(test => `- ${test}`).join('\n');
body += '\n\n';
} else {
body += '### ✅ All tests passed!\n\n';
}
if (succeededTests.length > 0) {
body += '### ✅ Succeeded Tests:\n';
body += succeededTests.map(test => `- ${test}`).join('\n');
}
github.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
e2e-tests-linux:
name: "Desktop Tests E2E (Ubuntu)"
Expand Down

0 comments on commit 4490b99

Please sign in to comment.