Skip to content

Commit

Permalink
test: test slnx
Browse files Browse the repository at this point in the history
  • Loading branch information
joesdu committed Oct 16, 2024
1 parent 5099d0e commit d2589eb
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 36 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:
env:
DOTNET_VERSION: "9.0.x"
TZ: Asia/Shanghai
SOLUTION: EasilyNET.sln
SOLUTION: EasilyNET.slnx
ARTIFACTS: ./artifacts
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,11 +41,6 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore dependencies
run: dotnet restore ${{ env.SOLUTION }}

- name: Build
run: dotnet build ${{ env.SOLUTION }} --no-restore

- name: Test
run: dotnet test ${{ env.SOLUTION }} --no-build --verbosity normal
- name: Build and Test
run: ./Test.ps1
shell: pwsh
2 changes: 2 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
env:
DOTNET_VERSION: "9.0.x"
TZ: Asia/Shanghai
SOLUTION: EasilyNET.slnx
ARTIFACTS: ./artifacts
jobs:
build:
runs-on: ubuntu-latest
Expand Down
51 changes: 29 additions & 22 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,40 @@ function Exec {
}
}

$solution = "EasilyNET.slnx"
$artifacts = ".\artifacts"
# 尝试从环境变量中获取 SOLUTION,如果不存在则使用默认值
$SOLUTION = $env:SOLUTION
if (-not $SOLUTION) {
$SOLUTION = "EasilyNET.slnx"
}
$ARTIFACTS = $env:ARTIFACTS
if (-not $ARTIFACTS) {
$ARTIFACTS = ".\artifacts"
}

if (Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }
if (Test-Path $ARTIFACTS) { Remove-Item $ARTIFACTS -Force -Recurse }

exec { & dotnet clean $solution -c Release }
exec { & dotnet build $solution -c Release }
exec { & dotnet test $solution -c Release --no-build -l trx --verbosity=normal }
exec { & dotnet clean $SOLUTION -c Release }
exec { & dotnet build $SOLUTION -c Release }
exec { & dotnet test $SOLUTION -c Release --no-build -l trx --verbosity=normal }

# Core
exec { & dotnet pack .\src\EasilyNET.Core\EasilyNET.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
# exec { & dotnet pack .\src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj -c Release -o $artifacts --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore\EasilyNET.WebCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore.Swagger\EasilyNET.WebCore.Swagger.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Core\EasilyNET.Core.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
# exec { & dotnet pack .\src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj -c Release -o $ARTIFACTS --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore\EasilyNET.WebCore.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore.Swagger\EasilyNET.WebCore.Swagger.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }

# Framework
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection\EasilyNET.AutoDependencyInjection.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection.Core\EasilyNET.AutoDependencyInjection.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.ExpressMapper\EasilyNET.ExpressMapper.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.AspNetCore\EasilyNET.RabbitBus.AspNetCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.Core\EasilyNET.RabbitBus.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Security\EasilyNET.Security.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection\EasilyNET.AutoDependencyInjection.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.AutoDependencyInjection.Core\EasilyNET.AutoDependencyInjection.Core.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.ExpressMapper\EasilyNET.ExpressMapper.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.AspNetCore\EasilyNET.RabbitBus.AspNetCore.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.RabbitBus.Core\EasilyNET.RabbitBus.Core.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Security\EasilyNET.Security.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }

# Mongo
exec { & dotnet pack .\src\EasilyNET.Mongo.AspNetCore\EasilyNET.Mongo.AspNetCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Mongo.ConsoleDebug\EasilyNET.Mongo.ConsoleDebug.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Mongo.Core\EasilyNET.Mongo.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoDistributedLock\EasilyNET.MongoDistributedLock.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoDistributedLock.AspNetCore\EasilyNET.MongoDistributedLock.AspNetCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoGridFS.AspNetCore\EasilyNET.MongoGridFS.AspNetCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Mongo.AspNetCore\EasilyNET.Mongo.AspNetCore.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Mongo.ConsoleDebug\EasilyNET.Mongo.ConsoleDebug.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.Mongo.Core\EasilyNET.Mongo.Core.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoDistributedLock\EasilyNET.MongoDistributedLock.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoDistributedLock.AspNetCore\EasilyNET.MongoDistributedLock.AspNetCore.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.MongoGridFS.AspNetCore\EasilyNET.MongoGridFS.AspNetCore.csproj -c Release -o $ARTIFACTS --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
1 change: 1 addition & 0 deletions EasilyNET.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<File Path="LICENSE" />
<File Path="Push.ps1" />
<File Path="README.md" />
<File Path="Test.ps1" />
<File Path="ToUTF8.ps1" />
</Folder>
<Folder Name="/src/">
Expand Down
13 changes: 8 additions & 5 deletions Push.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
$scriptName = $MyInvocation.MyCommand.Name
$artifacts = "./artifacts"
$SCRIPTNAME = $MyInvocation.MyCommand.Name
$ARTIFACTS = $env:ARTIFACTS
if (-not $ARTIFACTS) {
$ARTIFACTS = ".\artifacts"
}

if ([string]::IsNullOrEmpty($Env:NUGET_API_KEY)) {
Write-Host "${scriptName}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
Write-Host "${SCRIPTNAME}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
}
else {
Get-ChildItem $artifacts -Filter "*.nupkg" | ForEach-Object {
Write-Host "$($scriptName): Pushing $($_.Name)"
Get-ChildItem $ARTIFACTS -Filter "*.nupkg" | ForEach-Object {
Write-Host "$($SCRIPTNAME): Pushing $($_.Name)"
dotnet nuget push $_ --source $Env:NUGET_URL --api-key $Env:NUGET_API_KEY
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
Expand Down
32 changes: 32 additions & 0 deletions Test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Taken from psake https://github.com/psake/psake

<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
function Exec {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = 1)][scriptblock]$cmd,
[Parameter(Position = 1, Mandatory = 0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}

# 尝试从环境变量中获取 SOLUTION,如果不存在则使用默认值
$SOLUTION = $env:SOLUTION
if (-not $SOLUTION) {
$SOLUTION = "EasilyNET.slnx"
}

exec { & dotnet clean $SOLUTION -c Release }
exec { & dotnet build $SOLUTION -c Release }
exec { & dotnet test $SOLUTION -c Release --no-build -l trx --verbosity=normal }

0 comments on commit d2589eb

Please sign in to comment.