Skip to content

Release / v0.12.1

Release / v0.12.1 #32

name: Regular Checks - Project
on:
pull_request:
branches:
- main
- 'epic/**'
paths:
- 'src/**/*'
- 'test/**/*'
- '.editorconfig'
- 'Directory.Build.props'
- 'Directory.Packages.props'
- 'Baked.sln'
env:
MIN_COVERAGE: 85
jobs:
# outputs matrix json so that windows is only added when head branch is a release branch
prepare:
name: Prepare
runs-on: ubuntu-latest
outputs:
matrix: ${{ env.MATRIX }}
env:
MATRIX: '{ "os": [ "ubuntu-latest" ] }'
COLON: ':'
steps:
- name: Windows
id: windows
if: startsWith(github.head_ref, 'release/') == true
run: echo "MATRIX={ \"os\"$COLON [ \"ubuntu-latest\", \"windows-latest\" ] }" >> $GITHUB_ENV
build:
name: Build
needs: Prepare
outputs:
matrix: ${{ needs.prepare.outputs.matrix }}
strategy:
max-parallel: 2
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
- name: Restore Dependencies
run: dotnet restore
- name: Format Solution
run: dotnet format --no-restore --verify-no-changes --verbosity diagnostic
- name: Build Solution
run: dotnet build --no-restore -c Release
test:
name: Test
needs: build
strategy:
max-parallel: 2
matrix: ${{ fromJson(needs.build.outputs.matrix) }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
- name: Test
if: ${{ matrix.os != 'ubuntu-latest' }}
run: dotnet test -c Release
- name: Test w/ Coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
# If a project is not listed in coverage report,
# use '-verbosity:diagnostic --diag:log.log' options
# to log collector warnings.
run: |
dotnet test -c Release \
--collect:"XPlat Code Coverage" \
--logger trx \
--results-directory .coverage \
--settings test/runsettings.xml
- name: Merge Multiple Test Coverage Report
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.0
with:
reports: '.coverage/*/coverage.cobertura.xml'
targetdir: 'coveragereport'
reporttypes: 'Cobertura'
- name: Code Coverage Summary Report
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coveragereport/Cobertura.xml
badge: true
format: 'markdown'
output: 'both'
- name: Upload Reports
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: code-coverage-results.md
coverage:
name: Coverage
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Reports
uses: actions/download-artifact@v4
with:
name: coverage-reports
- name: Write to Job Summary
run: |
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
- name: Checking Test Coverage Under Minimum Coverage
run: |
coverage=$(cat code-coverage-results.md | sed -n '/Code%20Coverage-/p' | sed '/[ a-zA-Z\/()=\.\?%\!]/ s///g' | sed 's/.\{3\}$//' | sed 's/^......//')
if test $(($coverage < ${{ env.MIN_COVERAGE }})) = 1
then
echo ! Coverage is below ${{ env.MIN_COVERAGE }}% ! >> $GITHUB_STEP_SUMMARY
exit 1
fi