Files
MewtocolNet/.github/workflows/test-pipeline.yml
2023-06-18 22:16:19 +02:00

101 lines
3.0 KiB
YAML

name: Test pipeline
on:
workflow_dispatch:
workflow_call:
inputs:
cache-id:
default: 'test-results'
required: false
type: string
push:
branches:
- main
- master
paths-ignore:
- '**.md'
permissions: write-all
jobs:
#Check the online status of the test PLCs first
check-plcs-online:
name: 'Test PLC online status'
runs-on: [self-hosted, linux, x64, womed-local-linux]
steps:
- name: 'Ping FPX-H-C30T'
run: ping 192.168.115.210 -w 5
- name: 'Ping FPX-H-C14R'
run: ping 192.168.115.212 -w 5
- name: 'Ping FPX-C30T'
run: ping 192.168.115.213 -w 5
#Run unit tests on the test PLCs
run-unit-tests:
name: 'Run unit tests'
needs: check-plcs-online
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: |
cd './MewtocolTests'
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.opencover.xml
cd ../
- name: Report Generator
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.22
with:
reports: './MewtocolTests/TestResults/coverage.opencover.xml'
targetdir: './MewtocolTests/TestResults'
reporttypes: HtmlSummary;MarkdownSummaryGithub;Badges
historydir: './MewtocolTests/Hist'
title: Report
- name: Markdown report
run: cat './MewtocolTests/TestResults/SummaryGithub.md' >> $GITHUB_STEP_SUMMARY
#Upload to codecov
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
#- uses: actions/upload-artifact@v3
# with:
# name: test-results
# path: ./MewtocolTests/TestResults/
- name: Cache test results
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/cache/save@v3
with:
key: ${{ inputs.cache-id }}
path: |
${{ github.workspace }}/MewtocolTests/TestResults
- name: Commit badge
continue-on-error: true
run: |
git fetch
git checkout badges
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add "./MewtocolTests/TestResults/badge_combined.svg" -f
git add "./MewtocolTests/TestResults/summary.html" -f
git commit -m "Add/Update badge"
- name: Push badge commit
uses: ad-m/github-push-action@master
if: ${{ success() }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges