Progmasoft Git

tazel

A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.

Clonegit clone https://git.progmasoft.com/tazel

mainroot / .github / workflows / ci.yml

16.8 KiB · Raw · Log

# SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
# SPDX-License-Identifier: MIT

name: CI

on:
  pull_request:
  push:
    branches:
      - main

permissions:
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

env:
  DOTNET_NOLOGO: "1"
  DOTNET_CLI_TELEMETRY_OPTOUT: "1"
  # A test without its stored snapshot fails here instead of writing one.
  SNAPSHOOTER_STRICT_MODE: "true"

jobs:
  test:
    name: Test (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    permissions:
      contents: read # the checkout
      id-token: write # Codecov takes the coverage with an OIDC token instead of a secret
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-26.04, windows-2025, macos-15]
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
        with:
          global-json-file: global.json

      # Zig for the Zig tests; checked against the SHA-256 that ziglang.org publishes.
      - name: Install Zig
        if: runner.os == 'Linux'
        shell: bash
        run: |
          curl -fsSL -o "$RUNNER_TEMP/zig.tar.xz" https://ziglang.org/download/0.17.1/zig-x86_64-linux-0.17.1.tar.xz
          echo "3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a  $RUNNER_TEMP/zig.tar.xz" | sha256sum -c -
          mkdir -p "$RUNNER_TEMP/zig"
          tar -xJf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig" --strip-components=1
          echo "$RUNNER_TEMP/zig" >> "$GITHUB_PATH"

      # clang on Windows takes the headers and libraries of MSVC from the environment vcvars64 sets.
      - name: Load the MSVC environment
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          $vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property installationPath
          cmd /c "`"$vs\VC\Auxiliary\Build\vcvars64.bat`" >NUL && set" | ForEach-Object {
            if ($_ -match '^(INCLUDE|LIB|LIBPATH|PATH)=(.*)$') { "$($Matches[1])=$($Matches[2])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 }
          }

      # The STL of this Visual Studio needs Clang 22 or newer, which the image does not have: LLVM 23.1.5 from its MSI,
      # checked against the SHA-256 of its release and unpacked by an administrative install, comes first on PATH.
      - name: Restore LLVM
        if: runner.os == 'Windows'
        id: llvm
        uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
        with:
          path: ${{ runner.temp }}/llvm
          key: llvm-23.1.5-win64-msi

      - name: Install LLVM
        if: runner.os == 'Windows' && steps.llvm.outputs.cache-hit != 'true'
        shell: pwsh
        run: |
          $msi = Join-Path $env:RUNNER_TEMP "llvm.msi"
          Invoke-WebRequest -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-23.1.5/LLVM-23.1.5-win64.msi" -OutFile $msi
          $sha = (Get-FileHash -Algorithm SHA256 $msi).Hash.ToLowerInvariant()
          if ($sha -ne "288ab326377157a9e02e6fb9724914cc2b55963882d493a405f31dc66e837c12") { throw "LLVM has the SHA-256 $sha" }
          $llvm = Join-Path $env:RUNNER_TEMP "llvm"
          $process = Start-Process msiexec.exe -ArgumentList "/a", "`"$msi`"", "/qn", "TARGETDIR=`"$llvm`"" -Wait -PassThru
          if ($process.ExitCode -ne 0) { throw "msiexec failed with $($process.ExitCode)" }

      - name: Put LLVM first on PATH
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          $clang = Get-ChildItem -Path (Join-Path $env:RUNNER_TEMP "llvm") -Recurse -Filter clang.exe | Select-Object -First 1
          if ($null -eq $clang) { throw "the LLVM install has no clang.exe" }
          "PATH=$($clang.DirectoryName);${env:PATH}" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8

      # Warnings are errors in every project (Directory.Build.props).
      - name: Build
        run: dotnet build Tazel.slnx -c Release

      # On macOS a run has stopped the whole machine, so that the job ended without a log. There each test class runs
      # in a step of its own; a step's log is kept when it ends, so the class at fault is the first step without one.
      - name: Test ActionCacheTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.ActionCacheTests

      - name: Test ArchiveTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.ArchiveTests

      - name: Test BuildCommandTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.BuildCommandTests

      - name: Test CacheSigningTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.CacheSigningTests

      - name: Test CommandLineTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.CommandLineTests

      - name: Test CoverageTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.CoverageTests

      - name: Test CustomCommandTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.CustomCommandTests

      - name: Test DepfileTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.DepfileTests

      - name: Test DiagnosticTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.DiagnosticTests

      - name: Test EnvsTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.EnvsTests

      - name: Test GlobTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.GlobTests

      - name: Test HelpTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.HelpTests

      - name: Test LabelTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.LabelTests

      - name: Test MarkerTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.MarkerTests

      - name: Test MicroVMBootTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.MicroVMBootTests

      - name: Test MicroVMFilesTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.MicroVMFilesTests

      - name: Test MicroVMProtocolTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.MicroVMProtocolTests

      - name: Test PlannerTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.PlannerTests

      - name: Test PluginLoadingTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.PluginLoadingTests

      - name: Test PluginSdkTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.PluginSdkTests

      - name: Test PortalCommandLineTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.PortalCommandLineTests

      - name: Test PortalTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.PortalTests

      - name: Test ProcessTreeTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.ProcessTreeTests

      - name: Test QueryTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.QueryTests

      - name: Test RemoteCacheTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.RemoteCacheTests

      - name: Test SnapshotTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.SnapshotTests

      - name: Test StepTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.StepTests

      - name: Test TazelOptionsTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.TazelOptionsTests

      - name: Test TestCacheTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.TestCacheTests

      - name: Test WorkspaceTests (macOS)
        if: runner.os == 'macOS'
        timeout-minutes: 10
        run: >-
          dotnet test --project tests/Progmasoft.Tazel.Tests -c Release --no-build --output Detailed
          --filter-class Progmasoft.Tazel.Tests.WorkspaceTests

      - name: Test
        # A test that hangs is named and dumped at 15 minutes, and the run stops itself at 20, before the step's own
        # limit, so the job ends with its log and its files kept instead of being cancelled at the job's limit.
        if: runner.os != 'macOS'
        timeout-minutes: 25
        run: >-
          dotnet test --solution Tazel.slnx -c Release --no-build --coverlet --coverlet-output-format cobertura
          --results-directory artifacts/coverage --hangdump --hangdump-timeout 15m --hangdump-type Mini
          --timeout 20m --diagnostic --diagnostic-output-directory artifacts/diagnostics

      - name: Keep what a failed run left
        if: failure() || cancelled()
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: test-run-${{ matrix.os }}
          path: |
            artifacts/coverage
            artifacts/diagnostics
          retention-days: 14
          if-no-files-found: ignore

      - name: Run the built Tazel
        run: dotnet src/Progmasoft.Tazel/bin/Release/net10.0/tazel.dll version

      - name: Upload coverage
        if: runner.os == 'Linux'
        uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
        with:
          use_oidc: true
          directory: artifacts/coverage
          fail_ci_if_error: false

  reference:
    name: DocFX
    runs-on: ubuntu-26.04
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
        with:
          global-json-file: global.json

      # The reference of the project-file types; every DocFX warning fails it.
      - name: DocFX
        run: |
          dotnet tool restore
          dotnet docfx docs/reference/docfx.json

      - name: Keep the reference
        uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: tazel-reference
          path: artifacts/reference/
          if-no-files-found: error
          retention-days: 7

  microvm:
    name: MicroVM (ubuntu-26.04, KVM)
    runs-on: ubuntu-26.04
    timeout-minutes: 45
    permissions:
      contents: read # the checkout
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
        with:
          global-json-file: global.json

      # The runners have KVM; the device is opened to the runner's user, and virtiofsd and the kernel's build tools are
      # installed from Ubuntu.
      - name: Open KVM and install virtiofsd
        shell: bash
        run: |
          echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm.rules
          sudo udevadm control --reload-rules
          sudo udevadm trigger --name-match=kvm
          sudo apt-get update
          sudo apt-get install -y --no-install-recommends virtiofsd flex bison bc libelf-dev
          ls -l /dev/kvm

      # The kernel's tree, built once per kernel.config and builder; the agent and the initramfs are built every time.
      - name: Restore the kernel build
        uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
        with:
          path: ${{ runner.temp }}/microvm-work/linux-*
          key: microvm-kernel-${{ hashFiles('microvm/kernel.config', 'microvm/build.cs') }}

      - name: Build the MicroVM image
        shell: bash
        run: dotnet run microvm/build.cs -- "$RUNNER_TEMP/microvm-work" "$RUNNER_TEMP/microvm-image"

      - name: Boot it and run commands inside
        shell: bash
        env:
          TAZEL_MICROVM_IMAGE: ${{ runner.temp }}/microvm-image
          TAZEL_REQUIRE_MICROVM: "1"
        run: >-
          dotnet test --solution Tazel.slnx -c Release
          --filter-class 'Progmasoft.Tazel.Tests.MicroVMBootTests'
          --filter-class 'Progmasoft.Tazel.Tests.MicroVMProtocolTests'
          --filter-class 'Progmasoft.Tazel.Tests.MicroVMFilesTests'
          --no-progress