-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (56 loc) · 2.17 KB
/
test-report.yaml
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
name: Tests
on:
workflow_dispatch:
push:
branches: [ "master" ]
paths-ignore:
- '.github/**'
- 'doc/**'
pull_request:
branches: [ "master" ]
paths-ignore:
- '.github/**'
- 'doc/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: restore
working-directory: ./src
run: dotnet restore
- name: test
working-directory: ./src
run: dotnet test --logger "trx;LogFileName=test-results.trx" || true
- name: create test report
uses: dorny/test-reporter@v1
id: test_report
if: github.ref == 'refs/heads/master' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'
with:
name: Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
- name: update test badge in README.md
if: github.ref == 'refs/heads/master' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
echo "Adding test report to README.md file..."
test_report_url=$(echo ${{ toJson(steps.test_report.outputs.url_html) }} | sed 's/\//\\\//g')
workflow_file=$(echo ${{ github.workflow_ref }} | sed 's/.*\/\(.*\)@.*/\1/')
badge_url=$(echo "${{ github.server_url }}/${{ github.repository }}/actions/workflows/$workflow_file/badge.svg" | sed 's/\//\\\//g')
echo "Badge URL: ${{ github.server_url }}/${{ github.repository }}/actions/workflows/$workflow_file/badge.svg"
echo "Report URL: ${{ toJson(steps.test_report.outputs.url_html) }}"
sed -i '2s/.*/[![${{ github.workflow }}]('"$badge_url"')]('"$test_report_url"')/' README.md
- name: commit changes
uses: EndBug/add-and-commit@v9
if: github.ref == 'refs/heads/master' && github.event_name == 'push' || github.event_name == 'workflow_dispatch'
with:
add: README.md
message: 'update test badge in README.md'
default_author: github_actions
fetch: false