Skip to content

**DO NOT MERGE** .NET 9 Testing #2942

**DO NOT MERGE** .NET 9 Testing

**DO NOT MERGE** .NET 9 Testing #2942

name: .NET Agent Unit Tests and Code Coverage
on:
push:
branches:
- main # runs after a completed PR to main
- feature/* # runs after a push to a feature branch
pull_request: # runs on a PR to any branch
workflow_dispatch: # allows for manual trigger
env:
DOTNET_NOLOGO: true
NR_DEV_BUILD_HOME: false
# only allow one instance of this workflow to be running per PR or branch, cancels any that are already running
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check-modified-files:
name: Check if source files were modified, skip remaining jobs if not
uses: ./.github/workflows/check_modified_files.yml
secrets: inherit
permissions:
contents: read
pull-requests: read
run-unit-tests:
name: Run Unit Tests
needs: check-modified-files
runs-on: windows-latest
# don't run this job if triggered by Dependabot, will cause all other jobs to be skipped as well
# run this job if non-workflow files were modified, or if triggered by a manual execution or by a push (not a PR)
if: github.actor != 'dependabot[bot]' && (needs.check-modified-files.outputs.non-workflow-files-changed == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'push')
env:
test_results_path: tests\TestResults
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Setup .NET 9 Preview
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
with:
dotnet-version: '9.0.x'
dotnet-quality: 'preview'
- name: Restore NuGet Packages
run: dotnet restore
- name: Build & Run Unit Tests
run: dotnet test --verbosity minimal --no-restore --settings tests\UnitTests.runsettings --results-directory ${{ env.test_results_path }}
- name: Upload coverage reports to Codecov.io
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
flags: Agent
directory: ${{ env.test_results_path }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage report artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: UnitTestResults # Artifact name
path: ${{ env.test_results_path }} # Directory containing files to upload