forked from nhost/hasura-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (68 loc) · 3.06 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
DEV_ENV_PATH=build/dev
DOCKER_DEV_ENV_PATH=$(DEV_ENV_PATH)/docker
GITHUB_REF_NAME?="0.0.0-dev"
VERSION=$(shell echo $(GITHUB_REF_NAME) | sed -e 's/^v//g' -e 's/\//_/g')
.PHONY: help
help: ## Show this help.
@IFS=$$'\n' ; \
lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//'`); \
for line in $${lines[@]}; do \
IFS=$$'#' ; \
split=($$line) ; \
command=`echo $${split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
info=`echo $${split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf "%-38s %s\n" $$command $$info ; \
done
.PHONY: get-version
get-version: ## Return version
@echo $(VERSION) > VERSION
@echo $(VERSION)
.PHONY: tests
tests: dev-env-up check ## Spin environment and run nix flake check
.PHONY: check
check: ## Run nix flake check
./build/nix.sh flake check --print-build-logs
.PHONY: integration-tests
integration-tests: ## Run go test with integration flags
@HASURA_AUTH_BEARER=$(shell make dev-jwt) \
TEST_S3_ACCESS_KEY=$(shell make dev-s3-access-key) \
TEST_S3_SECRET_KEY=$(shell make dev-s3-secret-key) \
GIN_MODE=release \
richgo test -tags=integration $(GOTEST_OPTIONS) ./... # -run=TestGetFileByID
.PHONY: build
build: ## Build application and places the binary under ./result/bin
@echo $(VERSION) > VERSION
./build/nix.sh build --print-build-logs --extra-experimental-features flakes --extra-experimental-features nix-command
.PHONY: build-docker-image
build-docker-image: ## Build docker container for native architecture
@echo $(VERSION) > VERSION
./build/nix-docker-image.sh
docker tag hasura-storage:$(VERSION) hasura-storage:dev
.PHONY: dev-env-up-short
dev-env-up-short: ## Starts development environment without hasura-storage
docker-compose -f ${DOCKER_DEV_ENV_PATH}/docker-compose.yaml up -d postgres graphql-engine minio
.PHONY: dev-env-up-hasura
dev-env-up-hasura: build-docker-image ## Starts development environment but only hasura-storage
docker-compose -f ${DOCKER_DEV_ENV_PATH}/docker-compose.yaml up -d storage
.PHONY: dev-env-up
dev-env-up: dev-env-down dev-env-build ## Starts development environment
docker-compose -f ${DOCKER_DEV_ENV_PATH}/docker-compose.yaml up -d
.PHONY: dev-env-down
dev-env-down: ## Stops development environment
docker-compose -f ${DOCKER_DEV_ENV_PATH}/docker-compose.yaml down
.PHONY: dev-env-build
dev-env-build: build-docker-image ## Builds development environment
docker-compose -f ${DOCKER_DEV_ENV_PATH}/docker-compose.yaml build
.PHONY: dev-jwt
dev-jwt: ## return a jwt valid for development environment
@sh ./$(DEV_ENV_PATH)/jwt-gen/get-jwt.sh
@sleep 2
.PHONY: dev-s3-access-key
dev-s3-access-key: ## return s3 access key for development environment
@docker exec -i hasura-storage-minio bash -c 'echo $$MINIO_ROOT_USER'
.PHONY: dev-s3-secret-key
dev-s3-secret-key: ## restun s3 secret key for development environment
@docker exec -i hasura-storage-minio bash -c 'echo $$MINIO_ROOT_PASSWORD'
.PHONY: migrations-add
migrations-add: ## add a migration with NAME in the migrations folder
migrate create -dir ./migrations/postgres -ext sql -seq $(MIGRATION_NAME)