|
| 1 | +name: 'Mutation tests' |
| 2 | + |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: # To can dispatch manually |
| 6 | + |
| 7 | + push: # First pipeline to run when deploy a new version |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - "src/**" # Only run when exists changes in source code |
| 12 | + - "tests/**" # Only run when exists changes in tests code |
| 13 | + |
| 14 | + pull_request: |
| 15 | + types: [opened, reopened, edited, synchronize] |
| 16 | + branches: |
| 17 | + - main |
| 18 | + |
| 19 | + |
| 20 | +env: |
| 21 | + SDK_VERSION: '7.0.100' |
| 22 | + |
| 23 | + GIT_ORGANIZATION: 'TechNobre' |
| 24 | + PROJECT_NAME: 'PowerUtils.AspNetCore.ErrorHandler' |
| 25 | + TEST_PROJECT_PATH: 'tests/PowerUtils.AspNetCore.ErrorHandler.Tests/PowerUtils.AspNetCore.ErrorHandler.Tests.csproj' |
| 26 | + |
| 27 | + |
| 28 | +permissions: |
| 29 | + pull-requests: write # To can create a comment with the results |
| 30 | + |
| 31 | + |
| 32 | +jobs: |
| 33 | + |
| 34 | + test-project: |
| 35 | + name: "Mutation tests" |
| 36 | + runs-on: ubuntu-latest |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: "Checkout" |
| 40 | + uses: actions/checkout@v3 |
| 41 | + |
| 42 | + - name: "Setup .NET" |
| 43 | + uses: actions/setup-dotnet@v3 |
| 44 | + with: |
| 45 | + dotnet-version: ${{ env.SDK_VERSION }} |
| 46 | + |
| 47 | + - name: "Restore .NET Tools" |
| 48 | + run: dotnet tool restore |
| 49 | + |
| 50 | + - name: "Restore dependencies" |
| 51 | + run: dotnet restore |
| 52 | + |
| 53 | + - name: "Build" |
| 54 | + run: dotnet build --configuration Release --no-restore |
| 55 | + |
| 56 | + - name: "Test for main version" |
| 57 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 58 | + run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter markdown --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version main |
| 59 | + |
| 60 | + - name: "Get branch name" |
| 61 | + if: github.event_name == 'pull_request' |
| 62 | + id: branch-name |
| 63 | + uses: tj-actions/branch-names@v6 |
| 64 | + |
| 65 | + - name: "Display branch details" |
| 66 | + if: github.event_name == 'pull_request' |
| 67 | + run: | |
| 68 | + echo "Branch name is ${{ steps.branch-name.outputs.current_branch }}" |
| 69 | +
|
| 70 | + - name: "Test for PR" |
| 71 | + if: github.event_name == 'pull_request' |
| 72 | + run: dotnet stryker -tp ${{ env.TEST_PROJECT_PATH }} --reporter markdown --reporter progress --reporter dashboard --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version ${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }} |
| 73 | + |
| 74 | + - name: "Comment PR" |
| 75 | + uses: actions/github-script@v6.3.3 |
| 76 | + if: github.event_name == 'pull_request' |
| 77 | + with: |
| 78 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + script: | |
| 80 | + const { issue: { number: issue_number }, repo: { owner, repo } } = context; |
| 81 | + const message = `🚀 **Stryker report generated** 🚀 |
| 82 | + [](https://dashboard.stryker-mutator.io/reports/github.com/${{ env.GIT_ORGANIZATION }}/${{ env.PROJECT_NAME }}/${{ steps.branch-name.outputs.current_branch }}-${{ github.run_number }}) |
| 83 | + 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 }}`; |
| 84 | + github.rest.issues.createComment({ |
| 85 | + issue_number, |
| 86 | + owner, |
| 87 | + repo, |
| 88 | + body: message |
| 89 | + }); |
| 90 | +
|
| 91 | + - name: "Publish report" |
| 92 | + run: | |
| 93 | + cat $(find ./StrykerOutput/* -name "*.md") > $GITHUB_STEP_SUMMARY |
0 commit comments