mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 14:47:33 +00:00
chore: fix login integration (#10318)
# Which Problems Are Solved Login integration tests are not executed in the pipeline # How the Problems Are Solved The login integration tests are fixed and added as a pipeline workflow. It tests against the built login docker image. On pipeline failures, developers are guided on how to fix them using a dev container configured for this purpose. # Additional Changes - email domains are replaced by example.com. In case the tests were accidentally run against a cloud instance, it wouldn't cause bounces. - pnpm is upgraded, because the --filter argument doesn't work for the install command on the old version. - The login Dockerfile is optimized for docker image builds # Additional Changes From Review for https://github.com/zitadel/zitadel/pull/10305 These changes were requested from @peintnermax - The base dev container starts without any services besides the database and the dev container itself - CONTRIBUTING.md is restructured - To reproduce pipeline checks, only the devcontainer CLI and Docker are needed. This is described in the CONTRIBUTING.md - The convenience npm script "generate" is added # Additional Context - Follow-up for PR https://github.com/zitadel/zitadel/pull/10305 - Base for https://github.com/zitadel/zitadel/issues/10277
This commit is contained in:
@@ -8,9 +8,13 @@ ENV SHELL=/bin/bash \
|
||||
PNPM_HOME=/home/node/.local/share/pnpm \
|
||||
PATH=/home/node/.local/share/pnpm:$PATH
|
||||
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get --no-install-recommends install -y \
|
||||
# Cypress dependencies
|
||||
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb && \
|
||||
apt-get clean && \
|
||||
corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack prepare pnpm@9.1.2 --activate
|
||||
corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack prepare pnpm@10.13.1 --activate
|
||||
|
||||
COPY --chown=node:node commands /commands
|
||||
|
||||
USER node
|
||||
|
2
.devcontainer/base/Dockerfile.dockerignore
Normal file
2
.devcontainer/base/Dockerfile.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!commands
|
39
.devcontainer/base/commands/login-integration.post-attach.sh
Executable file
39
.devcontainer/base/commands/login-integration.post-attach.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" == "true" ]; then
|
||||
set -e
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo -e "THANKS FOR CONTRIBUTING TO ZITADEL 🚀"
|
||||
echo
|
||||
echo "Your dev container is configured for fixing login integration tests."
|
||||
echo "The login is running in a separate container with the same configuration."
|
||||
echo "It calls the mock-zitadel container which provides a mocked Zitadel gRPC API."
|
||||
echo
|
||||
echo "Also the test suite is configured correctly."
|
||||
echo "For example, run a single test file:"
|
||||
echo "pnpm cypress run --spec integration/integration/login.cy.ts"
|
||||
echo
|
||||
echo "You can also run the test interactively."
|
||||
echo "However, this is only possible from outside the dev container."
|
||||
echo "On your host machine, run:"
|
||||
echo "cd apps/login"
|
||||
echo "pnpm cypress open"
|
||||
echo
|
||||
echo "If you want to change the login code, you can replace the login container by a hot reloading dev server."
|
||||
echo "docker stop login-integration"
|
||||
echo "pnpm turbo dev"
|
||||
echo "Navigate to the page you want to fix, for example:"
|
||||
echo "http://localhost:3001/ui/v2/login/verify?userId=221394658884845598&code=abc"
|
||||
echo "Change some code and reload the page for instant feedback."
|
||||
echo
|
||||
echo "When you are done, make sure all integration tests pass:"
|
||||
echo "pnpm cypress run"
|
||||
echo
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
18
.devcontainer/base/commands/login-integration.update-content.sh
Executable file
18
.devcontainer/base/commands/login-integration.update-content.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" == "true" ]; then
|
||||
echo "Running in fail-on-errors mode"
|
||||
set -e
|
||||
fi
|
||||
|
||||
pnpm install --frozen-lockfile \
|
||||
--filter @zitadel/login \
|
||||
--filter @zitadel/client \
|
||||
--filter @zitadel/proto \
|
||||
--filter zitadel-monorepo
|
||||
pnpm cypress install
|
||||
pnpm test:integration:login
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
30
.devcontainer/base/commands/turbo-lint-unit.post-attach.sh
Executable file
30
.devcontainer/base/commands/turbo-lint-unit.post-attach.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" == "true" ]; then
|
||||
set -e
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo -e "THANKS FOR CONTRIBUTING TO ZITADEL 🚀"
|
||||
echo
|
||||
echo "Your dev container is configured for fixing linting and unit tests."
|
||||
echo "No other services are running alongside this container."
|
||||
echo
|
||||
echo "To fix all auto-fixable linting errors, run:"
|
||||
echo "pnpm turbo lint:fix"
|
||||
echo
|
||||
echo "To watch console linting errors, run:"
|
||||
echo "pnpm turbo watch lint --filter console"
|
||||
echo
|
||||
echo "To watch @zitadel/client unit test failures, run:"
|
||||
echo "pnpm turbo watch test:unit --filter @zitadel/client"
|
||||
echo
|
||||
echo "To watch @zitadel/login relevant unit tests and linting failures, run:"
|
||||
echo "pnpm turbo watch lint test:unit --filter @zitadel/login..."
|
||||
echo
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
12
.devcontainer/base/commands/turbo-lint-unit.update-content.sh
Executable file
12
.devcontainer/base/commands/turbo-lint-unit.update-content.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" == "true" ]; then
|
||||
set -e
|
||||
fi
|
||||
|
||||
pnpm install --frozen-lockfile --recursive
|
||||
pnpm turbo lint test:unit
|
||||
|
||||
if [ "$FAIL_COMMANDS_ON_ERRORS" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
|
||||
"name": "devcontainer",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"name": "Base: Build and Run the Components you need",
|
||||
"dockerComposeFile": "docker-compose.yaml",
|
||||
"service": "devcontainer",
|
||||
"runServices": [
|
||||
"devContainer",
|
||||
"db"
|
||||
],
|
||||
"workspaceFolder": "/workspaces",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/go:1": {
|
||||
"version": "1.24"
|
||||
},
|
||||
"ghcr.io/guiyomh/features/golangci-lint:0": {},
|
||||
"ghcr.io/jungaretti/features/make:1": {}
|
||||
"remoteEnv": {
|
||||
"DISPLAY": ""
|
||||
},
|
||||
"forwardPorts": [
|
||||
3000,
|
||||
@@ -17,12 +17,13 @@
|
||||
4200,
|
||||
8080
|
||||
],
|
||||
"onCreateCommand": "pnpm install -g sass@1.64.1",
|
||||
"customizations": {
|
||||
"jetbrains": {
|
||||
"settings": {
|
||||
"com.intellij:app:HttpConfigurable.use_proxy_pac": true
|
||||
}
|
||||
}
|
||||
"onCreateCommand": "pnpm install --frozen-lockfile --recursive --prefer-offline",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/go:1": {
|
||||
"version": "1.24"
|
||||
},
|
||||
"ghcr.io/guiyomh/features/golangci-lint:0": {},
|
||||
"ghcr.io/jungaretti/features/make:1": {},
|
||||
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +1,11 @@
|
||||
x-build-cache: &build-cache
|
||||
cache_from:
|
||||
- type=gha
|
||||
cache_to:
|
||||
- type=gha,mode=max
|
||||
|
||||
services:
|
||||
|
||||
devcontainer:
|
||||
container_name: devcontainer
|
||||
build:
|
||||
context: .
|
||||
<<: *build-cache
|
||||
context: ../base
|
||||
volumes:
|
||||
- ../../:/workspaces:cached
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix:cached
|
||||
- home-dir:/home/node:delegated
|
||||
command: sleep infinity
|
||||
working_dir: /workspaces
|
||||
environment:
|
||||
@@ -39,34 +30,9 @@ services:
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
mock-zitadel:
|
||||
container_name: mock-zitadel
|
||||
build:
|
||||
context: ../../apps/login/integration/core-mock
|
||||
<<: *build-cache
|
||||
ports:
|
||||
- 22220:22220
|
||||
- 22222:22222
|
||||
|
||||
login-integration:
|
||||
container_name: login-integration
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: build/login/Dockerfile
|
||||
<<: *build-cache
|
||||
image: "${LOGIN_TAG:-zitadel-login:local}"
|
||||
env_file: ../../apps/login/.env.test
|
||||
network_mode: service:devcontainer
|
||||
environment:
|
||||
NODE_ENV: test
|
||||
PORT: 3001
|
||||
depends_on:
|
||||
mock-zitadel:
|
||||
condition: service_started
|
||||
|
||||
zitadel:
|
||||
image: "${ZITADEL_TAG:-ghcr.io/zitadel/zitadel:v4.0.0-rc.2}"
|
||||
container_name: zitadel
|
||||
image: "${ZITADEL_TAG:-ghcr.io/zitadel/zitadel:latest}"
|
||||
command: 'start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --config /zitadel.yaml --steps /zitadel.yaml'
|
||||
volumes:
|
||||
- ../../apps/login/acceptance/pat:/pat:delegated
|
||||
@@ -89,7 +55,6 @@ services:
|
||||
build:
|
||||
context: ../../apps/login/acceptance/setup
|
||||
dockerfile: ../go-command.Dockerfile
|
||||
<<: *build-cache
|
||||
entrypoint: "./setup.sh"
|
||||
network_mode: service:devcontainer
|
||||
environment:
|
||||
@@ -111,7 +76,7 @@ services:
|
||||
|
||||
login-acceptance:
|
||||
container_name: login
|
||||
image: "${LOGIN_TAG:-ghcr.io/zitadel/zitadel-login:v4.0.0-rc.2}"
|
||||
image: "${LOGIN_TAG:-ghcr.io/zitadel/zitadel-login:latest}"
|
||||
network_mode: service:devcontainer
|
||||
volumes:
|
||||
- ../../apps/login/.env.test.local:/env-files/.env:cached
|
||||
@@ -126,7 +91,6 @@ services:
|
||||
dockerfile: ../go-command.Dockerfile
|
||||
args:
|
||||
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
|
||||
<<: *build-cache
|
||||
environment:
|
||||
PORT: '3333'
|
||||
command:
|
||||
@@ -151,7 +115,6 @@ services:
|
||||
dockerfile: ../go-command.Dockerfile
|
||||
args:
|
||||
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
|
||||
<<: *build-cache
|
||||
network_mode: service:devcontainer
|
||||
environment:
|
||||
API_URL: 'http://localhost:8080'
|
||||
@@ -175,7 +138,6 @@ services:
|
||||
# dockerfile: ../../go-command.Dockerfile
|
||||
# args:
|
||||
# - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
|
||||
# <<: *build-cache
|
||||
# network_mode: service:devcontainer
|
||||
# environment:
|
||||
# API_URL: 'http://localhost:8080'
|
||||
@@ -197,7 +159,6 @@ services:
|
||||
dockerfile: ../go-command.Dockerfile
|
||||
args:
|
||||
- LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
|
||||
<<: *build-cache
|
||||
network_mode: service:devcontainer
|
||||
environment:
|
||||
API_URL: 'http://localhost:8080'
|
||||
@@ -219,7 +180,6 @@ services:
|
||||
# dockerfile: ../../go-command.Dockerfile
|
||||
# args:
|
||||
# - LOGIN_TEST_ACCEPTANCE_GOLANG_TAG=${LOGIN_TEST_ACCEPTANCE_GOLANG_TAG:-golang:1.24-alpine}
|
||||
# <<: *build-cache
|
||||
# network_mode: service:devcontainer
|
||||
# environment:
|
||||
# API_URL: 'http://localhost:8080'
|
||||
@@ -236,4 +196,3 @@ services:
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
home-dir:
|
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
|
||||
"name": "login-integration-debug",
|
||||
"dockerComposeFile": [
|
||||
"../base/docker-compose.yml",
|
||||
"docker-compose.yml"
|
||||
],
|
||||
"service": "login-integration-debug",
|
||||
"runServices": ["login-integration-debug"],
|
||||
"workspaceFolder": "/workspaces",
|
||||
"forwardPorts": [3001],
|
||||
"onCreateCommand": "pnpm install --recursive",
|
||||
"postAttachCommand": "pnpm turbo daemon clean; pnpm turbo @zitadel/login#dev test:integration:login:debug",
|
||||
"customizations": {
|
||||
"jetbrains": {
|
||||
"settings": {
|
||||
"com.intellij:app:HttpConfigurable.use_proxy_pac": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
services:
|
||||
login-integration-debug:
|
||||
extends:
|
||||
file: ../base/docker-compose.yml
|
||||
service: devcontainer
|
||||
container_name: login-integration-debug
|
||||
depends_on:
|
||||
mock-zitadel:
|
||||
condition: service_started
|
@@ -1,19 +1,26 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
|
||||
"name": "login-integration",
|
||||
"name": "Login Integration",
|
||||
"dockerComposeFile": [
|
||||
"../base/docker-compose.yml"
|
||||
"./docker-compose.yaml"
|
||||
],
|
||||
"service": "devcontainer",
|
||||
"runServices": ["login-integration"],
|
||||
"workspaceFolder": "/workspaces",
|
||||
"forwardPorts": [3001],
|
||||
"onCreateCommand": "pnpm install --frozen-lockfile --recursive && cd apps/login/packages/integration && pnpm cypress install && pnpm test:integration:login",
|
||||
"customizations": {
|
||||
"jetbrains": {
|
||||
"settings": {
|
||||
"com.intellij:app:HttpConfigurable.use_proxy_pac": true
|
||||
}
|
||||
}
|
||||
"service": "login-integration-dev",
|
||||
"runServices": [
|
||||
"login-integration"
|
||||
],
|
||||
"workspaceFolder": "/workspaces/apps/login",
|
||||
"forwardPorts": [
|
||||
22220,
|
||||
22222,
|
||||
3001
|
||||
],
|
||||
"remoteEnv": {
|
||||
"FAIL_COMMANDS_ON_ERRORS": "${localEnv:FAIL_COMMANDS_ON_ERRORS}",
|
||||
"DISPLAY": ""
|
||||
},
|
||||
"updateContentCommand": "/commands/login-integration.update-content.sh",
|
||||
"postAttachCommand": "/commands/login-integration.post-attach.sh",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
|
||||
}
|
||||
}
|
||||
|
35
.devcontainer/login-integration/docker-compose.yaml
Normal file
35
.devcontainer/login-integration/docker-compose.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
services:
|
||||
login-integration-dev:
|
||||
extends:
|
||||
file: ../base/docker-compose.yaml
|
||||
service: devcontainer
|
||||
container_name: login-integration-dev
|
||||
env_file: ../../apps/login/.env.test
|
||||
environment:
|
||||
CORE_MOCK_STUBS_URL: http://localhost:22220/v1/stubs
|
||||
LOGIN_BASE_URL: http://localhost:3001/ui/v2/login
|
||||
CYPRESS_CACHE_FOLDER: /workspaces/.artifacts/cypress
|
||||
network_mode: service:mock-zitadel
|
||||
depends_on:
|
||||
login-integration:
|
||||
condition: service_healthy
|
||||
|
||||
login-integration:
|
||||
container_name: login-integration
|
||||
image: "${LOGIN_TAG:-ghcr.io/zitadel/zitadel-login:latest}"
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: build/login/Dockerfile
|
||||
env_file: ../../apps/login/.env.test
|
||||
network_mode: service:mock-zitadel
|
||||
|
||||
mock-zitadel:
|
||||
container_name: mock-zitadel
|
||||
build:
|
||||
context: ../../apps/login/integration/core-mock
|
||||
additional_contexts:
|
||||
- zitadel-protos=../../proto
|
||||
ports:
|
||||
- 22220:22220
|
||||
- 22222:22222
|
||||
- 3001:3001
|
22
.devcontainer/login-subtree/devcontainer.json
Normal file
22
.devcontainer/login-subtree/devcontainer.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.base.schema.json",
|
||||
"image": "mcr.microsoft.com/devcontainers/typescript-node:20-bookworm",
|
||||
"name": "Login Subtree Container - Use the Login As If You Would Have Forked the Mirror Repo",
|
||||
"workspaceFolder": "/login",
|
||||
"workspaceMount": "source=${localWorkspaceFolder}/apps/login,target=/login,type=bind,consistency=cached",
|
||||
"mounts": [],
|
||||
"forwardPorts": [
|
||||
22220,
|
||||
22222,
|
||||
3000,
|
||||
3001
|
||||
],
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/go:1": {
|
||||
"version": "1.24"
|
||||
},
|
||||
"ghcr.io/guiyomh/features/golangci-lint:0": {},
|
||||
"ghcr.io/jungaretti/features/make:1": {},
|
||||
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
|
||||
"name": "turbo-lint-unit-debug",
|
||||
"dockerComposeFile": [
|
||||
"../base/docker-compose.yml",
|
||||
"docker-compose.yml"
|
||||
],
|
||||
"service": "turbo-lint-unit-debug",
|
||||
"runServices": ["turbo-lint-unit-debug"],
|
||||
"workspaceFolder": "/workspaces",
|
||||
"forwardPorts": [3001],
|
||||
"onCreateCommand": "pnpm install --recursive",
|
||||
"postAttachCommand": "pnpm turbo daemon clean; pnpm turbo watch lint test:unit",
|
||||
"customizations": {
|
||||
"jetbrains": {
|
||||
"settings": {
|
||||
"com.intellij:app:HttpConfigurable.use_proxy_pac": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
services:
|
||||
turbo-lint-unit-debug:
|
||||
extends:
|
||||
file: ../base/docker-compose.yml
|
||||
service: devcontainer
|
||||
container_name: turbo-lint-unit-debug
|
@@ -1,18 +1,20 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
|
||||
"name": "turbo-lint-unit",
|
||||
"name": "Turbo Lint and Unit Tests",
|
||||
"dockerComposeFile": [
|
||||
"../base/docker-compose.yml"
|
||||
"../base/docker-compose.yaml"
|
||||
],
|
||||
"service": "devcontainer",
|
||||
"runServices": ["devcontainer"],
|
||||
"runServices": [
|
||||
"devcontainer"
|
||||
],
|
||||
"workspaceFolder": "/workspaces",
|
||||
"postStartCommand": "pnpm install --frozen-lockfile --recursive && pnpm turbo lint test:unit",
|
||||
"customizations": {
|
||||
"jetbrains": {
|
||||
"settings": {
|
||||
"com.intellij:app:HttpConfigurable.use_proxy_pac": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"forwardPorts": [
|
||||
3001
|
||||
],
|
||||
"remoteEnv": {
|
||||
"FAIL_COMMANDS_ON_ERRORS": "${localEnv:FAIL_COMMANDS_ON_ERRORS}"
|
||||
},
|
||||
"updateContentCommand": "/commands/turbo-lint-unit.update-content.sh",
|
||||
"postAttachCommand": "/commands/turbo-lint-unit.post-attach.sh"
|
||||
}
|
Reference in New Issue
Block a user