-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
63 lines (45 loc) · 1.45 KB
/
Makefile
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
VERSION := $(shell git describe --dirty --tags --no-contains)
BINARY := nomad-driver-nspawn
PWD := $(shell pwd)
GOPATH := $(shell go env GOPATH)
GO120 := $(GOPATH)/bin/go1.20
GO120_INSTALLED := $(shell $GO120 version 2> /dev/null)
BUILDARGS := build -mod=vendor -a -v -ldflags '-extldflags "-static" -X github.com/JanMa/nomad-driver-nspawn/nspawn.pluginVersion=${VERSION}' -o $(BINARY)
.DELETE_ON_ERROR:
.PHONY: docker-image get tidy vendor test cover clean
build: $(BINARY)
docker-build: docker-image
sudo docker run --rm -e GO111MODULE=on -e GOOS=linux \
-v "${PWD}":/usr/src/nomad-driver-nspawn -w /usr/src/nomad-driver-nspawn golang:1.20-alpine \
go $(BUILDARGS)
$(BINARY): *.go nspawn/*.go | .go120
GO111MODULE=on GOOS=linux $(GO120) $(BUILDARGS)
*.go:
nspawn/*.go:
docker-image:
sudo docker pull golang:1.20-alpine
get: | .go120
GO111MODULE=on $(GO120) get -v
tidy: get | .go120
GO111MODULE=on $(GO120) mod tidy -v
vendor: tidy | .go120
GO111MODULE=on $(GO120) mod vendor -v
nspawn.test: *.go nspawn/*.go | .go120
$(GO120) test -c ./nspawn
test: nspawn.test
sudo ./nspawn.test
nspawn.cover: *.go nspawn/*.go | .go120
$(GO120) test -cover -c ./nspawn -o nspawn.cover
cover: nspawn.cover
sudo ./nspawn.cover
clean:
@rm -rf nomad-driver-nspawn nspawn.test nspawn.cover
.ONESHELL:
.go120:
@echo Installing Go 1.20
cd $$HOME
go install -v golang.org/dl/go1.20@latest
$(GO120) download
cd $$OLDPWD
touch .go120
all: test build