Changed license #107
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 | |
steps: | |
- name: 'Setup dotnet' | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: | | |
6.0.x | |
7.0.x | |
- name: 'Checkout' | |
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: '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" "~/plctypes.md" | |
- name: 'Switch and Commit to docs branch' | |
continue-on-error: true | |
run: | | |
git fetch | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git checkout --orphan ${{ steps.extract_branch.outputs.branch }}_auto_docs | |
git rm -rf . | |
cp ~/plctypes.md ./plctypes.md && | |
git add "./plctypes.md" -f && | |
git commit -m "Update documentation" | |
- 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 }}_auto_docs | |
- name: Report Generator | |
uses: danielpalme/[email protected] | |
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 "[email protected]" | |
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 | |