Skip to content

Commit df6ab06

Browse files
committed
Send test results to Slack
1 parent 4db5314 commit df6ab06

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

.github/workflows/update-tests-md.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,22 @@ jobs:
5353
uses: actions/upload-artifact@v3
5454
with:
5555
name: test-results-md
56-
path: ./tests/Tests.md
56+
path: ./tests/Tests.txt
57+
58+
- name: Read Tests.txt for Slack message
59+
id: read_tests
60+
run: |
61+
TESTS_CONTENT=$(cat ./tests/Tests.txt)
62+
echo "TESTS_CONTENT<<EOF" >> $GITHUB_ENV
63+
echo "$TESTS_CONTENT" >> $GITHUB_ENV
64+
echo "EOF" >> $GITHUB_ENV
65+
66+
- name: Notify Slack with test results
67+
uses: rtCamp/action-slack-notify@v2
68+
env:
69+
SLACK_COLOR: "#36a64f"
70+
SLACK_MESSAGE: |
71+
*Test Results:*
72+
${{ env.TESTS_CONTENT }}
73+
SLACK_TITLE: Test Results Update
74+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

tests/updateTestsMd.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@ const __dirname = path.dirname(__filename);
88

99
// Define paths for the results and markdown files
1010
const resultsPath = path.join(__dirname, 'results.json');
11-
const markdownPath = path.join(__dirname, 'Tests.md');
11+
const markdownPath = path.join(__dirname, 'Tests.txt');
1212

1313
// Read the Jest results
1414
fs.readFile(resultsPath, 'utf8')
1515
.then((data) => {
1616
const results = JSON.parse(data);
1717

18-
// Start constructing the Markdown table
19-
let markdownContent = `# Test Results\n\n`;
20-
markdownContent += `| Test Name | Status |\n`;
21-
markdownContent += `|-----------|--------|\n`;
22-
23-
// Iterate through each test result and populate the Markdown table
18+
// Iterate through each test result and populate the table
2419
results.testResults.forEach((test) => {
2520
const testName = test.assertionResults[0].fullName;
2621
const status = test.status === 'passed' ? '✅ Passed' : '❌ Failed';

0 commit comments

Comments
 (0)