Merge branch 'master' of https://github.com/WOmed/MewtocolNet #76
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: Test pipeline | |
on: | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
cache-id: | |
default: 'test-results' | |
required: false | |
type: string | |
push: | |
branches-ignore: | |
- badges | |
paths-ignore: | |
- '**.md' | |
permissions: write-all | |
jobs: | |
#Run unit tests on the test PLCs | |
run-unit-tests: | |
name: 'Run tests and documentation' | |
runs-on: [self-hosted, linux, x64, womed-local-linux] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Extract branch name' | |
shell: bash | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: 'Setup dotnet' | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
- name: 'Run tests' | |
run: dotnet test "./MewtocolTests" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../Builds/TestResults/coverage.opencover.xml | |
- name: 'Run docbuilder' | |
continue-on-error: true | |
run: dotnet run --project "./AutoTools.DocBuilder/AutoTools.DocBuilder.csproj" "./AutoTools.DocBuilder/Docs/plctypes.md" | |
- name: 'Commit generated docs to branch' | |
continue-on-error: true | |
run: | | |
git fetch | |
git checkout ${{ steps.extract_branch.outputs.branch }} | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add "./AutoTools.DocBuilder/Docs/plctypes.md" -f | |
git commit -m "(AUTO_DOC) add documentation for branch ${{ steps.extract_branch.outputs.branch }}" | |
- name: 'Push docs commit' | |
uses: ad-m/github-push-action@master | |
continue-on-error: true | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.extract_branch.outputs.branch }} | |
- name: Report Generator | |
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.22 | |
with: | |
reports: './Builds/TestResults/coverage.opencover.xml' | |
targetdir: './Builds/TestResults' | |
reporttypes: HtmlSummary;MarkdownSummaryGithub;Badges | |
historydir: './Builds/Hist' | |
title: Report | |
- name: Markdown report and copy for badges branch | |
run: | | |
cat './Builds/TestResults/SummaryGithub.md' >> $GITHUB_STEP_SUMMARY | |
cp ./Builds/TestResults/badge_combined.svg ~/badge_combined.svg | |
cp ./Builds/TestResults/summary.html ~/summary.html | |
ls -l ~ | |
- name: Cache test results | |
if: ${{ github.event_name == 'workflow_call' }} | |
uses: actions/cache/save@v3 | |
with: | |
key: ${{ inputs.cache-id }}-${{ steps.extract_branch.outputs.branch }} | |
path: | | |
${{ github.workspace }}/Builds/TestResults | |
- name: Commit badge | |
continue-on-error: true | |
run: | | |
git fetch | |
git checkout badges | |
cp ~/summary.html ./Builds/TestResults/summary_${{ steps.extract_branch.outputs.branch }}.html | |
cp ~/badge_combined.svg ./Builds/TestResults/badge_combined_${{ steps.extract_branch.outputs.branch }}.svg | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add "./Builds/TestResults/badge_combined_${{ steps.extract_branch.outputs.branch }}.svg" -f | |
git add "./Builds/TestResults/summary_${{ steps.extract_branch.outputs.branch }}.html" -f | |
git commit -m "Add/Update badge for branch ${{ steps.extract_branch.outputs.branch }}" | |
- name: 'Push badge commit' | |
uses: ad-m/github-push-action@master | |
if: ${{ success() }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: badges | |