Merge pull request #55 from fededim/fededim-buildfix #52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Main Build Process" | |
# Runs on main branch commits, | |
# every commit in a pull request, any published release. | |
on: | |
push: | |
branches: ["master"] | |
paths-ignore: | |
- 'misc/last_build_artifacts/**' | |
pull_request: | |
branches: ["master"] | |
paths-ignore: | |
- 'misc/last_build_artifacts/**' | |
release: | |
types: [published] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
name: "Build & Test" | |
# Permissions this GitHub Action needs for other things in GitHub | |
permissions: | |
pull-requests: write | |
contents: write | |
checks: write # required if create-status-check: true | |
runs-on: windows-latest | |
steps: | |
- name: "Check out the code" | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: "Setup .NET" | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.x | |
dotnet-quality: 'ga' | |
# - name: "Install Tyrannoport" | |
# run: dotnet tool install --global tyrannoport | |
- name: "Restore/Build/Test" | |
run: dotnet test --configuration Release --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/ | |
- name: "Generate reports From Code Coverage" | |
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.8 | |
with: | |
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported. | |
targetdir: "${{ github.workspace }}/misc/last_build_artifacts" # REQUIRED # The directory where the generated report should be saved. | |
reporttypes: Html;Cobertura;MarkdownSummaryGithub;Badges # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary | |
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off | |
title: "Code Coverage and Reports" # Optional title. | |
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version. | |
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings. | |
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool. | |
#- name: "Generate HTML from Test Results" | |
# run: gci -Path ${{ github.workspace }} -Filter *.trx -Recurse | foreach { tyrannoport -o misc/last_build_artifacts $_.FullName } | |
- name: "Generate reports from Test Results" | |
if: always() | |
id: process-test | |
uses: im-open/process-dotnet-test-results@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
update-comment-if-one-exists: false | |
#report-title-filter: 'Tests' | |
- name: "Copy reports from Test Results to misc/last_build_artifacts folder" | |
run: | | |
cp "${{ steps.process-test.outputs.test-results-file-path }}" "${{ github.workspace }}/misc/last_build_artifacts/test_results.md" | |
gci -Path "${{ github.workspace }}/Fededim.Extensions.Configuration.Protected.DataProtectionAPITest" -Filter *.trx -Recurse | foreach { cp "$_" misc/last_build_artifacts/ } | |
gci -Path "${{ github.workspace }}/Fededim.Extensions.Configuration.Protected.DataProtectionAPITest" -Filter *.cobertura.xml -Recurse | foreach { cp "$_" misc/last_build_artifacts/ } | |
- name: "Upload All Artifacts" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-artifacts | |
path: ${{ github.workspace }}/**/misc/last_build_artifacts/** | |
- name: Commit and push last_build_artifacts to PR branch | |
if: github.event_name == 'pull_request' | |
run: | | |
git checkout ${{ github.event.pull_request.head.ref }} | |
git config --global user.name 'Build And Test Github Action' | |
git config --global user.email 'githubaction@users.noreply.github.com' | |
git add ./misc/last_build_artifacts/* | |
git commit -m "Updated Last Build artifacts" | |
git push | |
- name: Test Results Summary | |
uses: dorny/test-reporter@v1 | |
with: | |
artifact: test-artifacts # artifact name | |
name: XUnit Tests # Name of the check run which will be created | |
path: '**/*.trx' # Path to test results (inside artifact .zip) | |
reporter: dotnet-trx # Format of test results |