Adding code coverage to tests in workflow #126
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: Build and Test | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
configuration: [Debug, Release] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: | | |
9.0.x | |
8.0.x | |
# Netfx testing on non-Windows requires mono | |
- name: Setup Mono | |
if: runner.os == 'Linux' | |
run: sudo apt-get install -y mono-devel | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies for tests | |
run: npm install @modelcontextprotocol/server-everything | |
- name: Install dependencies for tests | |
run: npm install @modelcontextprotocol/server-memory | |
- name: Build | |
run: dotnet build --configuration ${{ matrix.configuration }} | |
- name: Test | |
run: >- | |
dotnet test | |
--filter '(Execution!=Manual)' | |
--no-build | |
--configuration ${{ matrix.configuration }} | |
--logger "console;verbosity=normal" | |
--logger "trx" | |
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" | |
--blame | |
--blame-hang-timeout 7m | |
--blame-crash | |
--results-directory testresults | |
--collect "XPlat Code Coverage" | |
-- RunConfiguration.CollectSourceInformation=true | |
- name: Upload test results artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: testresults-${{ matrix.os }}-${{ matrix.configuration }} | |
path: testresults/** | |
publish-coverage: | |
if: github.actor != 'dependabot[bot]' | |
needs: build | |
uses: ./.github/workflows/code-coverage.yml | |
secrets: inherit |