-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
161 lines (134 loc) · 5.48 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
SHELL=/bin/bash -o pipefail
export GO111MODULE := on
export PATH := .bin:${PATH}
export PWD := $(shell pwd)
GO_DEPENDENCIES = github.com/ory/go-acc \
golang.org/x/tools/cmd/goimports \
github.com/golang/mock/mockgen \
github.com/go-swagger/go-swagger/cmd/swagger \
github.com/go-bindata/go-bindata/go-bindata
define make-go-dependency
# go install is responsible for not re-building when the code hasn't changed
.bin/$(notdir $1): go.sum go.mod
GOBIN=$(PWD)/.bin/ go install $1
endef
.bin/golangci-lint: Makefile
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))
node_modules: package.json
npm ci
.PHONY: .bin/yq
.bin/yq:
go build -o .bin/yq github.com/mikefarah/yq/v4
.bin/clidoc: go.mod
go build -o .bin/clidoc ./cmd/clidoc/.
docs/cli: .bin/clidoc
clidoc .
.bin/ory: Makefile
bash <(curl https://raw.githubusercontent.com/ory/meta/master/install.sh) -d -b .bin ory v0.1.22
touch -a -m .bin/ory
.PHONY: lint
lint: .bin/golangci-lint
golangci-lint run -v ./...
# Runs full test suite including tests where databases are enabled
.PHONY: test
test: .bin/go-acc
make test-resetdb
source scripts/test-env.sh && go-acc ./... -- -failfast -timeout=20m -tags sqlite
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: node_modules
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 --platform linux/amd64 -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:v20.2.6 start-single-node --insecure
# Build local docker images
.PHONY: docker
docker:
docker build -f .docker/Dockerfile-build -t oryd/hydra:latest-sqlite .
.PHONY: e2e
e2e: node_modules test-resetdb
source ./scripts/test-env.sh
for db in memory postgres mysql cockroach; do \
./test/e2e/circle-ci.bash "$${db}"; \
./test/e2e/circle-ci.bash "$${db}" --jwt; \
done
# Runs tests in short mode, without database adapters
.PHONY: quicktest
quicktest:
go test -failfast -short -tags sqlite ./...
.PHONY: quicktest-hsm
quicktest-hsm:
docker build --progress=plain -f .docker/Dockerfile-hsm --target test-hsm .
# Formats the code
.PHONY: format
format: .bin/goimports node_modules
goimports -w --local github.com/ory .
npm run format
# Generates mocks
.PHONY: mocks
mocks: .bin/mockgen
mockgen -package oauth2_test -destination oauth2/oauth2_provider_mock_test.go github.com/ory/fosite OAuth2Provider
# Generates the SDKs
.PHONY: sdk
sdk: .bin/swagger .bin/ory node_modules
swagger generate spec -m -o spec/swagger.json \
-c github.com/ory/hydra/client \
-c github.com/ory/hydra/consent \
-c github.com/ory/hydra/health \
-c github.com/ory/hydra/jwk \
-c github.com/ory/hydra/oauth2 \
-c github.com/ory/hydra/x \
-c github.com/ory/x/healthx \
-c github.com/ory/herodot
ory dev swagger sanitize ./spec/swagger.json
swagger validate ./spec/swagger.json
CIRCLE_PROJECT_USERNAME=ory CIRCLE_PROJECT_REPONAME=hydra \
ory dev openapi migrate \
--health-path-tags metadata \
-p https://raw.githubusercontent.com/ory/x/master/healthx/openapi/patch.yaml \
-p file://.schema/openapi/patches/meta.yaml \
-p file://.schema/openapi/patches/health.yaml \
-p file://.schema/openapi/patches/oauth2.yaml \
spec/swagger.json spec/api.json
rm -rf internal/httpclient internal/httpclient-next
mkdir -p internal/httpclient internal/httpclient-next
swagger generate client -f ./spec/swagger.json -t internal/httpclient -A Ory_Hydra
npm run openapi-generator-cli -- generate -i "spec/api.json" \
-g go \
-o "internal/httpclient-next" \
--git-user-id ory \
--git-repo-id hydra-client-go \
--git-host github.com \
-t .schema/openapi/templates/go \
-c .schema/openapi/gen.go.yml
make format
.PHONY: install-stable
install-stable:
HYDRA_LATEST=$$(git describe --abbrev=0 --tags)
git checkout $$HYDRA_LATEST
GO111MODULE=on go install \
-tags sqlite \
-ldflags "-X github.com/ory/hydra/driver/config.Version=$$HYDRA_LATEST -X github.com/ory/hydra/driver/config.Date=`TZ=UTC date -u '+%Y-%m-%dT%H:%M:%SZ'` -X github.com/ory/hydra/driver/config.Commit=`git rev-parse HEAD`" \
.
git checkout master
.PHONY: install
install:
GO111MODULE=on go install -tags sqlite .
.PHONY: contributors
contributors:
printf '# contributors generated by `make contributors`\n\n' > ./CONTRIBUTORS
git log --format="%aN <%aE>" | sort | uniq | grep -v '^dependabot\[bot\]' >> ./CONTRIBUTORS
.PHONY: post-release
post-release: .bin/yq
cat quickstart.yml | yq '.services.hydra.image = "oryd/hydra:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | yq '.services.hydra-migrate.image = "oryd/hydra:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | yq '.services.consent.image = "oryd/hydra-login-consent-node:'$$DOCKER_TAG'"' | sponge quickstart.yml