Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make tools indirect dependencies #4345

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
}
}
},
{
"label": "Kratos: install mailhog",
"type": "shell",
"command": "make .bin/MailHog"
},
{
"label": "Kratos: start mailhog",
"type": "shell",
Expand All @@ -44,9 +39,8 @@
"reveal": "always",
"panel": "dedicated"
},
"dependsOn": ["Kratos: install mailhog"],
"isBackground": true,
"command": "${workspaceFolder}/.bin/MailHog -smtp-bind-addr=localhost:8026",
"command": "go tool MailHog -smtp-bind-addr=localhost:8026",
"problemMatcher": {
"pattern": {
"regexp": ""
Expand Down
55 changes: 18 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,10 @@ export VCS_REF := $(shell git rev-parse HEAD)
export QUICKSTART_OPTIONS ?= ""
export IMAGE_TAG := $(if $(IMAGE_TAG),$(IMAGE_TAG),latest)

GO_DEPENDENCIES = github.com/ory/go-acc \
github.com/golang/mock/mockgen \
github.com/go-swagger/go-swagger/cmd/swagger \
golang.org/x/tools/cmd/goimports \
github.com/mattn/goveralls \
github.com/cortesi/modd/cmd/modd \
github.com/mailhog/MailHog

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
GOBIN=$(PWD)/.bin/ go install $1
endef
$(foreach dep, $(GO_DEPENDENCIES), $(eval $(call make-go-dependency, $(dep))))
$(call make-lint-dependency)

.bin/clidoc:
echo "deprecated usage, use docs/cli instead"
go build -o .bin/clidoc ./cmd/clidoc/.

.bin/yq: Makefile
GOBIN=$(PWD)/.bin go install github.com/mikefarah/yq/v4@v4.44.3

.PHONY: docs/cli
docs/cli:
go run ./cmd/clidoc/. .
Expand All @@ -48,7 +29,7 @@ docs/swagger:
npx @redocly/openapi-cli preview-docs spec/swagger.json

.bin/golangci-lint: Makefile
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -d -b .bin v1.61.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -d -b .bin v1.64.8

.bin/hydra: Makefile
bash <(curl https://raw.githubusercontent.com/ory/meta/master/install.sh) -d -b .bin hydra v2.2.0-rc.3
Expand All @@ -69,15 +50,15 @@ lint: .bin/golangci-lint
.bin/buf lint

.PHONY: mocks
mocks: .bin/mockgen
mockgen -mock_names Manager=MockLoginExecutorDependencies -package internal -destination internal/hook_login_executor_dependencies.go github.com/ory/kratos/selfservice loginExecutorDependencies
mocks:
go tool mockgen -mock_names Manager=MockLoginExecutorDependencies -package internal -destination internal/hook_login_executor_dependencies.go github.com/ory/kratos/selfservice loginExecutorDependencies

.PHONY: proto
proto: gen/oidc/v1/state.pb.go

gen/oidc/v1/state.pb.go: proto/oidc/v1/state.proto buf.yaml buf.gen.yaml .bin/buf .bin/goimports
gen/oidc/v1/state.pb.go: proto/oidc/v1/state.proto buf.yaml buf.gen.yaml .bin/buf
.bin/buf generate
.bin/goimports -w gen/
go tool goimports -w gen/

.PHONY: install
install:
Expand All @@ -95,25 +76,25 @@ test-short:
go test -tags sqlite -count=1 -failfast -short ./...

.PHONY: test-coverage
test-coverage: .bin/go-acc .bin/goveralls
go-acc -o coverage.out ./... -- -failfast -timeout=20m -tags sqlite,json1
test-coverage:
go test -coverprofile=coverage.out -failfast -timeout=20m -tags sqlite ./...

.PHONY: test-coverage-next
test-coverage-next: .bin/go-acc .bin/goveralls
go test -short -failfast -timeout=20m -tags sqlite,json1 -cover ./... --args test.gocoverdir="$$PWD/coverage"
test-coverage-next:
go test -short -failfast -timeout=20m -tags sqlite -cover ./... --args test.gocoverdir="$$PWD/coverage"
go tool covdata percent -i=coverage
go tool covdata textfmt -i=./coverage -o coverage.new.out

# Generates the SDK
.PHONY: sdk
sdk: .bin/swagger .bin/ory node_modules
swagger generate spec -m -o spec/swagger.json \
sdk: .bin/ory node_modules
go tool swagger generate spec -m -o spec/swagger.json \
-c github.com/ory/kratos \
-c github.com/ory/x/healthx \
-c github.com/ory/x/crdbx \
-c github.com/ory/x/openapix
ory dev swagger sanitize ./spec/swagger.json
swagger validate ./spec/swagger.json
go tool swagger validate ./spec/swagger.json
CIRCLE_PROJECT_USERNAME=ory CIRCLE_PROJECT_REPONAME=kratos \
ory dev openapi migrate \
--health-path-tags metadata \
Expand Down Expand Up @@ -176,9 +157,9 @@ authors: # updates the AUTHORS file

# Formats the code
.PHONY: format
format: .bin/goimports .bin/ory node_modules .bin/buf
format: .bin/ory node_modules .bin/buf
.bin/ory dev headers copyright --exclude=gen --exclude=internal/httpclient --exclude=internal/client-go --exclude test/e2e/proxy/node_modules --exclude test/e2e/node_modules --exclude node_modules
goimports -w -local github.com/ory .
go tool goimports -w -local github.com/ory .
npm exec -- prettier --write 'test/e2e/**/*{.ts,.js}'
npm exec -- prettier --write '.github'
.bin/buf format --write
Expand Down Expand Up @@ -207,10 +188,10 @@ test-refresh:
UPDATE_SNAPSHOTS=true go test -tags sqlite,json1,refresh -short ./...

.PHONY: post-release
post-release: .bin/yq
cat quickstart.yml | yq '.services.kratos.image = "oryd/kratos:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | yq '.services.kratos-migrate.image = "oryd/kratos:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | yq '.services.kratos-selfservice-ui-node.image = "oryd/kratos-selfservice-ui-node:'$$DOCKER_TAG'"' | sponge quickstart.yml
post-release:
cat quickstart.yml | go tool yq '.services.kratos.image = "oryd/kratos:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | go tool yq '.services.kratos-migrate.image = "oryd/kratos:'$$DOCKER_TAG'"' | sponge quickstart.yml
cat quickstart.yml | go tool yq '.services.kratos-selfservice-ui-node.image = "oryd/kratos-selfservice-ui-node:'$$DOCKER_TAG'"' | sponge quickstart.yml

licenses: .bin/licenses node_modules # checks open-source licenses
.bin/licenses
Expand Down
Loading
Loading