RPC远程过程调用,二进制封装,提供高吞吐低延迟的高性能RPC框架
大石头 authored at 2022-08-10 13:26:19
8.10 KiB
NewLife.Remoting
name: aot

# AOT 兼容矩阵(参考 NewLife.Core 做法):分析器零告警 + 三工程 NativeAOT 冒烟。
#   NativeAOT 不支持跨 OS 编译,每个 RID 用对应原生 runner 发布运行:
#     win-x64 → windows-latest;linux-x64 → ubuntu-latest;linux-arm64 → ubuntu-24.04-arm(以上为阻断门禁)
#     win-arm64 / osx-arm64 / osx-x64 → 观察期(continue-on-error),平台稳定全绿后逐项转阻断
#   linux-musl-x64 / linux-musl-arm64 → alpine 容器内原生发布运行(观察期)
#   linux-loongarch64(LA64):无 runtime pack、无 NativeAOT;QEMU 下的 JIT 冒烟【2026-10-16 起暂缓】,
#     作业配方保留但默认不执行(if: false),龙芯覆盖由 test.yml 的 LA64 单元测试矩阵承接。
# 触发:push / PR / 手动(workflow_dispatch);不采用夜间定时。

on:
  push:
    branches: [ '*' ]
  pull_request:
    branches: [ '*' ]
  workflow_dispatch:

jobs:
  # 分析器零告警(与 RID 无关)与源生成器单测,win-x64 硬约束
  aot-analyzer:
    name: aot analyzer (win-x64)
    runs-on: windows-latest
    timeout-minutes: 30

    steps:
    - uses: actions/checkout@v4
    - name: Setup dotNET
      uses: actions/setup-dotnet@v4
      with:
        # net8.0 目标需要 8.x SDK 提供对应目标包(runner 镜像已不再预装旧版 SDK)
        dotnet-version: |
          8.x
          10.x
    - name: 分析器零告警构建(-warnaserror 阻断新增告警)
      run: |
        dotnet build NewLife.Remoting/NewLife.Remoting.csproj -f net8.0 -c Release --nologo -warnaserror
        dotnet build NewLife.Remoting/NewLife.Remoting.csproj -f net10.0 -c Release --nologo -warnaserror
        dotnet build NewLife.Remoting.Extensions/NewLife.Remoting.Extensions.csproj -f net8.0 -c Release --nologo -warnaserror
        dotnet build NewLife.Remoting.Extensions/NewLife.Remoting.Extensions.csproj -f net10.0 -c Release --nologo -warnaserror
    - name: 源生成器单元测试
      run: dotnet test XUnitTest.SourceGenerator -c Release --nologo

  # 三工程 NativeAOT 冒烟:AotSmoke(核心链路 23 场景,含多语言词表)、AotSmoke.Web(最小 API 宿主 11 场景)、
  # AotSmoke.XCode(XCode 设备链路 6 场景,EXT-6 后转硬约束)。JIT 基线先行,再原生发布运行(非 0 退出码即失败)。
  aot:
    name: aot (${{ matrix.rid }})
    runs-on: ${{ matrix.os }}
    timeout-minutes: 40
    continue-on-error: ${{ matrix.experimental == true }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - rid: win-x64
            os: windows-latest
            bin: AotSmoke.exe
          - rid: win-arm64
            os: windows-11-arm
            bin: AotSmoke.exe
            experimental: true
          - rid: linux-x64
            os: ubuntu-latest
            bin: AotSmoke
          - rid: linux-arm64
            os: ubuntu-24.04-arm
            bin: AotSmoke
          - rid: osx-arm64
            os: macos-latest
            bin: AotSmoke
            experimental: true
          - rid: osx-x64
            os: macos-15-intel
            bin: AotSmoke
            experimental: true

    steps:
    - uses: actions/checkout@v4
    - name: Setup dotNET
      uses: actions/setup-dotnet@v4
      with:
        dotnet-version: 10.x
    - name: Install NativeAOT Prerequisites (Linux)
      if: runner.os == 'Linux'
      run: sudo apt-get update && sudo apt-get install -y clang zlib1g-dev
    - name: JIT Baseline (23 + 11 + 6 场景)
      run: |
        dotnet run -c Release --project AotSmoke/AotSmoke.csproj
        dotnet run -c Release --project AotSmoke.Web/AotSmoke.Web.csproj
        dotnet run -c Release --project AotSmoke.XCode/AotSmoke.XCode.csproj
    - name: Publish NativeAOT (三工程)
      run: |
        dotnet publish AotSmoke/AotSmoke.csproj -c Release -r ${{ matrix.rid }} -o AotSmoke/bin/aot-out
        dotnet publish AotSmoke.Web/AotSmoke.Web.csproj -c Release -r ${{ matrix.rid }} -o AotSmoke.Web/bin/aot-out
        dotnet publish AotSmoke.XCode/AotSmoke.XCode.csproj -c Release -r ${{ matrix.rid }} -o AotSmoke.XCode/bin/aot-out
    - name: Run NativeAOT Smoke
      shell: bash
      run: |
        if [[ "${{ matrix.bin }}" == "AotSmoke.exe" ]]; then EXT=".exe"; else EXT=""; fi
        ./AotSmoke/bin/aot-out/AotSmoke$EXT
        ./AotSmoke.Web/bin/aot-out/AotSmoke.Web$EXT
        ./AotSmoke.XCode/bin/aot-out/AotSmoke.XCode$EXT

  # NativeAOT 冒烟(musl):alpine 容器内原生发布运行(观察期)。
  # 容器内 actions/setup-dotnet 不可用,改用 dotnet-install.sh;官方要求 alpine 3.15+ 且安装 clang/build-base/zlib-dev
  aot-musl:
    name: aot (${{ matrix.rid }})
    runs-on: ${{ matrix.os }}
    timeout-minutes: 40
    continue-on-error: true
    strategy:
      fail-fast: false
      matrix:
        include:
          - rid: linux-musl-x64
            os: ubuntu-latest
          - rid: linux-musl-arm64
            os: ubuntu-24.04-arm

    steps:
    - uses: actions/checkout@v4
    - name: Publish & Run NativeAOT Smoke (alpine)
      run: |
        docker run --rm -v "$PWD:/src" -w /src alpine:3.20 sh -c '
          set -e
          apk add --no-cache bash curl clang build-base zlib-dev icu-libs >/dev/null
          curl -sSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh
          bash /tmp/dotnet-install.sh --channel 10.0 --install-dir /usr/share/dotnet >/dev/null
          ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
          export DOTNET_CLI_TELEMETRY_OPTOUT=1
          dotnet run -c Release --project AotSmoke/AotSmoke.csproj
          dotnet publish AotSmoke/AotSmoke.csproj -c Release -r ${{ matrix.rid }} -o AotSmoke/bin/aot-out
          ./AotSmoke/bin/aot-out/AotSmoke
        '

  # 龙芯 LA64(linux-loongarch64):无 runtime pack、无 NativeAOT,QEMU 用户态仿真以 JIT 姿态跑核心冒烟。
  # 【2026-10-16 起暂缓】配方保留、默认不执行(if: false):该冒烟在 QEMU 下曾 22/22 通过,但稳定性尚不足以
  #   长期占用 3 小时 runner;龙芯覆盖当前由 test.yml 的 test (linux-la64 qemu) 单元测试矩阵承接。
  #   恢复方式:删除下面那行 if,并同步更新本注释。
  # 配方要点:① tonistiigi/binfmt 注册较新的 qemu-user-static(qemu 10.2.3,含 loong64;9.2.2 的龙芯仿真存在
  #   缺陷,曾在 MSBuild/Regex 处触发内存损坏);② 业务在 loong64 Debian 容器内执行——容器根文件系统的
  #   glibc/ld.so 与龙芯 SDK 匹配(宿主交叉 glibc 曾遇「unexpected reloc type」);③ 龙芯 SDK 由宿主下载后
  #   进入预构建镜像(.github/la64)。还原/运行拆分为独立步骤,便于渐进查看日志;各步骤带重试,
  #   规避 QEMU 仿真的偶发内存/指令缺陷。
  aot-loongarch64:
    name: smoke (linux-la64 qemu)
    if: false
    runs-on: ubuntu-latest
    timeout-minutes: 180
    continue-on-error: true

    steps:
    - uses: actions/checkout@v4
    - name: Initialize binfmt_misc (QEMU 10.2.3)
      run: docker run --rm --privileged tonistiigi/binfmt:qemu-v10.2.3-68 --install all
    - name: Build LoongArch64 SDK image
      run: |
        curl -fL -o .github/la64/dotnet-sdk-10.0.113-linux-loongarch64.tar.gz \
          https://github.com/loongson/dotnet/releases/download/v10.0.113-loongarch64/dotnet-sdk-10.0.113-linux-loongarch64.tar.gz
        for i in 1 2; do
          echo "=== image build attempt $i ==="
          docker build --platform linux/loong64 -t la64-dotnet:10.0.113 .github/la64 && exit 0
          echo "image build attempt $i failed"
        done
        exit 1
    - name: JIT Smoke in LoongArch64 Container (AotSmoke 23 场景)
      run: |
        for i in 1 2 3; do
          echo "=== smoke attempt $i ==="
          docker run --rm --platform linux/loong64 -v "$PWD:/src" -v "$PWD/.qemu/nuget:/nuget" -w /src la64-dotnet:10.0.113 \
            bash -c 'dotnet nuget add source https://lnuget.loongnix.cn/v3/index.json -n loongnuget --allow-insecure-connections || true; dotnet --info; timeout -k 60s 60m dotnet run -c Release --project AotSmoke/AotSmoke.csproj' && exit 0
          echo "smoke attempt $i failed"
        done
        exit 1