forked from cs3org/reva
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
154 lines (116 loc) · 4.92 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# 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.54.2
CALENS_DIR := $(shell mktemp -d)
$(CALENS):
@mkdir -p $(@D)
CALENS_DIR=`mktemp -d`
git clone --depth 1 --branch v0.2.0 -c advice.detachedHead=false https://github.com/restic/calens.git $(CALENS_DIR)
cd $(CALENS_DIR) && GOBIN=$(@D) go install
rm -rf $(CALENS_DIR)
################################################################################
# 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 = -X github.com/cs3org/reva/cmd/revad.gitCommit=$(GIT_COMMIT) -X github.com/cs3org/reva/cmd/revad.version=$(VERSION) -X github.com/cs3org/reva/cmd/revad.goVersion=$(GO_VERSION) -X github.com/cs3org/reva/cmd/revad.buildDate=$(BUILD_DATE)
.PHONY: revad
revad:
go build -ldflags "$(BUILD_FLAGS)" -o ./cmd/revad/revad ./cmd/revad/main
.PHONY: revad-static
revad-static:
go build -ldflags "-extldflags=-static $(BUILD_FLAGS)" -o ./cmd/revad/revad ./cmd/revad/main
.PHONY: gaia
gaia:
go install github.com/cs3org/gaia@latest
.PHONY: cernbox-revad
cernbox-revad: gaia
gaia build --with github.com/cernbox/reva-plugins --with github.com/cs3org/reva=$(shell pwd) -o ./cmd/revad/revad
.PHONY: revad-ceph
revad-ceph:
go build -ldflags "$(BUILD_FLAGS)" -tags ceph -o ./cmd/revad/revad ./cmd/revad/main
.PHONY: reva
reva:
go build -ldflags "-extldflags=-static $(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) .
.PHONY: docker-eos-full-tests
docker-eos-full-tests:
docker build -f tests/docker/eos-storage/Dockerfile -t eos-full tests/docker/eos-storage
################################################################################
# Test
################################################################################
TEST = litmus-1 litmus-2 acceptance-1 acceptance-2
export REVAD_IMAGE ?= revad-eos
export EOS_FULL_IMAGE ?= eos-full
export PARTS ?= 1
export PART ?= 1
.PHONY: $(TEST)
$(TEST): docker-eos-full-tests docker-revad-eos
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
.PHONY: clean
clean: toolchain-clean docker-clean
rm -rf dist
rm -rf tmp