forked from astronomer/astro-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (55 loc) · 3.18 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
GIT_COMMIT_SHORT=$(shell git rev-parse --short HEAD)
VERSION ?= SNAPSHOT-${GIT_COMMIT_SHORT}
LDFLAGS_VERSION=-X github.com/astronomer/astro-cli/version.CurrVersion=${VERSION}
CORE_OPENAPI_SPEC=../astro/apps/core/docs/public/v1alpha1/public_v1alpha1.yaml
OUTPUT ?= astro
# golangci-lint version
GOLANGCI_LINT_VERSION ?=v1.50.1
PWD=$(shell pwd)
## Location to install dependencies to
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
$(ENVTEST_ASSETS_DIR):
mkdir -p $(ENVTEST_ASSETS_DIR)
## Tool Binaries
MOCKERY ?= $(ENVTEST_ASSETS_DIR)/mockery
## Tool versions
MOCKERY_VERSION ?= v2.32.0
.PHONY: kustomize
mockery: $(ENVTEST_ASSETS_DIR)
(test -s $(MOCKERY) && $(MOCKERY) --version | grep -i $(MOCKERY_VERSION)) || GOBIN=$(ENVTEST_ASSETS_DIR) go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
lint:
@test -f ${ENVTEST_ASSETS_DIR}/golangci-lint || curl -sSfL https://github.com/raw/golangci/golangci-lint/master/install.sh | sh -s -- -b ${ENVTEST_ASSETS_DIR} ${GOLANGCI_LINT_VERSION}
${ENVTEST_ASSETS_DIR}/golangci-lint version
${ENVTEST_ASSETS_DIR}/golangci-lint run --timeout 3m0s
build:
go build -o ${OUTPUT} -ldflags "${LDFLAGS_VERSION}" main.go
core_api_gen:
ifeq (, $(shell which oapi-codegen))
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
endif
oapi-codegen -include-tags=User,Organization,Invite,Workspace,Cluster,Options,Team,ApiToken,Deployment,Deploy,Environment -generate=types,client -package=astrocore "${CORE_OPENAPI_SPEC}" > ./astro-client-core/api.gen.go
make mock_astro_core
test:
go test -count=1 -cover -coverprofile=coverage.txt -covermode=atomic ./...
temp-astro:
cd $(shell mktemp -d) && ${PWD}/astro dev init
mock: mockery mock_airflow mock_houston mock_astro mock_pkg mock_astro_core mock_airflow_api
mock_houston:
$(MOCKERY) --filename=ClientInterface.go --output=houston/mocks --dir=houston --outpkg=houston_mocks --name ClientInterface
mock_airflow:
$(MOCKERY) --filename=RegistryHandler.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name RegistryHandler
$(MOCKERY) --filename=ImageHandler.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name ImageHandler
$(MOCKERY) --filename=ContainerHandler.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name ContainerHandler
$(MOCKERY) --filename=DockerComposeAPI.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name DockerComposeAPI
$(MOCKERY) --filename=DockerRegistryAPI.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name DockerRegistryAPI
$(MOCKERY) --filename=DockerCLIClient.go --output=airflow/mocks --dir=airflow --outpkg=mocks --name DockerCLIClient
mock_airflow_api:
$(MOCKERY) --filename=Client.go --output=airflow-client/mocks --dir=airflow-client --outpkg=airflow_mocks --name Client
mock_astro:
$(MOCKERY) --filename=Client.go --output=astro-client/mocks --dir=astro-client --outpkg=astro_mocks --name Client
mock_astro_core:
$(MOCKERY) --filename=client.go --output=astro-client-core/mocks --dir=astro-client-core --outpkg=astrocore_mocks --name ClientWithResponsesInterface
mock_pkg:
$(MOCKERY) --filename=Azure.go --output=pkg/azure/mocks --dir=pkg/azure --outpkg=azure_mocks --name Azure
codecov:
@eval $$(curl -s https://codecov.io/bash)