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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,68 @@ jobs:
name: packages
path: ./artifacts/*.nupkg

# Test coverage, uploaded to Codacy (OPS-157454).
# pdl-public, never a GitHub-hosted runner and never pdl-prod-cluster: this repository is public,
# so a fork pull request is untrusted code, and pdl-public is the hardened scale set that may run
# it (no dind, no privileged container, no hostPath, nothing shared between jobs).
coverage:
runs-on: [pdl-public]

env:
DOTNET_NOLOGO: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
# The actions-runner image does not offer the Node version several of these actions request
# by default; without this they fail before their first step runs.
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.

- name: Setup .NET
uses: actions/setup-dotnet@v6
# The runner user cannot write /usr/share/dotnet, so install the SDK somewhere it can.
env:
DOTNET_INSTALL_DIR: ${{ runner.temp }}/dotnet
with:
dotnet-version: 10.0.x

- name: Build tests
run: dotnet build PanoramicData.ChartMagic.Test/PanoramicData.ChartMagic.Test.csproj --configuration Debug

# The test project is a Microsoft.Testing.Platform application, so coverage is collected by
# running the test executable directly (Microsoft.Testing.Extensions.CodeCoverage) rather than
# through `dotnet test`. On Linux the executable has no .exe extension.
#
# Every test in this repository runs offline with no credentials, so no filter is applied.
- name: Run tests with coverage
run: >-
./PanoramicData.ChartMagic.Test/bin/Debug/net10.0/PanoramicData.ChartMagic.Test
--coverage
--coverage-settings "$GITHUB_WORKSPACE/coverage.config"
--coverage-output-format cobertura
--coverage-output coverage.cobertura.xml

# continue-on-error: a Codacy outage must not turn a passing test run red. The trade-off is that
# an expired or missing project token fails silently, so check the log for
# "Coverage received successfully" when in doubt.
- name: Upload coverage to Codacy
continue-on-error: true
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: PanoramicData.ChartMagic.Test/bin/Debug/net10.0/TestResults/coverage.cobertura.xml

- name: Upload coverage artifact
if: always()
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: coverage
path: PanoramicData.ChartMagic.Test/bin/Debug/net10.0/TestResults/coverage.cobertura.xml
retention-days: 7

publish:
needs: build
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<AnalysisLevel>latest-recommended</AnalysisLevel>
Expand Down
33 changes: 33 additions & 0 deletions coverage.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Microsoft.Testing.Extensions.CodeCoverage settings.

The attribute exclusions are not optional if figures are to stay comparable across the estate: the
Microsoft collector includes generated code by default, where coverlet excluded it. Porting them is
worth several points of apparent coverage on a repository with generated clients.
-->
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*Test\.dll$</ModulePath>
<ModulePath>.*Tests\.dll$</ModulePath>
</Exclude>
</ModulePaths>
<Attributes>
<Exclude>
<Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^System\.Runtime\.CompilerServices\.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
<Attribute>^System\.ObsoleteAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\obj\\.*</Source>
</Exclude>
</Sources>
<UseVerifiableInstrumentation>False</UseVerifiableInstrumentation>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
</CodeCoverage>
</Configuration>
Loading