-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.93 KB
/
build.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
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build & Test 🧪
# Dynamically set the run name to include the type of branch (feature or bugfix), branch name, and the user
run-name: "${{ contains(github.head_ref, 'feature/') && 'Feature' || contains(github.head_ref, 'bugfix/') && 'Bugfix' || 'Update' }}: ${{ github.head_ref }} by @${{ github.actor }} run #${{ github.run_number }} attempt #${{ github.run_attempt }}"
on:
push:
branches:
- main
- feature/**
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'docs/**'
- '.editorconfig'
- '.gitignore'
- '.gitattributes'
- '.vscode/**'
- '.dockerignore'
pull_request:
branches:
- main
paths-ignore:
- 'README.md'
- 'LICENSE'
- 'docs/**'
- '.editorconfig'
- '.gitignore'
- '.gitattributes'
- '.vscode/**'
- '.dockerignore'
env:
DOTNET_VERSION: '8.0.x'
BUILD_CONFIGURATION: 'Release'
jobs:
build:
name: 'Build & Test'
runs-on: ubuntu-latest
steps:
- name: 📂 Check out the code
uses: actions/checkout@v4
- name: 📦 Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: 🎒 Restore dependencies
run: dotnet restore
- name: 🛠️ Build
run: dotnet build --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: 🧪 Test
run: |
echo "## ❔ Test results" >> $GITHUB_STEP_SUMMARY
dotnet test --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' test/learning-fast-endpoints-tests -- RunConfiguration.CollectSourceInformation=true
- name: 📝 Code Coverage Report
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.1.23
reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub "-filefilters:-*.g.cs;-*.gen.cs" -verbosity:Warning
sed -i 's/# Summary/## 📝 Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
sed -i 's/## Coverage/### Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY
- name: 📝 Publish coverage report to coveralls.io
uses: coverallsapp/github-action@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
file: ${{github.workspace}}/coverage.cobertura.xml