Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.pdf binary
*.nupkg binary
*.snupkg binary
*.vsix binary
120 changes: 109 additions & 11 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
# This workflow will build a .NET project
# This workflow will build and test the .NET projects, and pack the NuGet packages
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
#
# The tests run on Microsoft Testing Platform (MTP): `dotnet test` is switched to MTP mode by the "test" section of
# global.json (the .NET 10 SDK is needed), and the reports (TRX, code coverage) are produced by MTP extensions.

name: .NET

permissions:
contents: read
pull-requests: write


on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
Expand All @@ -20,41 +30,129 @@ defaults:
jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" --settings .runsettings

# One target framework at a time. Every run keeps going when the one before it failed, so that all the failures show up,
# and the job still fails at the end. The reports go to TestResults/<framework> (at the root of the repository).
- name: Test (net8.0)
run: dotnet test --solution MDAT.slnx --no-build --framework net8.0 --results-directory ../TestResults/net8.0 --report-trx
- name: Test (net9.0)
if: ${{ !cancelled() }}
run: dotnet test --solution MDAT.slnx --no-build --framework net9.0 --results-directory ../TestResults/net9.0 --report-trx
- name: Test (net10.0)
if: ${{ !cancelled() && runner.os != 'Linux' }}
run: dotnet test --solution MDAT.slnx --no-build --framework net10.0 --results-directory ../TestResults/net10.0 --report-trx
- name: Test (net10.0, with code coverage)
if: ${{ !cancelled() && runner.os == 'Linux' }}
run: dotnet test --solution MDAT.slnx --no-build --framework net10.0 --results-directory ../TestResults/net10.0 --report-trx --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml

# The TRX reports of the Microsoft Testing Platform and the coverage, kept even when a test fails
- name: Upload test results
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.os }}
path: TestResults/**
if-no-files-found: error

- name: Code Coverage Report
if: runner.os == 'Linux'
uses: irongut/[email protected]
with:
filename: src/MDATTests/TestResults/**/coverage.cobertura.xml
filename: TestResults/net10.0/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 80'
# line rate / branch rate (measured: ~85% / ~75%)
thresholds: '80 70'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
if: runner.os == 'Linux' && github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

# Packages for review only: nothing is published from here
- name: Pack
if: runner.os == 'Linux'
run: dotnet pack MDAT.slnx -c Release -o ../artifacts
- name: Upload packages
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: nuget-packages
path: artifacts/*
if-no-files-found: error

# The files to download: the NuGet packages and the Visual Studio extension. Nothing goes to nuget.org from here.
# Every run keeps them as the "dist" artifact; a tag "v..." also attaches them to a GitHub release.
dist:
needs: build
runs-on: windows-latest
permissions:
contents: write
defaults:
run:
working-directory: .

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: Pack the NuGet packages
run: dotnet pack src/MDAT.slnx -c Release -o dist
# The extension is built for .NET Framework: MSBuild of Visual Studio (found with vswhere), not `dotnet build`.
# Only the actions of GitHub are used here: the organization may not allow the others.
- name: Build the Visual Studio extension
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = & $vswhere -latest -prerelease -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
& $msbuild src/MDAT.VisualStudio/MDAT.VisualStudio.csproj -restore -p:Configuration=Release -v:minimal
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Copy-Item src/MDAT.VisualStudio/bin/Release/net472/MDAT.VisualStudio.vsix dist/
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/*
if-no-files-found: error
- name: Attach to the GitHub release
if: startsWith(github.ref, 'refs/tags/v')
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
$options = @()
if ($env:GITHUB_REF_NAME.Contains('-')) { $options += '--prerelease' }
gh release create $env:GITHUB_REF_NAME (Get-ChildItem dist/*).FullName --title $env:GITHUB_REF_NAME --generate-notes @options
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
26 changes: 23 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/MDAT/MDAT.csproj",
"${workspaceFolder}/src/MDAT.Core/MDAT.Core.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -19,7 +19,7 @@
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/MDAT/MDAT.csproj",
"${workspaceFolder}/src/MDAT.Core/MDAT.Core.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -33,9 +33,29 @@
"watch",
"run",
"--project",
"${workspaceFolder}/src/MDAT/MDAT.csproj"
"${workspaceFolder}/src/MDAT.Core/MDAT.Core.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "Run MDAT tests (net8)",
"type": "shell",
"command": "dotnet",
"args": [
"run",
"--project",
"src/MDAT.Tests/MDAT.Tests.csproj",
"-f",
"net8.0"
],
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "test",
"isDefault": true
},
"problemMatcher": []
}
]
}
Loading
Loading