name: Test pipeline on: workflow_dispatch: workflow_call: inputs: cache-id: default: 'test-results' required: false type: string push: 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: 'Setup dotnet' uses: actions/setup-dotnet@v2 with: dotnet-version: '6.0.x' - name: 'Run tests' run: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../Builds/TestResults/coverage.opencover.xml - 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 }}-${{ GITHUB_REF##*/ }} path: | ${{ github.workspace }}/Builds/TestResults - name: Commit badge continue-on-error: true run: | git fetch git checkout badges cp ~/summary.html ./Builds/TestResults/summary_${{ GITHUB_REF##*/ }}.html cp ~/badge_combined.svg ./Builds/TestResults/badge_combined_${{ GITHUB_REF##*/ }}.svg git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add "./Builds/TestResults/badge_combined_${{ GITHUB_REF##*/ }}.svg" -f git add "./Builds/TestResults/summary_${{ GITHUB_REF##*/ }}.html" -f git commit -m "Add/Update badge for branch ${{ GITHUB_REF##*/ }}" - name: Push badge commit uses: ad-m/github-push-action@master if: ${{ success() }} with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: badges