-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (90 loc) · 3.36 KB
/
Makefile
File metadata and controls
110 lines (90 loc) · 3.36 KB
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
SHELL = /bin/bash
TAG ?= $(shell git describe --exact-match 2>/dev/null)
COMMIT = $(shell git rev-parse --short=7 HEAD)$(shell [[ $$(git status --porcelain) = "" ]] || echo -dirty)
ARO_IMAGE_BASE = $(RP_IMAGE_ACR).azurecr.io/aroinstaller
ifneq ($(shell uname -s),Darwin)
export CGO_CFLAGS=-Dgpgme_off_t=off_t
endif
ifeq ($(TAG),)
VERSION = $(COMMIT)
else
VERSION = $(TAG)
endif
# default to registry.access.redhat.com for build images on local builds and CI builds without $RP_IMAGE_ACR set.
ifeq ($(RP_IMAGE_ACR),arointsvc)
REGISTRY = arointsvc.azurecr.io
BUILDER_REGISTRY = arointsvc.azurecr.io/openshift-release-dev/golang-builder--partner-share
else ifeq ($(RP_IMAGE_ACR),arosvc)
REGISTRY = arosvc.azurecr.io
BUILDER_REGISTRY = arosvc.azurecr.io/openshift-release-dev/golang-builder--partner-share
else
REGISTRY ?= registry.access.redhat.com
BUILDER_REGISTRY ?= quay.io/openshift-release-dev/golang-builder--partner-share
endif
ARO_IMAGE ?= $(ARO_IMAGE_BASE):$(VERSION)
include .bingo/Variables.mk
.PHONY: build-all
build-all:
go build -tags altinfra,fipscapable,aro,containers_image_openpgp ./...
.PHONY: aro
aro: generate
go build -tags altinfra,fipscapable,aro,containers_image_openpgp,codec.safe ./cmd/aro
.PHONY: clean
clean:
rm -rf aro
find -type d -name 'gomock_reflect_[0-9]*' -exec rm -rf {} \+ 2>/dev/null
.PHONY: generate
generate: install-tools
go generate ./...
.PHONY: image-aro
image-aro:
docker pull $(REGISTRY)/ubi9/ubi-minimal
docker build --platform=linux/amd64 --network=host --no-cache -f Dockerfile.aro -t $(ARO_IMAGE) --build-arg REGISTRY=$(REGISTRY) --build-arg BUILDER_REGISTRY=$(BUILDER_REGISTRY) .
.PHONY: publish-image-aro
publish-image-aro: image-aro
docker push $(ARO_IMAGE)
ifeq ("${RP_IMAGE_ACR}-$(BRANCH)","arointsvc-master")
docker tag $(ARO_IMAGE) arointsvc.azurecr.io/aroinstaller:latest
docker push arointsvc.azurecr.io/aroinstaller:latest
endif
.PHONY: test-go
test-go: generate build-all validate-go lint-go unit-test-go
.PHONY: validate-go
validate-go:
gofmt -s -w cmd hack pkg test
go run ./hack/licenses
@[ -z "$$(ls pkg/util/*.go 2>/dev/null)" ] || (echo error: go files are not allowed in pkg/util, use a subpackage; exit 1)
@[ -z "$$(find -name "*:*")" ] || (echo error: filenames with colons are not allowed on Windows, please rename; exit 1)
go vet -tags containers_image_openpgp ./...
if ! git diff --quiet HEAD; then \
git diff; \
echo "You need to run 'make lint-go-fix' to update the codebase and commit the changes"; \
exit 1; \
fi
.PHONY: validate-fips
validate-fips: $(BINGO)
GOFLAGS="-mod=mod" $(BINGO) get -l fips-detect
GOFLAGS="-mod=mod" $(BINGO) get -l gojq
hack/fips/validate-fips.sh ./aro
.PHONY: unit-test-go
unit-test-go: $(GOTESTSUM)
$(GOTESTSUM) --format pkgname --junitfile report.xml -- -tags=altinfra,aro,containers_image_openpgp -coverprofile=cover.out ./...
.PHONY: lint-go
lint-go: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --verbose
.PHONY: imports
imports: lint-go-fix
.PHONY: lint-go-fix
lint-go-fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --verbose --fix
.PHONY: vendor
vendor:
# See comments in the script for background on why we need it
hack/update-go-module-dependencies.sh
.PHONY: install-tools
install-tools: $(BINGO)
GOFLAGS="-mod=mod" $(BINGO) get -l
# Fixes https://github.com/uber-go/mock/issues/185 for MacOS users
ifeq ($(shell uname -s),Darwin)
codesign -f -s - ${GOPATH}/bin/mockgen
endif