forked from dcflachs/compose_plugin
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.ps1
More file actions
66 lines (60 loc) · 2.3 KB
/
test.ps1
File metadata and controls
66 lines (60 loc) · 2.3 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
66
param (
[switch] $phpunit,
[switch] $phpstan,
[switch] $shellcheck,
[switch] $bats
)
$runAll = -not ($phpunit -or $phpstan -or $shellcheck -or $bats)
# Runs all PHPUnit tests and fails if any test fails
if ($runAll -or $phpunit) {
Write-Host "Running PHPUnit tests..." -ForegroundColor Yellow
& php vendor/bin/phpunit --configuration phpunit.xml
if ($LASTEXITCODE -ne 0) {
Write-Host "PHPUnit tests failed. Build aborted." -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "All PHPUnit tests passed." -ForegroundColor Green
}
# Run PHPStan static analysis
if ($runAll -or $phpstan) {
if (Test-Path "vendor/bin/phpstan") {
Write-Host "Running PHPStan static analysis..." -ForegroundColor Yellow
& php vendor/bin/phpstan analyse --memory-limit=512M
if ($LASTEXITCODE -ne 0) {
Write-Host "PHPStan static analysis failed. Build aborted." -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "PHPStan static analysis passed." -ForegroundColor Green
} else {
Write-Host "PHPStan not found. Skipping static analysis." -ForegroundColor Yellow
}
}
# Run ShellCheck for shell scripts
if ($runAll -or $shellcheck) {
if (Get-Command shellcheck -ErrorAction SilentlyContinue) {
Write-Host "Running ShellCheck..." -ForegroundColor Yellow
& shellcheck source/compose.manager/scripts/*.sh
if ($LASTEXITCODE -ne 0) {
Write-Host "ShellCheck failed. Build aborted." -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "ShellCheck passed." -ForegroundColor Green
} else {
Write-Host "ShellCheck not found. Skipping shell script lint." -ForegroundColor Yellow
}
}
# Run Bats tests in Docker
if ($runAll -or $bats) {
$batsScript = "tests/framework/bin/run-bats.sh"
if (Test-Path $batsScript) {
Write-Host "Running Bats tests..." -ForegroundColor Yellow
& bash $batsScript tests/unit
if ($LASTEXITCODE -ne 0) {
Write-Host "Bats tests failed. Build aborted." -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "All Bats tests passed." -ForegroundColor Green
} else {
Write-Host "Bats test runner not found. Skipping Bats tests." -ForegroundColor Yellow
}
}