Skip to content

Browse → read/write → subscribe → method call end-to-end tests #79

Browse → read/write → subscribe → method call end-to-end tests

Browse → read/write → subscribe → method call end-to-end tests #79

Workflow file for this run

name: build-and-test
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.0.x"
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
- name: Start OPC UA Reference Server
run: |
docker compose up -d opcua-refserver
echo "Waiting for OPC UA Reference Server to be ready..."
sleep 10
docker compose ps
- name: Test
run: dotnet test --no-build -c Release --collect:"XPlat Code Coverage" --logger "trx;LogFileName=test-results.trx"
env:
ALLURE_RESULTS_DIRECTORY: tests/PlcLab.Web.Tests/allure-results
- name: Stop OPC UA Reference Server
if: always()
run: docker compose down
- name: Collect coverage artifacts
shell: bash
run: |
mkdir -p coverage
find . -path "*TestResults*" -name "coverage.cobertura.xml" -print -exec cp {} coverage/ \; || true
if [ "$(ls -A coverage 2>/dev/null)" = "" ]; then
echo "No coverage files found" > coverage/NO_COVERAGE.txt
fi
- name: Upload coverage artifact
uses: actions/upload-artifact@v6
with:
name: coverage-cobertura
path: coverage
- name: Publish Web App
run: dotnet publish src/PlcLab.Web -c Release -o out
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max