Skip to content

CI

CI #437

Workflow file for this run

name: CI
on:
push:
schedule:
- cron: '1 0 * * 1' # * is a special character in YAML, therefore this string needs to be quoted
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
fail-fast: false
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
ARTIFACT_DIR: ./Artifacts
PROJECT_NAME: AoCHelper
steps:
- uses: actions/checkout@v4
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: '[Ubuntu] Set version to -ci-${{ github.run_number }}'
if: matrix.os == 'ubuntu-latest'
shell: pwsh
run: |
$input_path = "src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj"
$regex = "(?<=<Version>).*(?=</Version>)"
(Get-Content $input_path) -Replace $regex, '$0-ci-${{ github.run_number }}' | Out-File $input_path
- name: Build
run: dotnet build -c Release /p:DeterministicBuild=true
- name: Run tests
run: dotnet test -c Release --no-build --collect:"XPlat Code Coverage"
- name: '[Ubuntu] Pack'
if: matrix.os == 'ubuntu-latest'
run: |
dotnet pack -c Release --no-build src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj --include-symbols -o ${{ env.ARTIFACT_DIR }}
- name: '[Ubuntu] Upload Artifact'
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_NAME }}-ci-${{ github.run_number }}
path: |
${{ env.ARTIFACT_DIR }}/*.nupkg
${{ env.ARTIFACT_DIR }}/*.snupkg
if-no-files-found: error
- name: '[Ubuntu] Generate test coverage report'
if: matrix.os == 'ubuntu-latest'
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: 'tests/**/*.cobertura.xml'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline_AzurePipelines_Dark'
assemblyfilters: '+*'
classfilters: '+*;-*Exception'
filefilters: '+*'
verbosity: 'Info'
title: '${{ env.PROJECT_NAME }} #${{ github.run_number }} (${{ env.GITHUB_REF_SLUG }})'
tag: '${{ github.run_number }}_${{ github.run_id }}'
customSettings: 'numberOfReportsParsedInParallel=3;numberOfReportsMergedInParallel=3'
- name: '[Ubuntu] Upload test coverage report'
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROJECT_NAME }}-coverage-ci-${{ github.run_number }}
path: coveragereport/
if-no-files-found: error