Merge pull request #17 from Enterwell/feature/azure-devops #41
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: CI | |
# Triggering the workflow on PRs and pushes to relevant branches | |
on: | |
pull_request: | |
branches: | |
- main | |
- feature/** | |
push: | |
branches: | |
- main | |
- stage | |
jobs: | |
test-starter: | |
name: Test starter | |
runs-on: ubuntu-latest | |
permissions: write-all | |
# PostgreSQL service container to run with the job | |
services: | |
postgres: | |
image: postgres:15 | |
env: | |
POSTGRES_PASSWORD: password | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
# Maps TCP port 5432 on service container to the host | |
ports: | |
- 5432:5432 | |
steps: | |
# Checkout | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Defining what SDK to use | |
- name: Use .NET 8.0.x | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
# Restoring solution packages | |
- name: Restore packages | |
run: dotnet restore Acme.sln | |
# Building the solution | |
- name: Solution build | |
run: dotnet build Acme.sln --configuration Release --no-restore | |
# Testing the solution | |
- name: Solution test | |
run: dotnet test Acme.sln --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage | |
# Combine code coverage reports into one | |
- name: Create code coverage reports | |
uses: danielpalme/[email protected] | |
with: | |
reports: ./coverage/**/coverage.cobertura.xml | |
targetDir: ./CodeCoverage | |
reporttypes: HtmlInline;Cobertura | |
assemblyfilters: -Enterwell*;-*Tests* | |
# Publishing the combined code coverage report | |
- name: Publish code coverage report | |
uses: irongut/[email protected] | |
with: | |
filename: ./CodeCoverage/Cobertura.xml | |
badge: true | |
format: markdown | |
output: both | |
# Coverage PR comment | |
- name: Add coverage PR comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: test-coverage | |
recreate: true | |
path: code-coverage-results.md |