Skip to content

Commit

Permalink
refactor: simplify pipelines (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss authored Apr 1, 2024
1 parent ff11899 commit 7d43c13
Show file tree
Hide file tree
Showing 7 changed files with 200 additions and 411 deletions.
147 changes: 142 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: "Build"

on:
workflow_dispatch:
push:
branches: [main]
branches: [main, 'release/v[0-9]+.[0-9]+.[0-9]+']

jobs:
analyze:
Expand All @@ -23,6 +24,12 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 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:
Expand Down Expand Up @@ -68,6 +75,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:
Expand All @@ -92,6 +105,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:
Expand All @@ -116,6 +135,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:
Expand All @@ -140,12 +165,14 @@ 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:
dotnet-version: |
6.0.x
7.0.x
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup VSTest
Expand Down Expand Up @@ -192,3 +219,113 @@ jobs:
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.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@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
- 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@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}"
62 changes: 0 additions & 62 deletions .github/workflows/ci-stryker.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,60 @@ jobs:
with:
name: Test results (.NET Framework)
path: TestResults

stryker:
name: Mutation testing
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
- name: Install .NET Stryker
shell: bash
run: |
dotnet tool install dotnet-stryker --tool-path ../tools
- name: Prepare Reports directory
shell: bash
run: |
mkdir Tests/StrykerOutput/Reports -p
- 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_HEAD_REF}" -r "html" -r "cleartext" --since:main
mv ./StrykerOutput/**/reports/*.html ./StrykerOutput/Reports/Testably.Abstractions.FluentAssertions-report.html
- name: Upload Stryker reports
uses: actions/upload-artifact@v4
with:
name: Stryker
path: Tests/StrykerOutput/Reports/*
- name: Add comment to pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
prNumber="${{ github.event.number }}"
commentsUrl="https://api.github.com/repos/Testably/Testably.Abstractions.FluentAssertions/issues/$prNumber/comments"
dashboardLink="attached Stryker dashboards on the build pipeline"
echo "Search for comment in PR#$prNumber containing $dashboardLink..."
result=$(curl -X GET $commentsUrl \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN")
if [[ $result != *"$dashboardLink"* ]]
then
body="{\"body\":\"Please check the attached Stryker dashboards on the build pipeline.\"}"
curl -X POST $commentsUrl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d "$body"
fi
37 changes: 0 additions & 37 deletions .github/workflows/pr.yml

This file was deleted.

Loading

0 comments on commit 7d43c13

Please sign in to comment.