-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (122 loc) · 4.98 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
SHELL=/bin/bash -o pipefail
EXECUTABLES = docker-compose docker node npm go
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
export GO111MODULE := on
export PATH := .bin:${PATH}
.PHONY: deps
deps:
ifneq ("$(shell base64 Makefile))","$(shell cat .bin/.lock)")
npm ci
go build -o .bin/go-acc github.com/ory/go-acc
go build -o .bin/goreturns github.com/sqs/goreturns
go build -o .bin/listx github.com/ory/x/tools/listx
go build -o .bin/mockgen github.com/golang/mock/mockgen
go build -o .bin/swagger github.com/go-swagger/go-swagger/cmd/swagger
go build -o .bin/goimports golang.org/x/tools/cmd/goimports
go build -o .bin/ory-dev github.com/ory/meta/tools/ory-dev
go build -o .bin/packr2 github.com/gobuffalo/packr/v2/packr2
go build -o .bin/go-bindata github.com/go-bindata/go-bindata/go-bindata
echo "v0" > .bin/.lock
echo "$$(base64 Makefile)" > .bin/.lock
endif
# Runs full test suite including tests where databases are enabled
.PHONY: test-legacy-migrations
test-legacy-migrations: deps
make test-resetdb
make sqlbin
source scripts/test-env.sh && go test -tags legacy_migration_test -failfast -timeout=20m ./internal/fizzmigrate
docker rm -f hydra_test_database_mysql
docker rm -f hydra_test_database_postgres
docker rm -f hydra_test_database_cockroach
# Runs full test suite including tests where databases are enabled
.PHONY: test
test: deps
make test-resetdb
source scripts/test-env.sh && go-acc ./... -- -failfast -timeout=20m
docker rm -f hydra_test_database_mysql
docker rm -f hydra_test_database_postgres
docker rm -f hydra_test_database_cockroach
# Resets the test databases
.PHONY: test-resetdb
test-resetdb: deps
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:5.7
docker run --rm --name hydra_test_database_postgres -p 3445:5432 -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=postgres -d postgres:9.6
docker run --rm --name hydra_test_database_cockroach -p 3446:26257 -d cockroachdb/cockroach:v2.1.6 start --insecure
# Runs tests in short mode, without database adapters
.PHONY: docker
docker: deps
packr2
CGO_ENABLED=0 GO111MODULE=on GOOS=linux GOARCH=amd64 go build
packr2 clean
docker build -t oryd/hydra:latest .
docker build -f Dockerfile-alpine -t oryd/hydra:latest-alpine .
rm hydra
.PHONY: e2e
e2e: deps test-resetdb
source ./scripts/test-env.sh
./test/e2e/circle-ci.bash memory
./test/e2e/circle-ci.bash memory-jwt
./test/e2e/circle-ci.bash postgres
./test/e2e/circle-ci.bash postgres-jwt
./test/e2e/circle-ci.bash mysql
./test/e2e/circle-ci.bash mysql-jwt
./test/e2e/circle-ci.bash cockroach
./test/e2e/circle-ci.bash cockroach-jwt
./test/e2e/circle-ci.bash plugin
./test/e2e/circle-ci.bash plugin-jwt
# Runs tests in short mode, without database adapters
.PHONY: quicktest
quicktest:
go test -failfast -short ./...
# Formats the code
.PHONY: format
format: deps
goreturns -w -local github.com/ory $$(listx .)
npm run format
# Generates mocks
.PHONY: mocks
mocks: deps
mockgen -package oauth2_test -destination oauth2/oauth2_provider_mock_test.go github.com/ory/fosite OAuth2Provider
# Adds sql files to the binary using go-bindata
.PHONY: sqlbin
sqlbin: deps
cd internal/fizzmigrate/client; go-bindata -o sql_migration_files.go -pkg client ./migrations/sql/...
cd internal/fizzmigrate/consent; go-bindata -o sql_migration_files.go -pkg consent ./migrations/sql/...
cd internal/fizzmigrate/jwk; go-bindata -o sql_migration_files.go -pkg jwk ./migrations/sql/...
cd internal/fizzmigrate/oauth2; go-bindata -o sql_migration_files.go -pkg oauth2 ./migrations/sql/...
# Runs all code generators
.PHONY: gen deps
gen: mocks sqlbin sdk
# Generates the SDKs
.PHONY: sdk
sdk: deps
swagger generate spec -m -o ./.schema/api.swagger.json -x internal/httpclient,gopkg.in/square/go-jose.v2
ory-dev swagger sanitize ./.schema/api.swagger.json
swagger flatten --with-flatten=remove-unused -o ./.schema/api.swagger.json ./.schema/api.swagger.json
swagger validate ./.schema/api.swagger.json
rm -rf internal/httpclient
mkdir -p internal/httpclient
swagger generate client -f ./.schema/api.swagger.json -t internal/httpclient -A Ory_Hydra
make format
.PHONY: install-stable
install-stable: deps
HYDRA_LATEST=$$(git describe --abbrev=0 --tags)
git checkout $$HYDRA_LATEST
packr2
GO111MODULE=on go install \
-ldflags "-X github.com/ory/hydra/cmd.Version=$$HYDRA_LATEST -X github.com/ory/hydra/cmd.Date=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/hydra/cmd.Commit=`git rev-parse HEAD`" \
.
packr2 clean
git checkout master
.PHONY: install
install: deps
packr2
GO111MODULE=on go install .
packr2 clean