22 Commits

Author SHA1 Message Date
Felix Weiß
d5b701186e Fixed caching again 2023-06-16 14:36:49 +02:00
Felix Weiß
0702ab7d0a Fixed caching 2023-06-16 14:32:54 +02:00
Felix Weiß
5adadbfc46 fixed caching 2023-06-16 14:24:16 +02:00
Felix Weiß
739f83bf0c Merge branch 'master' of https://github.com/WOmed/MewtocolNet 2023-06-16 14:19:05 +02:00
Felix Weiß
a9bd792af1 added test result saving 2023-06-16 14:18:51 +02:00
Felix Weiß
e6ffc92db6 Update README.md 2023-06-16 12:21:41 +02:00
Felix Weiß
7bd07bb520 Fixed env.VERSION for sed step 2023-06-16 12:10:57 +02:00
Felix Weiß
f99af9511b Fix wrong ver 2023-06-16 12:03:44 +02:00
Felix Weiß
b13b2d0199 Fixed sed escape 2023-06-16 11:49:17 +02:00
Felix Weiß
364e0637bb fixed versioning auto release 2023-06-16 11:42:04 +02:00
Felix Weiß
bba90106cb Made test-pipeline.yml callable 2023-06-16 11:22:48 +02:00
Felix Weiß
3dea18d285 Speperated test and publish pipeline 2023-06-16 11:18:08 +02:00
Sandoun
ad61361008 Use setup dotnet v2 2023-06-16 10:39:41 +02:00
Sandoun
0e0659000a Fixed ci no write permission 2023-06-16 10:34:57 +02:00
Sandoun
8cc47b496a Fixed new publish pipeline 2023-06-16 10:30:14 +02:00
Sandoun
9eb09fc7ec Merge branch 'master' of https://github.com/WOmed/MewtocolNet 2023-06-16 10:24:25 +02:00
Sandoun
9b8fca6561 Changed package publisher to gh 2023-06-16 10:24:19 +02:00
Felix Weiß
6205f81931 Update README.md 2023-06-16 10:05:30 +02:00
Sandoun
a8960f12c8 Changed to opencover test format 2023-06-16 10:00:15 +02:00
Felix Weiß
0b670b1a27 Update build-pipeline.yml 2023-06-16 09:48:15 +02:00
Felix Weiß
63a1348704 Update README.md 2023-06-15 21:03:31 +02:00
Felix Weiß
61fe2aff65 Update build-pipeline.yml 2023-06-15 21:02:55 +02:00
5 changed files with 144 additions and 105 deletions

View File

@@ -1,101 +0,0 @@
name: Build pipeline
on:
workflow_dispatch:
push:
branches:
- main
- master
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]
strategy:
matrix:
dotnet-version: [ '6.0.x' ]
steps:
- uses: actions/checkout@v3
- name: 'Setup dotnet ${{ matrix.dotnet-version }}'
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: 'Run tests'
run: |
cd '${{ github.workspace }}/MewtocolTests'
dotnet test --logger "trx;logfilename=testresults.trx"
#Generate a test report
- name: 'Generate Test Report'
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Unit Test Report # Name of the check run which will be created
path: '${{ github.workspace }}/MewtocolTests/TestResults/testresults.trx' # Path to test results
reporter: dotnet-trx # Format of test results
#Run code ql check
#code-ql-check:
# uses: ./.github/workflows/codeql.yml
#Publish to nuget if version tag change detected
publish-and-push-nuget:
name: 'Build and publish to NuGet'
needs: [run-unit-tests, ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Publish
- name: publish on version change
id: publish_nuget
uses: brandedoutcast/publish-nuget@v2
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: MewtocolNet/MewtocolNet.csproj
# Configuration to build and package
# BUILD_CONFIGURATION: Release
# Platform target to compile (default is empty/AnyCPU)
# BUILD_PLATFORM: x64
# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: Mewtocol.NET
# Filepath with version info, relative to root of repository & defaults to PROJECT_FILE_PATH
# VERSION_FILE_PATH: Directory.Build.props
# Regex pattern to extract version info in a capturing group
# VERSION_REGEX: ^\s*<Version>(.*)<\/Version>\s*$
# Useful with external providers like Nerdbank.GitVersioning, ignores VERSION_FILE_PATH & VERSION_REGEX
# VERSION_STATIC: 1.0.0
# Flag to toggle git tagging, enabled by default
# TAG_COMMIT: true
# Format of the git tag, [*] gets replaced with actual version
# TAG_FORMAT: v*
# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.NUGET_KEY}}
# NuGet server uri hosting the packages, defaults to https://api.nuget.org
# NUGET_SOURCE: https://api.nuget.org
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false

80
.github/workflows/publish-pipeline.yml vendored Normal file
View File

@@ -0,0 +1,80 @@
name: Publish pipeline
on:
workflow_dispatch:
release:
types: [published]
permissions: write-all
jobs:
test-pipeline:
name: 'Invoke the test pipeline'
uses: ./.github/workflows/test-pipeline.yml
secrets: inherit
#Deploy package
publish-package:
name: 'Build and publish package'
needs: test-pipeline
runs-on: [self-hosted, linux, x64, womed-local-linux]
steps:
- uses: actions/checkout@v3
- name: Parse version tag
run: |
VERSION=${{ github.ref_name }}
echo "VERSION=${VERSION:1}" >> $GITHUB_ENV
- name: Set .csproj version to ${{ env.VERSION }}
run: |
sed -i 's/<Version>[0-9].[0-9].[0-9]<\/Version>/<Version>${{ env.VERSION }}<\/Version>/g' MewtocolNet/MewtocolNet.csproj
less MewtocolNet/MewtocolNet.csproj
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build as ${{ env.VERSION }}
run: dotnet build "MewtocolNet" --no-incremental
- name: Pack as ${{ env.VERSION }}
run: dotnet pack "MewtocolNet"
- name: Publish as ${{ env.VERSION }}
run: |
cd '${{ github.workspace }}/Builds'
ls -l
dotnet nuget push "*.nupkg" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/WOmed/index.json"
- name: 'Upload package to latest release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: "${{ github.event.release.upload_url }}"
asset_path: ${{ github.workspace }}/Builds/Mewtocol.NET.${{ env.VERSION }}.nupkg
asset_name: Mewtocol.NET.${{ env.VERSION }}.nupkg
asset_content_type: application/zip
- name: Load cached test results
uses: actions/cache/restore@v3
with:
key: coverage-data
path: |
${{ github.workspace }}/MewtocolTests/TestResults
- name: 'Upload coverage xml to latest release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: "${{ github.event.release.upload_url }}"
asset_path: '${{ github.workspace }}/MewtocolTests/TestResults/coverage.opencover.xml'
asset_name: coverage.opencover.xml
asset_content_type: application/xml

57
.github/workflows/test-pipeline.yml vendored Normal file
View File

@@ -0,0 +1,57 @@
name: Test pipeline
on:
workflow_dispatch:
workflow_call:
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 '${{ github.workspace }}/MewtocolTests'
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/
#Upload to codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Cache test results
uses: actions/cache/save@v3
with:
key: coverage-data
path: |
${{ github.workspace }}/MewtocolTests/TestResults

View File

@@ -9,6 +9,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

View File

@@ -1,6 +1,7 @@
[![Build pipeline](https://github.com/WOmed/MewtocolNet/actions/workflows/build-pipeline.yml/badge.svg)](https://github.com/WOmed/MewtocolNet/actions/workflows/build-pipeline.yml)
[![Publish pipeline](https://github.com/WOmed/MewtocolNet/actions/workflows/publish-pipeline.yml/badge.svg)](https://github.com/WOmed/MewtocolNet/actions/workflows/publish-pipeline.yml)
[![Test pipeline](https://github.com/WOmed/MewtocolNet/actions/workflows/test-pipeline.yml/badge.svg)](https://github.com/WOmed/MewtocolNet/actions/workflows/test-pipeline.yml)
[![Nuget](https://img.shields.io/nuget/v/Mewtocol.NET)](https://www.nuget.org/packages/Mewtocol.NET)
![Lines of code](https://img.shields.io/tokei/lines/github/WOmed/MewtocolNet)
[![codecov](https://codecov.io/gh/WOmed/MewtocolNet/branch/master/graph/badge.svg?token=M50U8EZPC6)](https://codecov.io/gh/WOmed/MewtocolNet)
![GitHub](https://img.shields.io/github/license/WOmed/MewtocolNet)
![Status](https://img.shields.io/badge/Status-In%20dev-orange)
@@ -141,8 +142,6 @@ await plc.ConnectAsync(
## Writing data registers / contacts
⚠ **Never set a register by setting the property, always use one of the provided methods**
Registers are stored in an underlying layer for automatic handling, each register has a unique name and address.
Classes that derive from `RegisterCollectionBase` reference these registers automatically using attributes.