test #3301
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: test | |
on: | |
workflow_call: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- main | |
# run on the first day of each month | |
# since the coverage artifacts will expire after 35d | |
schedule: | |
- cron: '0 0 1 * *' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-dotnet@v4 | |
- run: dotnet build /p:TreatWarningsAsErrors=true | |
- run: dotnet test --no-build --logger 'junit' /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura | |
- uses: test-summary/action@v2 | |
if: always() | |
with: | |
paths: 'test/**/TestResults/**/*.xml' | |
- uses: danielpalme/ReportGenerator-GitHub-Action@v5 | |
if: always() | |
with: | |
reports: 'test/**/*cobertura.xml' | |
reporttypes: 'Cobertura' | |
targetdir: '${{ github.workspace }}' | |
- uses: clearlyip/code-coverage-report-action@v5 | |
id: code_coverage_report_action | |
# dont run for dependabot | |
if: ${{ always() && github.actor != 'dependabot[bot]'}} | |
with: | |
filename: 'Cobertura.xml' | |
overall_coverage_fail_threshold: 75 | |
retention_days: 35 | |
package: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: sudo apt update && sudo apt -y install zipmerge # zipmerge is used to merge the multi target nupkg | |
- uses: actions/setup-dotnet@v4 | |
- run: dotnet tool restore | |
- run: RELEASE_VERSION="0.0.1-dev.$GITHUB_RUN_ID" ./build/package.sh | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mapperly-nupkg | |
path: artifacts/*.nupkg | |
- if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: verify-test-results-package | |
path: '**/*.received.*' | |
retention-days: 3 | |
validate-package: | |
needs: package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-dotnet@v4 | |
- run: dotnet tool restore | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mapperly-nupkg | |
path: artifacts | |
- run: dotnet meziantou.validate-nuget-package ./artifacts/*.nupkg | |
- run: dotnet validate package local ./artifacts/*.nupkg | |
integration-test: | |
needs: package | |
runs-on: ubuntu-latest | |
# use an alpine container to ensure only the dotnet version we want to test is installed, | |
# ubuntu-latest already contains several dotnet versions... | |
container: | |
image: alpine:3.17 | |
strategy: | |
fail-fast: false | |
matrix: | |
dotnet: | |
- '8.0' | |
- '7.0' | |
- '6.0' | |
steps: | |
- uses: actions/checkout@v4 | |
# install required dotnet dependencies | |
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-alpine#dependencies | |
- run: apk add --no-cache bash icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib | |
# delete global.json since we want to use custom versions here | |
- run: rm global.json | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ matrix.dotnet }} | |
- run: dotnet --list-sdks | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mapperly-nupkg | |
path: artifacts | |
# use nupkg artifact for integration tests instead of project references | |
- run: dotnet nuget add source "$(pwd)/artifacts" | |
- run: >- | |
dotnet build | |
-f net${{ matrix.dotnet }} | |
-p:MapperlyIntegrationTestsTargetFramework=net${{ matrix.dotnet }} | |
-p:MapperlyNugetPackageVersion="0.0.1-dev.$GITHUB_RUN_ID" | |
working-directory: ./test/Riok.Mapperly.IntegrationTests | |
- run: dotnet test --no-build -f net${{ matrix.dotnet }} | |
working-directory: ./test/Riok.Mapperly.IntegrationTests | |
- if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: verify-test-results-net${{ matrix.dotnet }} | |
path: '**/*.received.*' | |
retention-days: 3 | |
integration-test-net-framework: | |
needs: package | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# delete global.json since we want to use custom versions here | |
- run: rm global.json | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mapperly-nupkg | |
path: artifacts | |
# use nupkg artifact for integration tests instead of project references | |
- run: dotnet nuget add source "$(Get-Location)/artifacts" | |
- run: >- | |
dotnet build | |
-f net48 | |
-p:MapperlyIntegrationTestsTargetFramework=net48 | |
-p:MapperlyNugetPackageVersion=0.0.1-dev.$env:GITHUB_RUN_ID | |
working-directory: ./test/Riok.Mapperly.IntegrationTests | |
- run: dotnet test --no-build -f net48 | |
working-directory: ./test/Riok.Mapperly.IntegrationTests | |
- if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: verify-test-results-net-framework | |
path: '**/*.received.*' | |
retention-days: 3 | |
sample: | |
runs-on: ubuntu-latest | |
needs: package | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-dotnet@v4 | |
- run: dotnet run --project ./samples/Riok.Mapperly.Sample | |
# run the same again with the real nuget without runtime assets | |
- uses: actions/download-artifact@v4 | |
with: | |
name: mapperly-nupkg | |
path: artifacts | |
# use nupkg artifact instead of project references | |
- run: dotnet nuget add source "$(pwd)/artifacts" | |
- run: dotnet clean | |
- run: dotnet build -p:MapperlyNugetPackageVersion="0.0.1-dev.$GITHUB_RUN_ID" | |
working-directory: ./samples/Riok.Mapperly.Sample | |
- run: dotnet run --no-build | |
working-directory: ./samples/Riok.Mapperly.Sample |