-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
87 lines (76 loc) · 2.45 KB
/
action.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
name: 'Jest coverage report gha'
description: 'This action updates adds a unit test coverage SVG badge to your wiki'
branding:
color: blue
icon: award
inputs:
node_version:
description: Node version.
default: '18.x'
use_yarn:
description: Use Yarn
default: false
coverage_npm_script:
description: Npm command to generate coverage
default: 'test-coverage'
json_coverage_file:
description: json coverage report file to extract coverage % from
default: 'coverage/coverage-summary.json'
json_coverage_var:
description: Where in the json file to extract coverage % from
default: '.total.lines.pct'
runs:
using: "composite"
steps:
- name: Get repository name
shell: bash
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{inputs.node_version}}
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout wiki
uses: actions/checkout@v3
with:
repository: ${{github.repository}}.wiki
path: ./.github/wiki/
- name: Install yarn
shell: bash
if: inputs.use_yarn == 'true'
run: npm install -g yarn
- name: Install dependencies (yarn)
shell: bash
if: inputs.use_yarn == 'true'
run: yarn install
- name: Install dependencies (npm)
shell: bash
if: inputs.use_yarn != 'true'
run: npm install
- name: Generate coverage report
shell: bash
env:
USE_YARN: ${{inputs.use_yarn}}
COVERAGE_NPM_SCRIPT: ${{inputs.coverage_npm_script}}
JSON_COVERAGE_FILE: ${{inputs.json_coverage_file}}
JSON_COVERAGE_VAR: ${{inputs.json_coverage_var}}
REPO_NAME: ${{ env.REPOSITORY_NAME }}
run: |
${{github.action_path}}/coverage.sh
mv ${{github.action_path}}/coverage.svg ./.github/wiki/
cat ${{github.action_path}}/coverage.log >> ./.github/wiki/coverage.log
sort -u -o ./.github/wiki/coverage.log ./.github/wiki/coverage.log
- name: Push to wiki
shell: bash
run: |
cd ./.github/wiki/
git add --all
git diff-index --quiet HEAD && exit
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
git commit -m "Update coverage" && git push
- name: Uninstall yarn
shell: bash
if: always()
run: npm uninstall -g yarn