Bump dotnet-reportgenerator-globaltool from 5.2.4 to 5.2.5 in /src/ba… #63
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: "Backend CI" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- dev | |
tags: | |
- "v*" | |
paths: | |
- "src/backend/**" | |
- "tests/backend/**" | |
pull_request: | |
branches: | |
- main | |
- test | |
- dev | |
paths: | |
- "src/backend/**" | |
- "tests/backend/**" | |
- ".github/workflows/backend-ci.yml" | |
types: [opened, reopened, labeled, synchronize, ready_for_review] | |
# Sets permissions of the GITHUB_TOKEN to allow creating checks and updating PR | |
permissions: | |
contents: read | |
checks: write | |
pull-requests: write | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | |
cancel-in-progress: true | |
env: | |
DOTNET_VERSION: "8.0.x" | |
BACKEND_SOLUTION_PATH: "src/backend" | |
WORKFLOW_SHORT_NAME: "backend-ci" | |
WORKFLOW_AGENT_PATH: "/home/runner/work/test/test/" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.draft == false }} | |
defaults: | |
run: | |
working-directory: ${{ env.BACKEND_SOLUTION_PATH }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # used by GitVersion to find the most recent tag outside of this branch | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- uses: actions/cache@v4 | |
id: nuget-cache | |
with: | |
path: ~/.nuget/packages | |
key: nuget-${{ hashFiles('**/packages.lock.json') }} | |
- name: dotnet restore | |
run: dotnet restore --locked-mode | |
- name: dotnet tool restore | |
run: dotnet tool restore | |
- name: Build | |
id: dotnet-build | |
run: | | |
dotnet build -c Release --no-restore --nologo -consoleLoggerParameters:NoSummary -verbosity:quiet 1>build.out 2>&1 || (exit 0) | |
grep "): error " build.out > build.err || (exit 0) | |
if [ ! -s build.err ] | |
then | |
echo "## ✅ Build successful" > build.md | |
else | |
# Reformat error output as github error annotations | |
error_regex="(.+)\(([0-9]+),([0-9]+)\): error (.+) \[(.+)\]" | |
# Capture groups: 1=file path 2=line 3=character 4=warn: message 5=project path | |
cat build.err | while read line | |
do | |
if [[ $line =~ $error_regex ]]; then | |
echo "::error file=${BASH_REMATCH[1]},line=${BASH_REMATCH[2]}::${BASH_REMATCH[4]}" | |
fi | |
done | |
cat build.err | sed 's|${{ env.WORKFLOW_AGENT_PATH }}|| ; s|${{ env.WORKFLOW_AGENT_PATH }}||' > build.md | |
sed -i '/^$/d' build.md # removes empty lines | |
sed -i -e 's/^/- ❌ /' build.md # prefix with markdown list item and cross mark emoji | |
echo "## ❌ The following build issues should be fixed:" | cat - build.md > build.md.temp && mv build.md.temp build.md | |
fi | |
echo "result<<EOF"$'\n'"$(cat build.md)"$'\n'EOF >> $GITHUB_OUTPUT | |
cat build.md >> $GITHUB_STEP_SUMMARY | |
if [ -s build.err ] | |
then | |
exit 1 | |
fi | |
- name: "Create or Update PR Comment" | |
uses: im-open/[email protected] | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-build-results" | |
comment-content: ${{ steps.dotnet-build.outputs.result }} | |
- name: WebApi Tests | |
run: dotnet test ../../tests/backend/WebApi.Tests --no-restore --collect:"XPlat Code Coverage" --logger "trx;LogFileName=test-results.trx" /p:CollectCoverage=true /p:CoverletOutput="../../tests/backend/WebApi.Tests/TestResults/" /p:CoverletOutputFormat=cobertura | |
- uses: dorny/test-reporter@v1 | |
with: | |
name: "WebApi Tests" | |
path: "tests/backend/WebApi.Tests/TestResults/test-results.trx" | |
reporter: dotnet-trx | |
fail-on-error: true | |
- name: Generate report for all tests | |
id: reportgenerator | |
run: | | |
dotnet reportgenerator -reports:"../../tests/backend/**/TestResults/**/coverage.cobertura.xml" -targetdir:"../../tests/backend/CoverageReport" -reporttypes:"Html;Cobertura;MarkdownSummaryGithub;Badges" | |
cat ../../tests/backend/CoverageReport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
echo "markdown<<EOF" >> $GITHUB_OUTPUT | |
cat ../../tests/backend/CoverageReport/SummaryGithub.md >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
# TODO: commit the badges for README.md | |
- name: "Create or Update PR Comment" | |
uses: im-open/[email protected] | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-reportgenerator" | |
comment-content: ${{ steps.reportgenerator.outputs.markdown }} | |
- name: Code Coverage Report | |
uses: irongut/[email protected] | |
with: | |
filename: "tests/backend/CoverageReport/Cobertura.xml" | |
badge: true | |
fail_below_min: false | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: true | |
indicators: true | |
output: both | |
thresholds: "60 80" | |
- name: Create output variable | |
id: code-coverage-summary | |
run: | | |
cat ../../code-coverage-results.md >> $GITHUB_STEP_SUMMARY | |
echo "markdown<<EOF" >> $GITHUB_OUTPUT | |
cat ../../code-coverage-results.md >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: "Create or Update PR Comment" | |
uses: im-open/[email protected] | |
if: ${{ always() && github.event_name == 'pull_request' }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
comment-identifier: "${{ env.WORKFLOW_SHORT_NAME }}-CodeCoverageSummary" | |
comment-content: ${{ steps.code-coverage-summary.outputs.markdown }} | |
- name: Inspect code | |
uses: muno92/resharper_inspectcode@v1 | |
if: ${{ github.event_name == 'pull_request' }} | |
with: | |
workingDirectory: ${{ env.BACKEND_SOLUTION_PATH }} | |
solutionPath: Backend.sln | |
dotnetVersion: ${{ env.DOTNET_VERSION }} | |
failOnIssue: false | |
include: | | |
**.cs |