This repository has been archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathMakefile
91 lines (71 loc) · 2.42 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
# Image URL to use all building/pushing image targets
REGISTRY ?= quay.io
REPOSITORY ?= $(REGISTRY)/kohlstechnology
CONTAINER_IMAGE_TAG ?= latest
COMMIT := $(shell git rev-parse HEAD)
BRANCH := $(shell git symbolic-ref --short -q HEAD || echo HEAD)
DATE := $(shell date -u +%Y%m%d-%H:%M:%S)
VERSION_PKG = github.com/KohlsTechnology/eunomia/version
LDFLAGS := "-X ${VERSION_PKG}.Branch=${BRANCH} -X ${VERSION_PKG}.BuildDate=${DATE} \
-X ${VERSION_PKG}.GitSHA1=${COMMIT}"
export GITHUB_PAGES_DIR ?= /tmp/helm/publish
export GITHUB_PAGES_BRANCH ?= gh-pages
export GITHUB_PAGES_REPO ?= KohlsTechnology/eunomia
export HELM_CHARTS_SOURCE ?= deploy/helm/eunomia-operator
export HELM_CHART_DEST ?= $(GITHUB_PAGES_DIR)
export EUNOMIA_TEST_ENV ?= minikube
.PHONY: all
all: build
.PHONY: clean
clean:
rm -rf build/_output
generate:
./scripts/update-crds.sh
.PHONY: vendor
vendor:
go mod vendor
# Build binary
.PHONY: build
build:
go build -o build/_output/bin/eunomia -ldflags $(LDFLAGS) github.com/KohlsTechnology/eunomia/cmd/manager
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run:
go run ./cmd/manager/main.go
# Run some stuff that should be run before committing, then verify that there are no accidental modifications in the repo,
# which could result in different code being actually compiled than expected based on reading the source.
.PHONY: test-dirty
test-dirty: vendor generate
git diff --exit-code
# TODO: also check that there are no untracked files, e.g. extra .go and .yaml ones
.PHONY: test
test: lint-all test-unit test-e2e
.PHONY: test-e2e
test-e2e:
./scripts/e2e-test.sh
.PHONY: test-unit
test-unit:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
# Install CRDs into a cluster
.PHONY: install
install:
cat deploy/crds/*crd.yaml | kubectl apply -f-
# Make sure goreleaser is working
.PHONY: test-release
test-release:
BRANCH=$(BRANCH) COMMIT=$(COMMIT) DATE=$(DATE) VERSION_PKG=$(VERSION_PKG) goreleaser release --snapshot --skip-publish --rm-dist
.PHONY: golangci-lint
golangci-lint:
golangci-lint run
.PHONY: lint-all
lint-all: golangci-lint
.PHONY: e2e-test-images
e2e-test-images: build
CONTAINER_IMAGE_TAG=$(CONTAINER_IMAGE_TAG) ./scripts/build-images.sh ${REPOSITORY}
# Deploy images to Quay.io
.PHONY: deploy-images
deploy-images: build
docker login -u ${QUAY_USER} -p ${QUAY_TOKEN} ${REGISTRY}
./scripts/build-images.sh ${REPOSITORY} true
.PHONY: release
release: deploy-images