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 8a7cae6
Show file tree
Hide file tree
Showing 3 changed files with 42 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' src/apps/ledger-live-desktop/test-results.json)
succeeded_tests=$(jq '.testResults[] | select(.status == "passed") | .fullName' src/apps/ledger-live-desktop/test-results.json)
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
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/test-results.json

Large diffs are not rendered by default.

0 comments on commit 8a7cae6

Please sign in to comment.