forked from cs3org/reva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (101 loc) · 4.26 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# force makefile to use bash instead of sh.
SHELL := /usr/bin/env bash
.PHONY: all
all: revad reva test-go lint gen-doc
################################################################################
# Toolchain
################################################################################
TOOLCHAIN ?= $(CURDIR)/toolchain
GOLANGCI_LINT ?= $(TOOLCHAIN)/golangci-lint
CALENS ?= $(TOOLCHAIN)/calens
.PHONY: toolchain
toolchain: $(GOLANGCI_LINT) $(CALENS)
$(GOLANGCI_LINT):
@mkdir -p $(@D)
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | BINDIR=$(@D) sh -s v1.50.1
$(CALENS):
@mkdir -p $(@D)
git clone --depth 1 --branch v0.2.0 -c advice.detachedHead=false https://github.com/restic/calens.git /tmp/calens
cd /tmp/calens && GOBIN=$(@D) go install
rm -rf /tmp/calens
################################################################################
# Build
################################################################################
GIT_COMMIT ?= `git rev-parse --short HEAD`
VERSION ?= `git describe --always`
GO_VERSION ?= `go version | awk '{print $$3}'`
BUILD_DATE = `date +%FT%T%z`
BUILD_FLAGS = "`[[ -z "$(STATIC)" ]] && echo "" || echo "-extldflags=-static"` -X main.gitCommit=$(GIT_COMMIT) -X main.version=$(VERSION) -X main.goVersion=$(GO_VERSION) -X main.buildDate=$(BUILD_DATE)"
.PHONY: revad
revad:
go build -ldflags $(BUILD_FLAGS) -o ./cmd/revad/revad ./cmd/revad
.PHONY: revad-ceph
revad-ceph:
go build -ldflags $(BUILD_FLAGS) -tags ceph -o ./cmd/revad/revad ./cmd/revad
.PHONY: reva
reva:
go build -ldflags $(BUILD_FLAGS) -o ./cmd/reva/reva ./cmd/reva
.PHONY: docker-reva
docker-reva:
docker build -f docker/Dockerfile.reva -t reva --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad
docker-revad:
docker build -f docker/Dockerfile.revad -t revad --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad-ceph
docker-revad-ceph:
docker build -f docker/Dockerfile.revad-ceph -t revad-ceph --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad-eos
docker-revad-eos:
docker build -f docker/Dockerfile.revad-eos -t revad-eos --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
################################################################################
# Test
################################################################################
TEST = litmus-1 litmus-2 litmus-3 acceptance-1 acceptance-2 acceptance-3
export REVAD_IMAGE ?= revad
export PARTS ?= 1
export PART ?= 1
.PHONY: $(TEST)
$(TEST): docker-revad
docker compose -f ./tests/docker/docker-compose.yml up --force-recreate --always-recreate-deps --build --abort-on-container-exit -V --remove-orphans --exit-code-from $@ $@
.PHONY: test-go
test-go:
go test $$([[ -z "$(COVER_PROFILE)" ]] && echo "" || echo "-coverprofile=$(COVER_PROFILE)") -race $$(go list ./... | grep -v /tests/integration)
.PHONY: test-integration
test-integration: revad
go test -race ./tests/integration/...
.PHONY: check-changelog
check-changelog: $(CALENS)
ifndef PR
$(error PR is not defined)
else
$(CALENS) | sed -n '/^Changelog for reva unreleased (UNRELEASED)/,/^Details/p' | \
grep -E '^ \* [[:alpha:]]{3} #$(PR): '
endif
.PHONY: lint
lint: $(GOLANGCI_LINT)
@$(GOLANGCI_LINT) run || (echo "Tip: many lint errors can be automatically fixed with \"make lint-fix\""; exit 1)
.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT)
gofmt -w .
$(GOLANGCI_LINT) run --fix
################################################################################
# Release
################################################################################
.PHONY: gen-doc
gen-doc:
go run tools/generate-documentation/main.go
dist: gen-doc
go run tools/create-artifacts/main.go -version $(VERSION) -commit $(GIT_COMMIT) -goversion $(GO_VERSION)
################################################################################
# Clean
################################################################################
.PHONY: toolchain-clean
toolchain-clean:
rm -rf $(TOOLCHAIN)
.PHONY: docker-clean
docker-clean:
docker compose -f ./tests/docker/docker-compose.yml down --rmi local -v --remove-orphans
docker rmi $(REVAD_IMAGE)
.PHONY: clean
clean: toolchain-clean docker-clean
rm -rf dist