From c6e97fe8878a1b3f3ac493777829464ecbd48075 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Fri, 4 Jan 2019 17:20:34 +0300 Subject: [PATCH] build by Make --- .teamcity/settings.kts | 12 ++---------- Makefile | 36 ++++++++++++++++++++++++++++++++++++ build.sh | 16 ---------------- docker-compose.yml | 4 ++-- test.sh | 7 ------- 5 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 Makefile delete mode 100755 build.sh delete mode 100755 test.sh diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index e89c7fb8f..453c1859f 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -72,7 +72,7 @@ object Build : BuildType({ steps { script { name = "Build" - scriptContent = "./build.sh" + scriptContent = "make build -j 3" dockerImage = golangImage dockerPull = true } @@ -84,15 +84,7 @@ object Build : BuildType({ script { name = "Test" - scriptContent = """ - set -eux - - go test -c ./driver - go test -c ./iso - go test -c ./clone - - ./test.sh | go-test-teamcity - """.trimIndent() + scriptContent = "make test | go-test-teamcity" dockerImage = golangImage dockerPull = true dockerRunParameters = "--network=container:vpn" diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..5e32f679e --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +GOOPTS := GOARCH=amd64 CGO_ENABLED=0 + +build: iso clone + +iso: iso-linux iso-windows iso-macos +clone: clone-linux clone-windows clone-macos + +iso-linux: modules bin + $(GOOPTS) GOOS=linux go build -o bin/packer-builder-vsphere-iso.linux ./cmd/iso + +iso-windows: modules bin + $(GOOPTS) GOOS=windows go build -o bin/packer-builder-vsphere-iso.exe ./cmd/iso + +iso-macos: modules bin + $(GOOPTS) GOOS=darwin go build -o bin/packer-builder-vsphere-iso.macos ./cmd/iso + +clone-linux: modules bin + $(GOOPTS) GOOS=linux go build -o bin/packer-builder-vsphere-clone.linux ./cmd/clone + +clone-windows: modules bin + $(GOOPTS) GOOS=windows go build -o bin/packer-builder-vsphere-clone.exe ./cmd/clone + +clone-macos: modules bin + $(GOOPTS) GOOS=darwin go build -o bin/packer-builder-vsphere-clone.macos ./cmd/clone + +modules: + go mod download + +bin: + mkdir -p bin + rm -f bin/* + +test: + PACKER_ACC=1 go test -v -count 1 ./driver ./iso ./clone + +.PHONY: bin test diff --git a/build.sh b/build.sh deleted file mode 100755 index 7b61248e3..000000000 --- a/build.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -eux - -export CGO_ENABLED=0 -export GOARCH=amd64 -mkdir -p bin -rm -f bin/* - -GOOS=darwin go build -o bin/packer-builder-vsphere-iso.macos ./cmd/iso -GOOS=linux go build -o bin/packer-builder-vsphere-iso.linux ./cmd/iso -GOOS=windows go build -o bin/packer-builder-vsphere-iso.exe ./cmd/iso - -GOOS=darwin go build -o bin/packer-builder-vsphere-clone.macos ./cmd/clone -GOOS=linux go build -o bin/packer-builder-vsphere-clone.linux ./cmd/clone -GOOS=windows go build -o bin/packer-builder-vsphere-clone.exe ./cmd/clone diff --git a/docker-compose.yml b/docker-compose.yml index 191ca53cd..8d158b02a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - modules:/go/pkg/mod - cache:/root/.cache working_dir: /work - command: ./build.sh + command: make build -j 3 test: image: jetbrainsinfra/golang:1.11.4 @@ -20,7 +20,7 @@ services: environment: VSPHERE_USERNAME: VSPHERE_PASSWORD: - command: ./test.sh + command: make test volumes: modules: diff --git a/test.sh b/test.sh deleted file mode 100755 index 4df8d7782..000000000 --- a/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -eux - -export PACKER_ACC=1 - -go test -v -count 1 -timeout 20m ./driver ./iso ./clone