Skip to content

Commit 1b05f20

Browse files
committed
2 parents 7a1192a + ac375ee commit 1b05f20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1112
-647
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Run Jest Tests on PR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
jobs:
10+
test:
11+
name: Run Jest Tests
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
contents: read
16+
issues: write
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
27+
- name: Install Dependencies
28+
run: npm install
29+
30+
- name: Run Jest Tests
31+
id: jest
32+
run: |
33+
npm test -- --json --outputFile=jest-results.json || echo "TESTS_FAILED=true" >> $GITHUB_ENV
34+
35+
- name: Read Jest Results
36+
id: results
37+
run: |
38+
# Default TESTS_FAILED to false
39+
if [ -z "$TESTS_FAILED" ]; then
40+
TESTS_FAILED=false
41+
fi
42+
43+
# Set TESTS_PASSED properly
44+
if [ "$TESTS_FAILED" = "true" ]; then
45+
TESTS_PASSED=false
46+
echo "TESTS_PASSED=false" >> $GITHUB_ENV
47+
FAILED_TESTS=$(jq -r '[.testResults[] | select(.status == "failed") | .name] | map(split("/") | last) | join("\n")' jest-results.json)
48+
echo "FAILED_TESTS<<EOF" >> $GITHUB_ENV
49+
echo "$FAILED_TESTS" >> $GITHUB_ENV
50+
echo "EOF" >> $GITHUB_ENV
51+
else
52+
TESTS_PASSED=true
53+
echo "TESTS_PASSED=true" >> $GITHUB_ENV
54+
echo "FAILED_TESTS=None" >> $GITHUB_ENV
55+
fi
56+
57+
# Extract PR number
58+
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
59+
60+
# Generate a temporary file for the comment
61+
COMMENT_FILE=$(mktemp)
62+
63+
# Save variables to GITHUB_OUTPUT
64+
echo "TESTS_PASSED=$TESTS_PASSED" >> $GITHUB_ENV
65+
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
66+
echo "COMMENT_FILE=$COMMENT_FILE" >> $GITHUB_OUTPUT
67+
68+
# Generate content for the comment file
69+
{
70+
if [ "$TESTS_PASSED" = "true" ]; then
71+
echo "✅ All Jest tests passed! This PR is ready to merge."
72+
else
73+
echo "❌ Some Jest tests failed. Please check the logs and fix the issues before merging."
74+
echo ""
75+
echo "**Failed Tests:**"
76+
echo ""
77+
echo '```'
78+
echo "$FAILED_TESTS"
79+
echo '```'
80+
fi
81+
} > "$COMMENT_FILE"
82+
83+
- name: PR comment
84+
uses: thollander/actions-comment-pull-request@v3
85+
with:
86+
file-path: ${{ steps.results.outputs.COMMENT_FILE }}
87+
pr-number: ${{ steps.results.outputs.PR_NUMBER }}
88+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/weblate-sync.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)