Skip to content

ci: Improved test reports #253

ci: Improved test reports

ci: Improved test reports #253

name: 'Mutation tests'
on:
workflow_dispatch: # To can dispatch manually
push: # First pipeline to run when deploy a new version
branches:
- main
paths:
- "src/**" # Only run when exists changes in source code
- "tests/**" # Only run when exists changes in tests code
pull_request:
types: [opened, reopened, edited, synchronize]
branches:
- main
env:
SDK_VERSION: '6.0.420'
GIT_ORGANIZATION: 'TechNobre'
PROJECT_NAME: 'PowerUtils.xUnit.Extensions'
TEST_PROJECT_PATH: 'tests/PowerUtils.xUnit.Extensions.Tests.csproj'
permissions:
pull-requests: write # To can create a comment with the results
jobs:
test-project:
name: "Mutation tests"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup .NET"
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.SDK_VERSION }}
- name: "Restore .NET Tools"
run: dotnet tool restore
- name: "Restore dependencies"
run: dotnet restore
- name: "Build"
run: dotnet build --configuration Release --no-restore
- name: "Test for main version"
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version main
- name: "Get branch name"
if: github.event_name == 'pull_request'
id: branch-name
uses: tj-actions/branch-names@v8
- name: "Display branch details"
if: github.event_name == 'pull_request'
run: |
echo "Branch name is ${{ steps.branch-name.outputs.current_branch }}"
- name: "Test for PR"
if: github.event_name == 'pull_request'
run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version ${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }}
- name: "Comment PR"
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const message = `🚀 **Stryker report generated** 🚀
[![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2F${{ env.GIT_ORGANIZATION }}%2F${{ env.PROJECT_NAME }}%2F${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }})](https://dashboard.stryker-mutator.io/reports/github.com/${{ env.GIT_ORGANIZATION }}/${{ env.PROJECT_NAME }}/${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }})
To more details: https://dashboard.stryker-mutator.io/reports/github.com/${{ env.GIT_ORGANIZATION }}/${{ env.PROJECT_NAME }}/${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }}`;
github.rest.issues.createComment({
issue_number,
owner,
repo,
body: message
});