-
-
Notifications
You must be signed in to change notification settings - Fork 18
88 lines (75 loc) · 2.35 KB
/
frameworkTesting.yml
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
name: frameworkTesting
run-name: Test Converters
on:
push:
branches:
- main
- feature/*
paths:
- "src/**"
pull_request:
branches:
- main
paths:
- "src/**"
- ".github/workflows/**" #remove later
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20'
- run: npm install
- run: npm run test
# - name: Convert code coverage results for summary
# uses: irongut/[email protected]
# with:
# filename: coverage/*.xml
# badge: true
# format: 'markdown'
# output: 'file'
# - name: Add code coverage PR comment
# uses: marocchino/sticky-pull-request-comment@v2
# if: github.event_name == 'pull_request'
# with:
# recreate: true
# path: code-coverage-results.md
# - name: Write to job summary
# run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Convert code coverage results for badge
uses: irongut/[email protected]
with:
filename: coverage/*.xml
hide_branch_rate: true
hide_complexity: true
badge: true
output: 'file'
#https://img.shields.io/badge/Code%20Coverage-80%25-success?style=flat
#https://img.shields.io/badge/Code%20Coverage-40%25-critical?style=flat
#green=44cc11
#orange=e05d44
- name: Extract code coverage badge
run: |
read -r line < code-coverage-results.txt
coverage=$(echo "$line" | sed -n 's/.*Code%20Coverage-\([0-9]*\)%.*/\1/p')
condition=$(echo "$line" | sed -n 's/.*%25-\([a-z]*\)?.*/\1/p')
[[ $condition == "critical" ]] && color="#e05d44" || color="#44cc11"
cat <<EOF > cov.json
{
"schemaVersion": 1,
"label": "Code Coverage",
"message": "$coverage",
"style": "for-the-badge",
"color": "$color"
}
- name: Publish code coverage badge
uses: exuanbo/actions-deploy-gist@v1
with:
token: ${{ secrets.GIST_SECRET }}
gist_id: dd5dc24ffa62de59b3d836f856f48a10
file_path: cov.json