ci: add build & test action #18
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 Api Pull-request | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- backend/** | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore ./backend/src | |
- name: Build | |
run: dotnet build -c Release ./backend/src --no-restore | |
- name: Test | |
run: >- | |
dotnet test -c Release ./backend/src/tests/Equinor.ProjectExecutionPortal.Tests.WebApi | |
--no-restore --collect:"XPlat Code Coverage" --results-directory | |
coverage --verbosity normal --filter "Category!=LongRunning" | |
- name: Code Coverage Summary Report | |
uses: irongut/[email protected] | |
with: | |
filename: "coverage/*/coverage.cobertura.xml" | |
badge: true | |
format: "markdown" | |
output: "both" | |
- name: "Collect xUnit results for comment" | |
run: echo '## Workspace xUnit coverage' >> coverage.md && cat code-coverage-results.md >> coverage.md | |
- name: Add Coverage PR Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: github.event_name == 'pull_request' | |
with: | |
recreate: true | |
header: Workspace | |
path: coverage.md | |
- name: Write to Job Summary | |
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |