-
-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathbuild.ps1
More file actions
executable file
·65 lines (55 loc) · 2.13 KB
/
Copy pathbuild.ps1
File metadata and controls
executable file
·65 lines (55 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env pwsh
$ErrorActionPreference = 'Stop'
# Options
$configuration = 'Release'
$artifactsDir = Join-Path (Resolve-Path .) 'artifacts'
$packagesDir = Join-Path $artifactsDir 'Packages'
$testResultsDir = Join-Path $artifactsDir 'Test results'
$logsDir = Join-Path $artifactsDir 'Logs'
# Ensure directories exist
New-Item -ItemType Directory -Force -Path $artifactsDir, $packagesDir, $testResultsDir, $logsDir | Out-Null
$dotnetArgs = @(
'--configuration', $configuration
'/p:CI=' + ($env:CI -or $env:TF_BUILD)
)
# Build
Write-Host "Building..." -ForegroundColor Cyan
dotnet build @dotnetArgs /bl:"$logsDir/build.binlog"
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed with exit code $LASTEXITCODE"
exit 1
}
# Pack
Write-Host "Packing..." -ForegroundColor Cyan
if (Test-Path $packagesDir) {
Remove-Item -Recurse -Force $packagesDir
}
$packProjects = @("src\Shouldly", "src\Shouldly.DiffEngine")
foreach ($project in $packProjects) {
dotnet pack $project --no-build --output $packagesDir @dotnetArgs /bl:"$logsDir/pack-$(Split-Path $project -Leaf).binlog"
if ($LASTEXITCODE -ne 0) {
Write-Error "Pack for $project failed with exit code $LASTEXITCODE"
exit 1
}
}
# Test
Write-Host "Testing..." -ForegroundColor Cyan
if (Test-Path $testResultsDir) {
Remove-Item -Recurse -Force $testResultsDir
}
# Define test projects
$testProjects = @(
"src/Shouldly.Tests/Shouldly.Tests.csproj"
"src/EquivalencyComparisonTests/EquivalencyComparisonTests.csproj"
"src/DocumentationExamples/DocumentationExamples.csproj"
)
# Run tests for each project
foreach ($project in $testProjects) {
Write-Host "Testing $project..." -ForegroundColor Cyan
dotnet test --project $project --no-build @dotnetArgs --results-directory $testResultsDir --report-xunit-trx --report-github --report-github-summary-include-passed --report-github-summary-include-skipped /bl:"$logsDir/test-$(Split-Path $project -Leaf).binlog"
if ($LASTEXITCODE -ne 0) {
Write-Error "Tests for $project failed with exit code $LASTEXITCODE"
exit 1
}
}
Write-Host "Build completed successfully!" -ForegroundColor Green