🎨 格式化代码 #126
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- feat/** | |
paths: | |
- .github/workflows/build.yml | |
- "build/**/*" | |
- "script/**/*" | |
- "sdk/**/*" | |
- "src/**/*" | |
- "test/**/*" | |
pull_request: | |
branches: | |
- master | |
- develop | |
paths: | |
- .github/workflows/build.yml | |
- "build/**/*" | |
- "script/**/*" | |
- "sdk/**/*" | |
- "src/**/*" | |
- "test/**/*" | |
jobs: | |
build-sdk: | |
name: 构建 MSBuild Sdk | |
runs-on: ubuntu-latest | |
steps: | |
- name: 签出仓库 | |
uses: actions/checkout@v3.3.0 | |
with: | |
lfs: true | |
- name: 配置 Nuget 缓存 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: nuget-cache | |
restore-keys: | | |
nuget-cache | |
- name: 配置 .Net 环境 | |
uses: actions/setup-dotnet@v3.2.0 | |
with: | |
global-json-file: ./global.json | |
- name: 还原 | |
shell: pwsh | |
run: |- | |
Get-ChildItem sdk ` | |
| Where-Object { | |
$PSItem -is [System.IO.DirectoryInfo] | |
} ` | |
| ForEach-Object { | |
Write-Output "Restore $($PSItem.Name)" | |
dotnet restore $PSItem.FullName | |
} | |
- name: 打包 | |
shell: pwsh | |
run: |- | |
Get-ChildItem sdk ` | |
| Where-Object { | |
$PSItem -is [System.IO.DirectoryInfo] | |
} ` | |
| ForEach-Object { | |
Write-Output "Pack $($PSItem.Name)" | |
dotnet pack $PSItem.FullName --configuration Release --no-restore --no-build --include-symbols --include-source | |
} | |
- name: 上传 Nuget 包 | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: nuget-packages-sdk | |
path: | | |
sdk/**/bin/Release/*.*nupkg | |
retention-days: 3 | |
build-dotnet: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
name: .Net 构建 ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: 签出仓库 | |
uses: actions/checkout@v3.3.0 | |
with: | |
lfs: true | |
- name: 配置 Nuget 缓存 | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: nuget-cache | |
restore-keys: | | |
nuget-cache | |
- name: 配置 .Net 环境 | |
uses: actions/setup-dotnet@v3.2.0 | |
with: | |
global-json-file: ./global.json | |
- name: 生成解决方案 | |
shell: pwsh | |
run: ./script/Generate-Solutions.ps1 | |
- name: 还原 | |
shell: pwsh | |
run: |- | |
. ./script/Invoke-AllSolutions.ps1 | |
Invoke-AllProject { | |
dotnet restore $args | Out-Default | |
return $LASTEXITCODE | |
} -Echo "Restore ""{0}""" | |
- name: 构建 | |
shell: pwsh | |
run: |- | |
. ./script/Invoke-AllSolutions.ps1 | |
Invoke-AllProject { | |
dotnet build $args --configuration Release --no-restore | Out-Default | |
return $LASTEXITCODE | |
} -Echo "Build ""{0}""" | |
- name: 测试 | |
shell: pwsh | |
run: |- | |
. ./script/Invoke-AllSolutions.ps1 | |
Invoke-AllProject { | |
dotnet test $args --configuration Release --no-build | Out-Default | |
return $LASTEXITCODE | |
} -Echo "Test ""{0}""" | |
- name: 打包 | |
shell: pwsh | |
run: |- | |
. ./script/Invoke-AllSolutions.ps1 | |
Invoke-AllProject { | |
dotnet pack $args --configuration Release --no-restore --no-build --include-symbols --include-source | Out-Default | |
return $LASTEXITCODE | |
} -Echo "Pack ""{0}""" | |
- name: 上传 Nuget 包 | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: nuget-packages-${{ matrix.os }} | |
path: | | |
src/**/bin/Release/*.*nupkg | |
retention-days: 3 | |
- name: 收集测试覆盖率 | |
uses: coverallsapp/github-action@v2 | |
with: | |
flag-name: run-${{ join(matrix.*, '-') }} | |
parallel: true | |
file: ./coverage/lcov.info | |
coverage-upload: | |
needs: build-dotnet | |
if: ${{ always() }} | |
name: 上传测试覆盖率 | |
runs-on: ubuntu-latest | |
steps: | |
- name: 上传测试覆盖率 | |
uses: coverallsapp/github-action@v2 | |
with: | |
parallel-finished: true | |
carryforward: "run-ubuntu-latest,run-windows-latest,run-macos-latest" |