-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (56 loc) · 2.82 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
SHELL=/bin/bash -o pipefail
export PATH := .bin:${PATH}
GO_DEPENDENCIES = github.com/ory/go-acc \
github.com/ory/x/tools/listx \
github.com/jandelgado/gcov2lcov \
github.com/golang/mock/mockgen
define make-go-dependency
# go install is responsible for not re-building when the code hasn't changed
.bin/$(notdir $1): go.mod go.sum Makefile
GOBIN=$(PWD)/.bin/ go install $1
endef
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))
$(call make-lint-dependency)
.bin/ory: Makefile
bash <(curl https://raw.githubusercontent.com/ory/cli/master/install.sh) -b .bin v0.0.53
touch -a -m .bin/ory
.PHONY: format
format: .bin/goimports node_modules
.bin/goimports -w -local github.com/ory .
npm exec -- prettier --write .
.bin/goimports: Makefile
GOBIN=$(shell pwd)/.bin go install golang.org/x/tools/cmd/goimports@latest
.bin/golangci-lint: Makefile
bash <(curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh) -d -b .bin v1.46.2
.PHONY: test
test:
make resetdb
export TEST_DATABASE_POSTGRESQL=postgres://postgres:[email protected]:3445/hydra?sslmode=disable; export TEST_DATABASE_COCKROACHDB=cockroach://[email protected]:3446/defaultdb?sslmode=disable; export TEST_DATABASE_MYSQL='mysql://root:secret@tcp(127.0.0.1:3444)/mysql?parseTime=true&multiStatements=true'; go test -count=1 -tags sqlite ./...
.PHONY: resetdb
resetdb:
docker kill hydra_test_database_mysql || true
docker kill hydra_test_database_postgres || true
docker kill hydra_test_database_cockroach || true
docker rm -f hydra_test_database_mysql || true
docker rm -f hydra_test_database_postgres || true
docker rm -f hydra_test_database_cockroach || true
docker run --rm --name hydra_test_database_mysql -p 3444:3306 -e MYSQL_ROOT_PASSWORD=secret -d mysql:8.0
docker run --rm --name hydra_test_database_postgres -p 3445:5432 -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=hydra -d postgres:11.8
docker run --rm --name hydra_test_database_cockroach -p 3446:26257 -d cockroachdb/cockroach:v21.1.2 start --insecure
.PHONY: lint
lint: .bin/golangci-lint
GO111MODULE=on golangci-lint run -v ./...
.PHONY: migrations-render
migrations-render: .bin/ory
ory dev pop migration render networkx/migrations/templates networkx/migrations/sql
.PHONY: migrations-render-replace
migrations-render-replace: .bin/ory
ory dev pop migration render -r networkx/migrations/templates networkx/migrations/sql
.PHONY: mocks
mocks: .bin/mockgen
mockgen -package hasherx_test -destination hasherx/mocks_argon2_test.go github.com/ory/x/hasherx Argon2Configurator
mockgen -package hasherx_test -destination hasherx/mocks_bcrypt_test.go github.com/ory/x/hasherx BCryptConfigurator
mockgen -package hasherx_test -destination hasherx/mocks_pkdbf2_test.go github.com/ory/x/hasherx PBKDF2Configurator
node_modules: package-lock.json
npm ci
touch node_modules