chore: setup db test infrastructure #416
Workflow file for this run
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: Code test and analysis (fork) | |
on: | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize, reopened, ready_for_review] | |
jobs: | |
check-slns: | |
name: Check sln files | |
if: github.actor == 'dependabot[bot]' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
run_install: | | |
- cwd: .github/scripts | |
args: [--frozen-lockfile] | |
- args: [--global, tsx] | |
- name: Update all sln files | |
run: tsx ./.github/scripts/update-sln-files.mts | |
- name: Assert that no sln files have changed | |
run: git diff --exit-code | |
test: | |
if: github.actor == 'dependabot[bot]' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Restore dotnet workloads | |
run: dotnet workload restore | |
- name: dotnet build | |
run: dotnet build Altinn.Register.sln -v m | |
- name: dotnet test | |
run: dotnet test Altinn.Register.sln --results-directory TestResults/ --collect:"XPlat Code Coverage" -v m | |
- name: Generate coverage results | |
run: | | |
dotnet tool install --global dotnet-reportgenerator-globaltool | |
reportgenerator -reports:TestResults/**/coverage.cobertura.xml -targetdir:TestResults/Output/CoverageReport -reporttypes:Cobertura | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report | |
path: TestResults/Output/CoverageReport/ | |
code-coverage: | |
if: github.actor == 'dependabot[bot]' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) | |
name: Report code coverage | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Download Coverage Results | |
uses: actions/download-artifact@master | |
with: | |
name: code-coverage-report | |
path: dist/ | |
- name: Create Coverage Summary Report | |
uses: irongut/[email protected] | |
with: | |
filename: dist/Cobertura.xml | |
badge: true | |
fail_below_min: true | |
format: markdown | |
hide_branch_rate: false | |
hide_complexity: true | |
indicators: true | |
output: both | |
thresholds: "60 80" | |
# Step disabled until workaround available for commenting PR | |
# - name: Add Coverage PR Comment | |
# uses: marocchino/sticky-pull-request-comment@v2 | |
# with: | |
# recreate: true | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# path: code-coverage-results.md |