2023-07-17 08:08:20 +00:00
go_bin := " $$ (go env GOPATH)/bin "
gen_authopt_path := " $( go_bin) /protoc-gen-authoption "
gen_zitadel_path := " $( go_bin) /protoc-gen-zitadel "
now := $( shell date --rfc-3339= seconds | sed 's/ /T/' )
2023-09-14 13:30:59 +00:00
VERSION ?= development-$( now)
2023-07-17 08:08:20 +00:00
COMMIT_SHA ?= $( shell git rev-parse HEAD)
2024-02-27 16:29:09 +00:00
ZITADEL_IMAGE ?= zitadel:local
2023-07-17 08:08:20 +00:00
.PHONY : compile
compile : core_build console_build compile_pipeline
2024-02-27 16:29:09 +00:00
.PHONY : docker_image
docker_image : compile
DOCKER_BUILDKIT = 1 docker build -f build/Dockerfile -t $( ZITADEL_IMAGE) .
2023-07-17 08:08:20 +00: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 05:52:59 +00:00
go generate internal/api/ui/login/statik/generate.go
2023-07-17 08:08:20 +00:00
go generate internal/notification/statik/generate.go
go generate internal/statik/generate.go
2023-11-22 10:56:43 +00:00
.PHONY : core_generate_all
core_generate_all :
2024-07-04 06:28:56 +00:00
go install github.com/dmarkham/enumer@v1.5.10 # https://pkg.go.dev/github.com/dmarkham/enumer?tab=versions
2024-01-16 09:27:09 +00: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 06:28:56 +00: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 10:56:43 +00:00
go generate ./...
2023-07-17 08:08:20 +00: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 :
i f e q ( , $( wildcard $ ( gen_authopt_path ) ) )
go install internal/protoc/protoc-gen-authoption/main.go \
&& mv $$ ( go env GOPATH) /bin/main $( gen_authopt_path)
e n d i f
i f e q ( , $( wildcard $ ( gen_zitadel_path ) ) )
go install internal/protoc/protoc-gen-zitadel/main.go \
&& mv $$ ( go env GOPATH) /bin/main $( gen_zitadel_path)
e n d i f
.PHONY : core_grpc_dependencies
core_grpc_dependencies :
2024-07-04 06:28:56 +00:00
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 # 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.4 # 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.20.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.20.0 # https://pkg.go.dev/github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2?tab=versions
2024-03-22 07:10:34 +00:00
go install github.com/envoyproxy/protoc-gen-validate@v1.0.4 # https://pkg.go.dev/github.com/envoyproxy/protoc-gen-validate?tab=versions
2024-07-04 06:28:56 +00:00
go install github.com/bufbuild/buf/cmd/buf@v1.34.0 # https://pkg.go.dev/github.com/bufbuild/buf/cmd/buf?tab=versions
2023-07-17 08:08:20 +00:00
.PHONY : core_api
core_api : core_api_generator core_grpc_dependencies
buf generate
mkdir -p pkg/grpc
cp -r .artifacts/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc/
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 09:46:45 +00:00
$( RM) -r .artifacts/grpc
2023-07-17 08:08:20 +00:00
$( RM) $( gen_authopt_path)
$( RM) $( gen_zitadel_path)
.PHONY : core_unit_test
core_unit_test :
go test -race -coverprofile= profile.cov ./...
2023-08-11 15:36:18 +00:00
.PHONY : core_integration_setup
core_integration_setup :
2023-07-17 08:08:20 +00:00
go build -o zitadel main.go
./zitadel init --config internal/integration/config/zitadel.yaml --config internal/integration/config/${ INTEGRATION_DB_FLAVOR } .yaml
2024-01-25 16:28:20 +00:00
./zitadel setup --masterkeyFromEnv --init-projections --config internal/integration/config/zitadel.yaml --config internal/integration/config/${ INTEGRATION_DB_FLAVOR } .yaml --steps internal/integration/config/zitadel.yaml --steps internal/integration/config/${ INTEGRATION_DB_FLAVOR } .yaml
2023-07-17 08:08:20 +00:00
$( RM) zitadel
2023-08-11 15:36:18 +00:00
.PHONY : core_integration_test
core_integration_test : core_integration_setup
2024-02-19 06:50:37 +00:00
go test -tags= integration -race -p 1 -coverprofile= profile.cov -coverpkg= ./internal/...,./cmd/... ./...
2023-07-17 08:08:20 +00:00
2024-04-05 09:35:49 +00:00
.PHONY : core_integration_test_fast
core_integration_test_fast : core_integration_setup
go test -tags= integration -p 1 ./...
2023-07-17 08:08:20 +00:00
.PHONY : console_lint
console_lint :
cd console && \
yarn lint
2024-02-27 16:29:09 +00:00
.PHONY : core_lint
2023-07-17 08:08:20 +00:00
core_lint :
golangci-lint run \
--timeout 10m \
--config ./.golangci.yaml \
--out-format= github-actions \
2023-07-25 05:52:59 +00:00
--concurrency= $$ ( getconf _NPROCESSORS_ONLN)