Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add CI pipeline #21

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-stryker": {
"version": "3.12.0",
"commands": [
"dotnet-stryker"
]
}
}
}
126 changes: 126 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: CI

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

permissions:
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true

env:
DOTNET_CLI_PERF_LOG: false
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_NOLOGO: true
SuppressNETCoreSdkPreviewMessage: true
SLN_PATH: source/FlashOWare.Generators.sln

jobs:
build:
name: Restore & Build & Test
continue-on-error: false
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-22.04, windows-2022]
configuration: [Debug, Release]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Restore dependencies
run: dotnet restore ${{ env.SLN_PATH }} --configfile nuget.config --no-cache
- name: Build
run: dotnet build ${{ env.SLN_PATH }} --configuration ${{ matrix.configuration }} --no-restore
- name: Test
run: dotnet test ${{ env.SLN_PATH }} --configuration ${{ matrix.configuration }} --no-build
codeCoverage:
name: Collect Code Coverage
needs:
- build
runs-on: ubuntu-22.04
env:
COVERAGE_OUTPUT_PATH: artifacts/coverage
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Restore dependencies
run: dotnet restore ${{ env.SLN_PATH }} --configfile nuget.config --no-cache
- name: Build
run: dotnet build ${{ env.SLN_PATH }} --configuration Debug --no-restore
- name: Test
run: dotnet test ${{ env.SLN_PATH }} --configuration Debug --no-build --collect:"XPlat Code Coverage" --logger trx --results-directory ${{ env.COVERAGE_OUTPUT_PATH }}
- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: '${{ env.COVERAGE_OUTPUT_PATH }}/*/coverage.cobertura.xml'
badge: true
format: 'markdown'
output: 'both'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: Code Coverage
recreate: true
path: code-coverage-results.md
- name: Write to Job Summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
mutationTesting:
name: Mutation Testing
needs:
- build
env:
STRYKER_OUTPUT_PATH: ${{ github.workspace }}/artifacts/stryker
runs-on: ubuntu-22.04
steps:
- name: Setup Variables
# https://stryker-mutator.io/docs/stryker-net/reporters/#markdown-summary-reporter
run: echo "STRYKER_REPORT_PATH=${{ env.STRYKER_OUTPUT_PATH }}/reports/mutation-report.md" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Restore tools
run: dotnet tool restore --configfile nuget.config --tool-manifest .config/dotnet-tools.json --no-cache
- name: Restore dependencies
run: dotnet restore ${{ env.SLN_PATH }} --configfile nuget.config --no-cache
- name: Build
# Although Stryker states that restore/build is not needed, I got a warning that sources could not be found.
# Therefore always restore/build!
run: dotnet build ${{ env.SLN_PATH }} --configuration Debug --no-restore
- name: Run dotnet-stryker
run: dotnet stryker --config-file stryker-config.yaml --output ${{ env.STRYKER_OUTPUT_PATH }}
working-directory: source/gen
- name: Add Mutation Test PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: Mutation Test
recreate: true
path: ${{ env.STRYKER_REPORT_PATH }}
- name: Write to Job Summary
run: cat ${{ env.STRYKER_REPORT_PATH }} >> $GITHUB_STEP_SUMMARY
Loading