From c168b4f44604bae73826866c10aa3d09be277d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 30 Mar 2024 07:39:06 +0100 Subject: [PATCH 1/2] Move release pipeline into build --- .github/workflows/build.yml | 190 ++++++++++++++++++++- .github/workflows/release.yml | 306 ---------------------------------- Testably.Abstractions.sln | 1 - 3 files changed, 189 insertions(+), 308 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2321c4f87..8902aca2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: "Build" on: push: - branches: [main] + branches: [main, 'release/v[0-9]+.[0-9]+.[0-9]+'] jobs: test-macos: @@ -13,6 +13,12 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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: @@ -41,6 +47,12 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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: @@ -69,6 +81,12 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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: @@ -97,6 +115,12 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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 @@ -126,6 +150,12 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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: @@ -180,3 +210,161 @@ jobs: with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} coverage-reports: coverage-report/Cobertura.xml + + stryker-ubuntu: + name: Analyze quality of unit test coverage with .NET Stryker (Ubuntu) + if: startsWith(github.ref, 'refs/heads/release/') + runs-on: ubuntu-latest + timeout-minutes: 300 + steps: + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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.Testing + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" + + stryker-windows: + name: Analyze quality of unit test coverage with .NET Stryker (Windows) + if: startsWith(github.ref, 'refs/heads/release/') + runs-on: windows-latest + timeout-minutes: 300 + steps: + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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 + 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" + - name: Analyze Testably.Abstractions.AccessControl + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" + - name: Analyze Testably.Abstractions.Compression + env: + STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} + shell: bash + run: | + cd Tests + ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.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: [test-macos, test-ubuntu, test-windows, test-net-framework, test-examples] + steps: + - name: Checkout sources + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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\/releases\/tag\/${version})" "./README.md" + for f in "README.md" "Docs/AccessControl.md" "Docs/Compression.md" "Docs/Interface.md" "Docs/Testing.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%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f" + sed -i -e "s/Testably.Abstractions%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f" + sed -i -e "s/Testably.Abstractions\/main)/Testably.Abstractions\/release\/${version})/g" "./$f" + # Add absolute path to example section + sed -i -e 's/\(Examples\/README.md\)/https:\/\/github.com\/Testably\/Testably.Abstractions\/blob\/main\/Examples\/README.md/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, stryker-windows, stryker-ubuntu] + 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7afdc40d3..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,306 +0,0 @@ -name: "Release" - -on: - push: - branches: - - 'release/v[0-9]+.[0-9]+.[0-9]+' - -jobs: - test-macos: - name: Test (MacOS) - runs-on: macos-latest - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Tag current commit - 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 - uses: Wandalen/wretry.action@v1.4.10 - with: - command: dotnet test --no-build - attempt_limit: 2 - - test-ubuntu: - name: Test (Ubuntu) - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Tag current commit - 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 - uses: Wandalen/wretry.action@v1.4.10 - with: - command: dotnet test --no-build - attempt_limit: 2 - - test-windows: - name: Test (Windows) - runs-on: windows-latest - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Tag current commit - 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 - uses: Wandalen/wretry.action@v1.4.10 - with: - command: dotnet test --no-build - attempt_limit: 2 - - test-net-framework: - name: Test (.NET Framework) - runs-on: windows-latest - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Tag current commit - 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: 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.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.Tests\net48\Testably.Abstractions.Tests.dll .\Build\Tests\Testably.Abstractions.Parity.Tests\net48\Testably.Abstractions.Parity.Tests.dll .\Build\Tests\Testably.Abstractions.Testing.Tests\net48\Testably.Abstractions.Testing.Tests.dll - - test-examples: - name: Test (Examples) - runs-on: windows-latest - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - fetch-depth: 0 - - name: Tag current commit - 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 - - name: Build example solution - run: dotnet build Examples /p:UseFileReferenceToTestablyLibraries=True --configuration "Release" - - name: Run example tests - uses: Wandalen/wretry.action@v1.4.10 - with: - command: dotnet test Examples --no-build - attempt_limit: 2 - - stryker-ubuntu: - name: Analyze quality of unit test coverage with .NET Stryker (Ubuntu) - runs-on: ubuntu-latest - timeout-minutes: 300 - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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.Testing - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Testing.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" - - stryker-windows: - name: Analyze quality of unit test coverage with .NET Stryker (Windows) - runs-on: windows-latest - timeout-minutes: 300 - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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 - 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" - - name: Analyze Testably.Abstractions.AccessControl - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.AccessControl.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" - - name: Analyze Testably.Abstractions.Compression - env: - STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }} - shell: bash - run: | - cd Tests - ../../tools/dotnet-stryker -f ../.github/stryker/Stryker.Config.Compression.json -v "${GITHUB_REF#refs/heads/}" -r "Dashboard" -r "cleartext" - - deploy: - name: Deploy - runs-on: ubuntu-latest - environment: production - needs: [test-macos, test-ubuntu, test-windows, test-net-framework, test-examples] - steps: - - name: Checkout sources - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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\/releases\/tag\/${version})" "./README.md" - for f in "README.md" "Docs/AccessControl.md" "Docs/Compression.md" "Docs/Interface.md" "Docs/Testing.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%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f" - sed -i -e "s/Testably.Abstractions%2Fmain/Testably.Abstractions%2Frelease%2F${version}/g" "./$f" - sed -i -e "s/Testably.Abstractions\/main)/Testably.Abstractions\/release\/${version})/g" "./$f" - # Add absolute path to example section - sed -i -e 's/\(Examples\/README.md\)/https:\/\/github.com\/Testably\/Testably.Abstractions\/blob\/main\/Examples\/README.md/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 - runs-on: ubuntu-latest - needs: [deploy, stryker-windows, stryker-ubuntu] - 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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}" diff --git a/Testably.Abstractions.sln b/Testably.Abstractions.sln index fa0798d91..06e15af97 100644 --- a/Testably.Abstractions.sln +++ b/Testably.Abstractions.sln @@ -62,7 +62,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ .github\workflows\ci-stryker.yml = .github\workflows\ci-stryker.yml .github\workflows\ci.yml = .github\workflows\ci.yml .github\workflows\pr.yml = .github\workflows\pr.yml - .github\workflows\release.yml = .github\workflows\release.yml .github\workflows\stryker.yml = .github\workflows\stryker.yml .github\workflows\test-report.yml = .github\workflows\test-report.yml EndProjectSection From 156bf7922a22174743411080ac8c5bdf18b88d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Sat, 30 Mar 2024 07:48:21 +0100 Subject: [PATCH 2/2] Enable workflow_dispatch --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8902aca2e..1453e21de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: "Build" on: + workflow_dispatch: push: branches: [main, 'release/v[0-9]+.[0-9]+.[0-9]+']