# CI for the v2 branch — runs on every push + PR to the v2-akka-fuse / master
# branches. Layered into three jobs:
#   build           dotnet restore + build (fast feedback on compile errors)
#   unit-tests      every v2 unit-test project
#   integration     2-node Host.IntegrationTests harness
#
# Skips E2E (Category=E2E) — that runs nightly via v2-e2e.yml against the full
# four-node docker-dev stack.
#
# Compatible with both GitHub Actions and Gitea Actions (act_runner). The .NET 10
# SDK is pinned via global.json at the repo root; if no global.json exists, the
# setup-dotnet step falls back to dotnet-version below.

name: v2-ci

on:
  push:
    branches: [v2-akka-fuse, master]
  pull_request:
    branches: [v2-akka-fuse, master]
  workflow_dispatch: {}

env:
  DOTNET_NOLOGO: "1"
  DOTNET_CLI_TELEMETRY_OPTOUT: "1"

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 10.0.x
      - name: dotnet restore
        run: dotnet restore ZB.MOM.WW.OtOpcUa.slnx
      - name: dotnet build
        run: dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-restore --configuration Release

  unit-tests:
    needs: build
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        project:
          - tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests
          - tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests
          - tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests
          - tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests
          - tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 10.0.x
      - name: dotnet test ${{ matrix.project }}
        run: dotnet test ${{ matrix.project }} --configuration Release --filter "Category!=E2E"

  integration:
    needs: build
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        project:
          - tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests
          - tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 10.0.x
      - name: dotnet test ${{ matrix.project }}
        run: dotnet test ${{ matrix.project }} --configuration Release --filter "Category!=E2E"
