From b3dac52dedc6ca4984dbe34f7d92eb061582ff39 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Wed, 18 Jun 2025 11:54:33 +0200 Subject: [PATCH] quality --- .github/workflows/test.yml | 14 +++---- Makefile | 55 ++++++++++---------------- docker-bake.hcl | 18 ++++----- dockerfiles/login-test-unit.Dockerfile | 1 + 4 files changed, 35 insertions(+), 53 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b071af66bb..cec85ddbfe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,15 +31,11 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - uses: depot/setup-action@v1 - - uses: depot/bake-action@v1 with: - project: jp837jn3fm - push: false - targets: login-lint,login-test-unit,login-test-integration,login-test-acceptance - files: | - docker-bake.hcl - docker-bake-ci.hcl + oidc: true + - run: make login-quality-ci env: # latest if branch is main, otherwise image version which is the pull request number - BUILD_CACHE_KEY: ${{ github.ref == 'refs/heads/main' && 'latest' || fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - - run: make login-quality + BUILDX_CLI: depot + DEPOT_PROJECT_ID: jp837jn3fm + REF_TAG: ${{ github.ref == 'refs/heads/main' && 'latest' || fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} diff --git a/Makefile b/Makefile index 9e39b34802..bf395299b3 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,23 @@ XDG_CACHE_HOME ?= $(HOME)/.cache export CACHE_DIR ?= $(XDG_CACHE_HOME)/zitadel-make -export LOGIN_TAG ?= login:local -export LOGIN_TEST_UNIT_TAG := login-test-unit:local -export LOGIN_TEST_INTEGRATION_TAG ?= login-test-integration:local -export LOGIN_TEST_ACCEPTANCE_TAG := login-test-acceptance:local -export LOGIN_TEST_ACCEPTANCE_SETUP_TAG := login-test-acceptance-setup:local -export LOGIN_TEST_ACCEPTANCE_SINK_TAG := login-test-acceptance-sink:local -export LOGIN_TEST_ACCEPTANCE_OIDCRP_TAG := login-test-acceptance-oidcrp:local -export LOGIN_TEST_ACCEPTANCE_OIDCOP_TAG := login-test-acceptance-oidcop:local -export LOGIN_TEST_ACCEPTANCE_SAMLSP_TAG := login-test-acceptance-samlsp:local -export LOGIN_TEST_ACCEPTANCE_SAMLIDP_TAG := login-test-acceptance-samlidp:local +export BUILDX_CLI ?= docker buildx +export REF_TAG ?= local +export LOGIN_TAG := login:${REF_TAG} +export LOGIN_TEST_UNIT_TAG := login-test-unit:${REF_TAG} +export LOGIN_TEST_INTEGRATION_TAG ?= login-test-integration:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_TAG := login-test-acceptance:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_SETUP_TAG := login-test-acceptance-setup:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_SINK_TAG := login-test-acceptance-sink:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_OIDCRP_TAG := login-test-acceptance-oidcrp:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_OIDCOP_TAG := login-test-acceptance-oidcop:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_SAMLSP_TAG := login-test-acceptance-samlsp:${REF_TAG} +export LOGIN_TEST_ACCEPTANCE_SAMLIDP_TAG := login-test-acceptance-samlidp:${REF_TAG} export POSTGRES_TAG := postgres:17.0-alpine3.19 export GOLANG_TAG := golang:1.24-alpine # TODO: use ghcr.io/zitadel/zitadel:latest export ZITADEL_TAG ?= ghcr.io/zitadel/zitadel:02617cf17fdde849378c1a6b5254bbfb2745b164 -export CORE_MOCK_TAG := core-mock:local +export CORE_MOCK_TAG := core-mock:${REF_TAG} .PHONY: login-help login-help: @@ -31,30 +33,14 @@ login-help: @echo " show-cache-keys - Show all cache keys with image ids and exit codes." @echo " clean-cache-keys - Remove all cache keys." -login-lint-build: - docker buildx bake login-lint +login-lint: + $(BUILDX_CLI) bake login-lint -login-lint-run: - docker run --rm $(LOGIN_LINT_TAG) lint - docker run --rm $(LOGIN_LINT_TAG) format --check - -.PHONY: login-lint -login-lint: login-lint-build -# ./scripts/run_or_skip.sh login-lint-run $(LOGIN_LINT_TAG) - -login-test-unit-build: - docker buildx bake login-test-unit - -login-test-unit-run: - docker run --rm $(LOGIN_TEST_UNIT_TAG) test:unit:standalone - -.PHONY: login-test-unit -login-test-unit: login-test-unit-build - ./scripts/run_or_skip.sh login-test-unit-run $(LOGIN_TEST_UNIT_TAG) +login-test-unit: + $(BUILDX_CLI) bake login-test-unit login-test-integration-build: - docker buildx bake core-mock - docker buildx bake login-test-integration + $(BUILDX_CLI) bake core-mock login-test-integration login-test-integration-run: login-test-integration-cleanup docker compose --file ./apps/login-test-integration/docker-compose.yaml run --rm integration @@ -71,8 +57,7 @@ login-test-integration: login-standalone-build login-test-integration-build login-test-acceptance-build: COMPOSE_BAKE=true docker compose --file ./apps/login-test-acceptance/docker-compose.yaml build - docker buildx bake login-standalone - docker buildx bake login-test-acceptance + $(BUILDX_CLI) bake login-standalone login-test-acceptance login-test-acceptance-run: login-acceptance-cleanup docker compose --file ./apps/login-test-acceptance/docker-compose.yaml run --rm --service-ports acceptance @@ -100,7 +85,7 @@ login-quality: login-lint login-test-unit login-test-integration login-test-acce .PHONY: login-standalone-build login-standalone-build: - docker buildx bake login-standalone + $(BUILDX_CLI) bake login-standalone .PHONY: clean-cache-keys clean-cache-keys: diff --git a/docker-bake.hcl b/docker-bake.hcl index 707208cfb0..b2eb3e1f5d 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -4,13 +4,13 @@ variable "IMAGE_REGISTRY" { default = "ghcr.io/zitadel" } -variable "BUILD_CACHE_KEY" { +variable "REF_TAG" { default = "local" } target "login-pnpm" { cache-from = [ - { "type": "registry", "ref": "${IMAGE_REGISTRY}/login-pnpm-buildcache:${BUILD_CACHE_KEY}" }, + { "type": "registry", "ref": "${IMAGE_REGISTRY}/login-pnpm-buildcache:${REF_TAG}" }, { "type": "registry", "ref": "${IMAGE_REGISTRY}/login-pnpm-buildcache:latest" }, ] dockerfile = "dockerfiles/login-pnpm.Dockerfile" @@ -18,7 +18,7 @@ target "login-pnpm" { target "login-dev-base" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-dev-base-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-dev-base-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-dev-base-buildcache:latest"}, ] dockerfile = "dockerfiles/login-dev-base.Dockerfile" @@ -29,7 +29,7 @@ target "login-dev-base" { target "login-lint" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-lint-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-lint-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-lint-buildcache:latest"}, ] dockerfile = "dockerfiles/login-lint.Dockerfile" @@ -40,7 +40,7 @@ target "login-lint" { target "login-test-unit" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-unit-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-unit-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-unit-buildcache:latest"}, ] dockerfile = "dockerfiles/login-test-unit.Dockerfile" @@ -51,7 +51,7 @@ target "login-test-unit" { target "login-client" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-client-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-client-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-client-buildcache:latest"}, ] dockerfile = "dockerfiles/login-client.Dockerfile" @@ -97,7 +97,7 @@ variable "LOGIN_TEST_INTEGRATION_TAG" { target "login-test-integration" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-integration-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-integration-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-integration-buildcache:latest"}, ] dockerfile = "dockerfiles/login-test-integration.Dockerfile" @@ -114,7 +114,7 @@ variable "LOGIN_TEST_ACCEPTANCE_TAG" { target "login-test-acceptance" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-acceptance-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-acceptance-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-test-acceptance-buildcache:latest"}, ] dockerfile = "dockerfiles/login-test-acceptance.Dockerfile" @@ -132,7 +132,7 @@ variable "LOGIN_TAG" { # We run integration and acceptance tests against the next standalone server for docker. target "login-standalone" { cache-from = [ - {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-buildcache:${BUILD_CACHE_KEY}"}, + {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-buildcache:${REF_TAG}"}, {"type": "registry", "ref": "${IMAGE_REGISTRY}/login-buildcache:latest"}, ] dockerfile = "dockerfiles/login-standalone.Dockerfile" diff --git a/dockerfiles/login-test-unit.Dockerfile b/dockerfiles/login-test-unit.Dockerfile index 6f8070a266..365c843287 100644 --- a/dockerfiles/login-test-unit.Dockerfile +++ b/dockerfiles/login-test-unit.Dockerfile @@ -3,3 +3,4 @@ COPY apps/login/package.json ./apps/login/ RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ pnpm install --frozen-lockfile --workspace-root --filter zitadel-client COPY apps/login ./apps/login +RUN pnpm test:unit:standalone