2023-07-17 10:08:20 +02:00
go_bin := " $$ (go env GOPATH)/bin"
gen_authopt_path := " $( go_bin) /protoc-gen-authoption"
gen_zitadel_path := " $( go_bin) /protoc-gen-zitadel"
2024-10-28 18:06:57 +05:30
now := $( shell date '+%Y-%m-%dT%T%z' | sed -E 's/.([0-9]{2})([0-9]{2})$$/-\1:\2/' )
2023-09-14 16:30:59 +03:00
VERSION ?= development-$( now)
2023-07-17 10:08:20 +02:00
COMMIT_SHA ?= $( shell git rev-parse HEAD)
2024-02-27 18:29:09 +02:00
ZITADEL_IMAGE ?= zitadel:local
2023-07-17 10:08:20 +02:00
2024-09-06 15:47:57 +03:00
GOCOVERDIR = tmp/coverage
ZITADEL_MASTERKEY ?= MasterkeyNeedsToHave32Characters
2025-04-02 16:53:06 +02:00
export GOCOVERDIR ZITADEL_MASTERKEY
2024-09-06 15:47:57 +03:00
2025-07-02 10:04:19 +02:00
LOGIN_REMOTE_NAME := login
LOGIN_REMOTE_URL ?= https://github.com/zitadel/typescript.git
LOGIN_REMOTE_BRANCH ?= main
2023-07-17 10:08:20 +02:00
.PHONY : compile
compile : core_build console_build compile_pipeline
2024-02-27 18:29:09 +02:00
.PHONY : docker_image
2025-07-02 10:04:19 +02:00
docker_image :
@if [ ! -f ./zitadel ] ; then \
echo "Compiling zitadel binary" ; \
$( MAKE) compile; \
else \
echo "Reusing precompiled zitadel binary" ; \
fi
2024-02-27 18:29:09 +02:00
DOCKER_BUILDKIT = 1 docker build -f build/Dockerfile -t $( ZITADEL_IMAGE) .
2023-07-17 10:08:20 +02:00
.PHONY : compile_pipeline
compile_pipeline : console_move
CGO_ENABLED = 0 go build -o zitadel -v -ldflags= "-s -w -X 'github.com/zitadel/zitadel/cmd/build.commit= $( COMMIT_SHA) ' -X 'github.com/zitadel/zitadel/cmd/build.date= $( now) ' -X 'github.com/zitadel/zitadel/cmd/build.version= $( VERSION) ' "
chmod +x zitadel
.PHONY : core_dependencies
core_dependencies :
go mod download
.PHONY : core_static
core_static :
go install github.com/rakyll/statik@v0.1.7
go generate internal/api/ui/login/static/resources/generate.go
2023-07-25 07:52:59 +02:00
go generate internal/api/ui/login/statik/generate.go
2023-07-17 10:08:20 +02:00
go generate internal/notification/statik/generate.go
go generate internal/statik/generate.go
2023-11-22 12:56:43 +02:00
.PHONY : core_generate_all
core_generate_all :
2024-07-04 08:28:56 +02:00
go install github.com/dmarkham/enumer@v1.5.10 # https://pkg.go.dev/github.com/dmarkham/enumer?tab=versions
2024-01-16 11:27:09 +02:00
go install github.com/rakyll/statik@v0.1.7 # https://pkg.go.dev/github.com/rakyll/statik?tab=versions
go install go.uber.org/mock/mockgen@v0.4.0 # https://pkg.go.dev/go.uber.org/mock/mockgen?tab=versions
2024-07-04 08:28:56 +02:00
go install golang.org/x/tools/cmd/stringer@v0.22.0 # https://pkg.go.dev/golang.org/x/tools/cmd/stringer?tab=versions
2023-11-22 12:56:43 +02:00
go generate ./...
2023-07-17 10:08:20 +02:00
.PHONY : core_assets
core_assets :
mkdir -p docs/apis/assets
go run internal/api/assets/generator/asset_generator.go -directory= internal/api/assets/generator/ -assets= docs/apis/assets/assets.md
.PHONY : core_api_generator
core_api_generator :
ifeq (, $( wildcard $( gen_authopt_path )) )
go install internal/protoc/protoc-gen-authoption/main.go \
&& mv $$ (go env GOPATH)/bin/main $( gen_authopt_path )
endif
ifeq (, $( wildcard $( gen_zitadel_path )) )
go install internal/protoc/protoc-gen-zitadel/main.go \
&& mv $$ (go env GOPATH)/bin/main $( gen_zitadel_path )
endif
.PHONY : core_grpc_dependencies
core_grpc_dependencies :
2024-11-04 10:06:14 +01:00
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.35.1 # https://pkg.go.dev/google.golang.org/protobuf/cmd/protoc-gen-go?tab=versions
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 # https://pkg.go.dev/google.golang.org/grpc/cmd/protoc-gen-go-grpc?tab=versions
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.22.0 # https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway?tab=versions
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.22.0 # https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2?tab=versions
go install github.com/envoyproxy/protoc-gen-validate@v1.1.0 # https://pkg.go.dev/github.com/envoyproxy/protoc-gen-validate?tab=versions
go install github.com/bufbuild/buf/cmd/buf@v1.45.0 # https://pkg.go.dev/github.com/bufbuild/buf/cmd/buf?tab=versions
2025-07-04 10:06:20 -04:00
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.18.1 # https://pkg.go.dev/connectrpc.com/connect/cmd/protoc-gen-connect-go?tab=versions
2023-07-17 10:08:20 +02:00
.PHONY : core_api
core_api : core_api_generator core_grpc_dependencies
buf generate
mkdir -p pkg/grpc
2025-07-04 10:06:20 -04:00
cp -r .artifacts/grpc/github.com/zitadel/zitadel/pkg/grpc/** pkg/grpc/
2023-07-17 10:08:20 +02:00
mkdir -p openapi/v2/zitadel
cp -r .artifacts/grpc/zitadel/ openapi/v2/zitadel
.PHONY : core_build
core_build : core_dependencies core_api core_static core_assets
.PHONY : console_move
console_move :
cp -r console/dist/console/* internal/api/ui/console/static
.PHONY : console_dependencies
console_dependencies :
cd console && \
yarn install --immutable
.PHONY : console_client
console_client :
cd console && \
yarn generate
.PHONY : console_build
console_build : console_dependencies console_client
cd console && \
yarn build
.PHONY : clean
clean :
2023-10-18 11:46:45 +02:00
$( RM) -r .artifacts/grpc
2023-07-17 10:08:20 +02:00
$( RM) $( gen_authopt_path)
$( RM) $( gen_zitadel_path)
2024-09-06 15:47:57 +03:00
$( RM) -r tmp/
2023-07-17 10:08:20 +02:00
.PHONY : core_unit_test
core_unit_test :
2024-09-06 15:47:57 +03:00
go test -race -coverprofile= profile.cov -coverpkg= ./internal/... ./...
.PHONY : core_integration_db_up
core_integration_db_up :
2025-04-15 19:38:25 +03:00
docker compose -f internal/integration/config/docker-compose.yaml up --pull always --wait cache postgres
2024-09-06 15:47:57 +03:00
.PHONY : core_integration_db_down
core_integration_db_down :
docker compose -f internal/integration/config/docker-compose.yaml down
2023-07-17 10:08:20 +02:00
2023-08-11 18:36:18 +03:00
.PHONY : core_integration_setup
core_integration_setup :
2024-09-06 15:47:57 +03:00
go build -cover -race -tags integration -o zitadel.test main.go
mkdir -p $$ { GOCOVERDIR}
2025-04-02 16:53:06 +02:00
GORACE = "halt_on_error=1" ./zitadel.test init --config internal/integration/config/zitadel.yaml --config internal/integration/config/postgres.yaml
GORACE = "halt_on_error=1" ./zitadel.test setup --masterkeyFromEnv --init-projections --config internal/integration/config/zitadel.yaml --config internal/integration/config/postgres.yaml --steps internal/integration/config/steps.yaml
2024-09-06 15:47:57 +03:00
.PHONY : core_integration_server_start
core_integration_server_start : core_integration_setup
GORACE = "log_path=tmp/race.log" \
2025-04-02 16:53:06 +02:00
./zitadel.test start --masterkeyFromEnv --config internal/integration/config/zitadel.yaml --config internal/integration/config/postgres.yaml \
2024-09-06 15:47:57 +03:00
> tmp/zitadel.log 2>& 1 \
& printf $$ ! > tmp/zitadel.pid
.PHONY : core_integration_test_packages
core_integration_test_packages :
2024-09-25 22:40:21 +03:00
go test -race -count 1 -tags integration -timeout 30m $$ ( go list -tags integration ./... | grep "integration_test" )
2024-09-06 15:47:57 +03:00
.PHONY : core_integration_server_stop
core_integration_server_stop :
pid = $$ ( cat tmp/zitadel.pid) ; \
$( RM) tmp/zitadel.pid; \
kill $$ pid; \
if [ -s tmp/race.log.$$ pid ] ; then \
cat tmp/race.log.$$ pid; \
exit 66; \
fi
.PHONY : core_integration_reports
core_integration_reports :
go tool covdata textfmt -i= tmp/coverage -pkg= github.com/zitadel/zitadel/internal/...,github.com/zitadel/zitadel/cmd/... -o profile.cov
2023-08-11 18:36:18 +03:00
.PHONY : core_integration_test
2024-09-06 15:47:57 +03:00
core_integration_test : core_integration_server_start core_integration_test_packages core_integration_server_stop core_integration_reports
2024-04-05 12:35:49 +03:00
2023-07-17 10:08:20 +02:00
.PHONY : console_lint
console_lint :
cd console && \
yarn lint
2024-02-27 18:29:09 +02:00
.PHONY : core_lint
2023-07-17 10:08:20 +02:00
core_lint :
golangci-lint run \
--timeout 10m \
--config ./.golangci.yaml \
--out-format= github-actions \
2023-07-25 07:52:59 +02:00
--concurrency= $$ ( getconf _NPROCESSORS_ONLN)
2025-07-02 10:04:19 +02:00
.PHONY : login_pull
login_pull : login_ensure_remote
@echo "Pulling changes from the 'login' subtree on remote $( LOGIN_REMOTE_NAME) branch $( LOGIN_REMOTE_BRANCH) "
git fetch $( LOGIN_REMOTE_NAME)
git subtree pull --prefix= login $( LOGIN_REMOTE_NAME) $( LOGIN_REMOTE_BRANCH)
.PHONY : login_push
login_push : login_ensure_remote
@echo "Pushing changes to the 'login' subtree on remote $( LOGIN_REMOTE_NAME) branch $( LOGIN_REMOTE_BRANCH) "
git subtree push --prefix= login $( LOGIN_REMOTE_NAME) $( LOGIN_REMOTE_BRANCH)
login_ensure_remote :
@if ! git remote get-url $( LOGIN_REMOTE_NAME) > /dev/null 2>& 1; then \
echo "Adding remote $( LOGIN_REMOTE_NAME) " ; \
git remote add $( LOGIN_REMOTE_NAME) $( LOGIN_REMOTE_URL) ; \
else \
echo "Remote $( LOGIN_REMOTE_NAME) already exists." ; \
fi
@if [ ! -d login ] ; then \
echo "Adding subtree for 'login' from branch $( LOGIN_REMOTE_BRANCH) " ; \
git subtree add --prefix= login $( LOGIN_REMOTE_NAME) $( LOGIN_REMOTE_BRANCH) ; \
else \
echo "Subtree 'login' already exists." ; \
fi
export LOGIN_DIR := ./login/
export LOGIN_BAKE_CLI_ADDITIONAL_ARGS := --set login-*.context= ./login/ --file ./docker-bake.hcl
export ZITADEL_TAG ?= $( ZITADEL_IMAGE)
include login/Makefile
# Intentional override of login_test_acceptance_build
login_test_acceptance_build : docker_image
@echo "Building login test acceptance environment with the local zitadel image"
$( MAKE) login_test_acceptance_build_compose login_test_acceptance_build_bake
login_dev : docker_image typescript_generate login_test_acceptance_build_compose login_test_acceptance_cleanup login_test_acceptance_setup_dev
@echo "Starting login test environment with the local zitadel image"