chore(deps): update danielpalme/reportgenerator-github-action action … #149
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" | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main, 'release/v[0-9]+.[0-9]+.[0-9]+'] | |
jobs: | |
analyze: | |
name: Static code analysis | |
runs-on: windows-latest | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Tag current commit | |
if: startsWith(github.ref, 'refs/heads/release/') | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@v4 | |
with: | |
path: .\.sonar\scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: Install SonarCloud scanner | |
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Path .\.sonar\scanner -ItemType Directory | |
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
- name: Build and analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
shell: powershell | |
run: | | |
dotnet tool install minver-cli --global | |
dotnet tool restore | |
$version = minver -t v | |
$productVersion,$prerelease = $version -split '-',2 | |
echo "Detected product version: $productVersion" | |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Testably_Testably.Abstractions.FluentAssertions" /o:"testably" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /v:"$productVersion" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
dotnet tool install --global dotnet-coverage | |
dotnet restore -s 'nuget.config' | |
dotnet build --no-incremental /p:NetCoreOnly=True --configuration "Release" | |
dotnet-coverage collect 'dotnet test --no-build' -f xml -o 'coverage.xml' | |
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
test-macos: | |
name: Test (MacOS) | |
runs-on: macos-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag current commit | |
if: startsWith(github.ref, 'refs/heads/release/') | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Build solution | |
run: dotnet build /p:NetCoreOnly=True --configuration "Release" | |
- name: Run tests | |
run: dotnet test --no-build --collect:"XPlat Code Coverage" | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Code coverage (MacOS) | |
path: "**/coverage.cobertura.xml" | |
test-ubuntu: | |
name: Test (Ubuntu) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag current commit | |
if: startsWith(github.ref, 'refs/heads/release/') | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Build solution | |
run: dotnet build /p:NetCoreOnly=True --configuration "Release" | |
- name: Run tests | |
run: dotnet test --no-build --collect:"XPlat Code Coverage" | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Code coverage (Ubuntu) | |
path: "**/coverage.cobertura.xml" | |
test-windows: | |
name: Test (Windows) | |
runs-on: windows-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag current commit | |
if: startsWith(github.ref, 'refs/heads/release/') | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Build solution | |
run: dotnet build /p:NetCoreOnly=True --configuration "Release" | |
- name: Run tests | |
run: dotnet test --no-build --collect:"XPlat Code Coverage" | |
- name: Upload coverage | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Code coverage (Windows) | |
path: "**/coverage.cobertura.xml" | |
test-net-framework: | |
name: Test (.NET Framework) | |
runs-on: windows-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag current commit | |
if: startsWith(github.ref, 'refs/heads/release/') | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v2 | |
- name: Setup VSTest | |
uses: darenm/Setup-VSTest@v1 | |
- name: Navigate to Workspace | |
run: cd $GITHUB_WORKSPACE | |
- name: Build solution | |
run: msbuild.exe Testably.Abstractions.FluentAssertions.sln /p:NetFrameworkOnly=True /p:platform="Any CPU" /p:configuration="Release" -t:restore,build -p:RestorePackagesConfig=true | |
- name: Run tests | |
run: vstest.console.exe .\Build\Tests\Testably.Abstractions.FluentAssertions.Tests\net48\Testably.Abstractions.FluentAssertions.Tests.dll | |
upload-coverage: | |
name: Upload coverage to Codacy | |
needs: [test-macos, test-ubuntu, test-windows, test-net-framework] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Download code coverage files (MacOS) | |
uses: actions/download-artifact@v4 | |
with: | |
name: Code coverage (MacOS) | |
path: Coverage/MacOS | |
- name: Download code coverage files (Ubuntu) | |
uses: actions/download-artifact@v4 | |
with: | |
name: Code coverage (Ubuntu) | |
path: Coverage/Ubuntu | |
- name: Download code coverage files (Windows) | |
uses: actions/download-artifact@v4 | |
with: | |
name: Code coverage (Windows) | |
path: Coverage/Windows | |
- name: Generate coverage report | |
uses: danielpalme/ReportGenerator-GitHub-Action@v5.3.11 | |
with: | |
reports: "Coverage/**/coverage.cobertura.xml" | |
targetdir: "coverage-report" | |
reporttypes: "Cobertura" | |
- name: Publish coverage report to Codacy | |
uses: codacy/codacy-coverage-reporter-action@master | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: coverage-report/Cobertura.xml | |
stryker: | |
name: Stryker mutation testing | |
runs-on: ubuntu-latest | |
timeout-minutes: 300 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Install .NET Stryker | |
shell: bash | |
run: | | |
dotnet tool install dotnet-stryker --tool-path ../tools | |
- name: Analyze Testably.Abstractions.FluentAssertions | |
env: | |
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} | |
shell: bash | |
run: | | |
cd Tests | |
../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" | |
deploy: | |
name: Deploy | |
if: startsWith(github.ref, 'refs/heads/release/') | |
runs-on: ubuntu-latest | |
environment: production | |
needs: [analyze, test-macos, test-ubuntu, test-windows, test-net-framework, stryker] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Tag current commit | |
id: tag | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git tag "${version}" | |
git push origin "${version}" | |
echo "release_version=${version}" >> "$GITHUB_OUTPUT" | |
- name: Setup NuGet | |
uses: NuGet/setup-nuget@v2.0.0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Prepare README.md | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
# Add changelog badge to README.md | |
sed -i -e "2 a\[!\[Changelog](https:\/\/img\.shields\.io\/badge\/Changelog-${version}-blue)](https:\/\/github\.com\/Testably\/Testably\.Abstractions\.FluentAssertions\/releases\/tag\/${version})" "./README.md" | |
for f in "README.md" | |
do | |
echo "Processing $f" # always double quote "$f" filename | |
# do something on $f | |
# Remove the codacy badge as it is not aligned to the release | |
grep -v "Codacy Badge" "./$f" > "./$f.backup" && mv "./$f.backup" "./$f" | |
# Change status badges to display explicit version | |
sed -i -e "s/branch=main/branch=release%2F${version}/g" "./$f" | |
sed -i -e "s/Testably.Abstractions.FluentAssertions%2Fmain/Testably.Abstractions.FluentAssertions%2Frelease%2F${version}/g" "./$f" | |
sed -i -e "s/Testably.Abstractions.FluentAssertions%2Fmain/Testably.Abstractions.FluentAssertions%2Frelease%2F${version}/g" "./$f" | |
sed -i -e "s/Testably.Abstractions.FluentAssertions\/main)/Testably.Abstractions.FluentAssertions\/release\/${version})/g" "./$f" | |
done | |
- name: Build | |
run: dotnet build --configuration "Release" | |
- name: Publish | |
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}} | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: ${{ steps.tag.outputs.release_version }} | |
tag_name: ${{ steps.tag.outputs.release_version }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
generate_release_notes: true | |
cleanup: | |
name: Cleanup | |
if: startsWith(github.ref, 'refs/heads/release/') | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
steps: | |
- name: Comment relevant issues and pull requests | |
uses: apexskier/github-release-commenter@v1.3.6 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
comment-template: | | |
This is addressed in release {release_link}. | |
label-template: | | |
state: released | |
skip-label: | | |
state: released | |
- name: Checkout sources | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Delete release branch | |
shell: bash | |
run: | | |
version="${GITHUB_REF#refs/heads/release/}" | |
git push origin -d "refs/heads/release/${version}" |