build.ps1 is now functional
@@ -2,6 +2,17 @@ param (
[string] $cmd = $null
)
+$REPO_PATH = "github.com/sensu/sensu-go"
+
+# source in the environment variables from `go env`
+$env_commands = go env
+ForEach ($env_cmd in $env_commands) {
+ $env_str = $env_cmd -replace "set " -replace ""
+ $env = $env_str.Split("=")
+ $ps_cmd = "`$env:$($env[0]) = ""$($env[1])"""
+ Invoke-Expression $ps_cmd
+}
+
function install_deps
{
go get github.com/axw/gocov/gocov
@@ -11,14 +22,30 @@ function install_deps
go get -u github.com/golang/lint/golint
}
-function build_binary
+function build_binary([string]$goos, [string]$goarch, [string]$bin)
{
- # build binary
+ $outfile = "target/$goos-$goarch/sensu-$bin.exe"
+ $env:GOOS = $goos
+ $env:GOARCH = $goarch
+ go build -o $outfile "$REPO_PATH/$bin/cmd/..."
+
+ return $outfile
}
function build_commands
{
echo "Running build..."
+
+ If (!(Test-Path -Path "bin")) {
+ New-Item -ItemType directory -Path "bin" | out-null
+ }
+
+ ForEach ($bin in "agent","backend") {
+ echo "Building $bin for $env:GOOS-$env:GOARCH"
+ $out = build_binary $env:GOOS $env:GOARCH $bin
+ Remove-Item -Path "bin/$(Split-Path -Leaf $out)" -EA SilentlyContinue
+ cp $out bin
+ }
}
function test_commands
@@ -26,14 +53,6 @@ function test_commands
echo "Running tests..."
gometalinter.v1 --vendor --disable-all --enable=vet --enable=vetshadow --enable=golint --enable=ineffassign --enable=goconst --tests ./...
-}
-
-If ($cmd -eq "deps") {
- install_deps
-}
-ElseIf ($cmd -eq "unit") {
- test_commands
-
If ($LASTEXITCODE -ne 0) {
echo "Linting failed..."
exit 1
@@ -49,6 +68,20 @@ ElseIf ($cmd -eq "unit") {
}
}
}
+
+function e2e_commands
+{
+ echo "Running e2e tests..."
+
+ go test -v $REPO_PATH/testing/e2e
+}
+
+If ($cmd -eq "deps") {
+ install_deps
+}
+ElseIf ($cmd -eq "unit") {
+ test_commands
+}
ElseIf ($cmd -eq "build") {
build_commands
}
