Skip to content

Reduced unnecessary snapshots (#7465) #474

Reduced unnecessary snapshots (#7465)

Reduced unnecessary snapshots (#7465) #474

Workflow file for this run

name: Main Branch Coverage
on:
push:
branches:
- main
paths:
- 'src/**'
concurrency:
group: main-coverage
cancel-in-progress: true
jobs:
configure:
name: Generate Test Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout to repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.x
8.x
- name: Generate Test Matrix
run: dotnet run --project ./.build -- GenerateMatrix
- name: Export Test Matrix
id: set-matrix
run: echo "matrix=$(jq -c . < ./matrix.json)" >> $GITHUB_OUTPUT
library-tests:
name: Run ${{ matrix.name }}
runs-on: ubuntu-latest
needs: configure
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.configure.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
7.x
8.x
- name: Run Build
id: run-build
run: dotnet build ${{ matrix.path }} --framework net8.0 --verbosity q
timeout-minutes: 5
- name: Run tests
id: run-tests
timeout-minutes: 15
continue-on-error: true
run: >
dotnet test ${{ matrix.path }}
--collect:"XPlat Code Coverage;Format=opencover"
--framework net8.0
--logger trx
--no-build
--verbosity q
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile="**/test/**"
env:
CI_BUILD: true
- name: Upload Test Results as Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.name }}
path: ${{ matrix.directoryPath }}/TestResults/*.trx
- name: Upload Coverage File as Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.name }}
# The * matches a single directory that is named with a GUID.
# Take note of https://github.com/microsoft/vstest/issues/2334.
path: ${{ matrix.directoryPath }}/TestResults/*/coverage.opencover.xml
- name: Upload mismatch files as Artifact
if: failure()
uses: actions/upload-artifact@v4
with:
name: mismatch-files-${{ matrix.name }}
path: ${{ matrix.directoryPath }}/**/__mismatch__/*
- name: Fail if tests failed or were cancelled
run: exit 1
if: |
steps.run-tests.outcome == 'failure' ||
steps.run-tests.outcome == 'cancelled'
merge-coverage:
name: Merge and Upload Coverage
needs: library-tests
if: always() && needs.library-tests.result != 'cancelled'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
7.x
8.x
- name: Create All.sln
if: ${{ !cancelled() }}
run: ./build.sh CreateAllSln
- name: Build
if: ${{ !cancelled() }}
run: dotnet build ./src/All.sln
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
path: ./output/download
pattern: coverage-*
- name: Merge Coverage Files
if: ${{ !cancelled() }}
timeout-minutes: 10
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator "-reports:./output/download/**/*.xml" "-targetdir:./output/coverage/merged" -reporttypes:Opencover -license:$ReportGenerator_License
env:
ReportGenerator_License: ${{ secrets.REPORTGENERATOR_LICENSE }}
- name: Upload Combined Coverage to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@v4
timeout-minutes: 10
with:
file: ./output/coverage/merged/OpenCover.xml
token: ${{ secrets.CODECOV_TOKEN }}
name: graphql-platform
flags: unittests
fail_ci_if_error: true
disable_search: true