chore: 增加 sdk:check 并对齐 Go SDK 版本
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
$Skip = { param($n, $r) Write-Host ("skip " + $n + ": " + $r) }
|
||||
|
||||
if (Get-Command go -ErrorAction SilentlyContinue) {
|
||||
Push-Location sdk/go
|
||||
$unfmt = gofmt -l .
|
||||
if ($unfmt) {
|
||||
Write-Host $unfmt
|
||||
Pop-Location
|
||||
exit 1
|
||||
}
|
||||
go vet ./...
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
go test ./...
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
Pop-Location
|
||||
} else {
|
||||
& $Skip "sdk/go" "no go"
|
||||
}
|
||||
|
||||
if ((Get-Command node -ErrorAction SilentlyContinue) -and (Test-Path "sdk/js/node_modules")) {
|
||||
Push-Location sdk/js
|
||||
npx --no-install tsc --noEmit
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
npx --no-install vitest run
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
Pop-Location
|
||||
} else {
|
||||
& $Skip "sdk/js" "no node or node_modules"
|
||||
}
|
||||
|
||||
$py = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $py) {
|
||||
$py = Get-Command python3 -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($py) {
|
||||
$env:PYTHONPATH = (Resolve-Path "sdk/python/src").Path
|
||||
& $py.Source -c "import paho.mqtt.client"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
& $Skip "sdk/python" "no paho-mqtt"
|
||||
} else {
|
||||
& $py.Source -m unittest discover -s sdk/python/tests -t sdk/python
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
}
|
||||
Remove-Item Env:PYTHONPATH -ErrorAction SilentlyContinue
|
||||
} else {
|
||||
& $Skip "sdk/python" "no python"
|
||||
}
|
||||
|
||||
if (Get-Command mvn -ErrorAction SilentlyContinue) {
|
||||
Push-Location sdk/java
|
||||
mvn -q test
|
||||
if ($LASTEXITCODE -ne 0) { Pop-Location; exit $LASTEXITCODE }
|
||||
Pop-Location
|
||||
} else {
|
||||
& $Skip "sdk/java" "no mvn"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
skip() { echo "skip $1: $2"; }
|
||||
|
||||
if command -v go >/dev/null 2>&1; then
|
||||
(cd sdk/go && test -z "$(gofmt -l .)" && go vet ./... && go test ./...)
|
||||
else
|
||||
skip sdk/go "no go"
|
||||
fi
|
||||
|
||||
if command -v node >/dev/null 2>&1 && [ -d sdk/js/node_modules ]; then
|
||||
(cd sdk/js && npx --no-install tsc --noEmit && npx --no-install vitest run)
|
||||
else
|
||||
skip sdk/js "no node or node_modules"
|
||||
fi
|
||||
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
PY=python3
|
||||
elif command -v python >/dev/null 2>&1; then
|
||||
PY=python
|
||||
else
|
||||
PY=
|
||||
fi
|
||||
if [ -n "$PY" ]; then
|
||||
if PYTHONPATH=sdk/python/src "$PY" -c "import paho.mqtt.client" >/dev/null 2>&1; then
|
||||
PYTHONPATH=sdk/python/src "$PY" -m unittest discover -s sdk/python/tests -t sdk/python
|
||||
else
|
||||
skip sdk/python "no paho-mqtt"
|
||||
fi
|
||||
else
|
||||
skip sdk/python "no python"
|
||||
fi
|
||||
|
||||
if command -v mvn >/dev/null 2>&1; then
|
||||
(cd sdk/java && mvn -q test)
|
||||
else
|
||||
skip sdk/java "no mvn"
|
||||
fi
|
||||
Reference in New Issue
Block a user