Commit 2517370c authored by shRabbit's avatar shRabbit
Browse files

添加 GitLab CI/CD 流水线、启用 MTP 测试模式

- .gitlab-ci.yml:build → test → Docker 构建并推送 GitLab Container Registry(仅 master)

- global.json:启用 dotnet test 的 Microsoft.Testing.Platform 模式

- 测试 csproj 清理过期注释

- .gitignore 忽略 CLAUDE.md
parent 33a92537
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4,3 +4,4 @@ obj/
riderModule.iml
/_ReSharper.Caches/
.idea/
CLAUDE.md
 No newline at end of file

.gitlab-ci.yml

0 → 100644
+43 −0
Original line number Diff line number Diff line
# NoCost CI/CD:build → test → Docker 推送到 GitLab Container Registry
stages:
  - build
  - test
  - docker

variables:
  DOTNET_VERSION: "10.0"

build:
  stage: build
  image: mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}
  script:
    - dotnet restore NoCost.slnx
    - dotnet build NoCost.slnx -c Release --no-restore
  artifacts:
    expire_in: 1 day
    paths:
      - src/NoCost/bin/Release/

test:
  stage: test
  image: mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION}
  dependencies: []
  script:
    # 注意:必须使用无参 dotnet test(xunit.v3 + Microsoft.Testing.Platform,依赖 global.json)
    - dotnet test

docker:
  stage: docker
  image: docker:27
  services:
    - docker:27-dind
  variables:
    DOCKER_TLS_CERTDIR: ""
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build -f src/NoCost/Dockerfile -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
    - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE:latest"
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
    - docker push "$CI_REGISTRY_IMAGE:latest"
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'

global.json

0 → 100644
+5 −0
Original line number Diff line number Diff line
{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <!-- xunit.v3 走 Microsoft.Testing.Platform;不再需要 Microsoft.NET.Test.Sdk / xunit.runner.visualstudio -->
        <PackageReference Include="xunit.v3" Version="4.0.0"/>
    </ItemGroup>