some small refactoring (#23) #78
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |