-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 2.89 KB
/
test.yml
File metadata and controls
100 lines (82 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Test Package
on:
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
test:
name: Vitest (Test Package)
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout Repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js and pnpm
uses: ./.github/common/setup-node-pnpm
- name: Test ESLint Config
id: eslint
run: pnpm run build:eslint && pnpm run test --project eslint-config
- name: Test Prettier Config
id: prettier
run: pnpm run build:prettier && pnpm run test --project prettier-config
- name: Test Stylelint Config
id: stylelint
run: pnpm run build:stylelint && pnpm run test --project stylelint-config
- name: Comment if success
run: |
# Create a comment body
cat << EOF > COMMENT.md
## ✅ Snapshot test success
See the details: [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
EOF
- name: Comment if any Error
if: ${{ always() && (steps.eslint.outcome == 'failure' || steps.prettier.outcome == 'failure' || steps.stylelint.outcome == 'failure') }}
run: |
# Create a comment body
cat << EOF > COMMENT.md
## 🚨 Snapshot test failed
See the details: [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
### Errors
EOF
# Append the error message to the comment body
if [ ${{ steps.eslint.outcome }} == 'failure' ]; then
echo "- ESLint" >> COMMENT.md
fi
if [ ${{ steps.prettier.outcome }} == 'failure' ]; then
echo "- Prettier" >> COMMENT.md
fi
if [ ${{ steps.stylelint.outcome }} == 'failure' ]; then
echo "- Stylelint" >> COMMENT.md
fi
# Append the next steps to the comment body
cat << EOF >> COMMENT.md
---
### ⏭️ Next Steps
If snapshot changes are...
**expected**: update the snapshots by adding \`update-snapshot\` label
**unexpected**: check diff and fix rules
EOF
- name: Comment to PR
if: always()
run: |
if [ ! -f COMMENT.md ]; then
echo "::warning::comment body not found."
exit 0
fi
gh pr comment ${{ github.event.number }} --body-file COMMENT.md --edit-last \
|| gh pr comment ${{ github.event.number }} --body-file COMMENT.md
env:
GH_TOKEN: ${{ github.token }}