This commit is contained in:
Elio Bischof
2025-08-02 05:35:33 +02:00
parent 90dc64a2bb
commit c066e7cd0d
27 changed files with 280 additions and 231 deletions

View File

@@ -14,4 +14,6 @@ RUN apt-get update && \
apt-get clean && \
corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack prepare pnpm@10.13.1 --activate
COPY --chown=node:node commands /commands
USER node

View File

@@ -1 +1,2 @@
*
!commands

View 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

View 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

View 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

View 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

View File

@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Base Container. Install and run Components yourself",
"name": "Base: Build and Run the Components you need",
"dockerComposeFile": "docker-compose.yaml",
"service": "devcontainer",
"runServices": [
@@ -8,6 +8,9 @@
"db"
],
"workspaceFolder": "/workspaces",
"remoteEnv": {
"DISPLAY": ""
},
"forwardPorts": [
3000,
3001,

View File

@@ -2,9 +2,9 @@ services:
devcontainer:
container_name: devcontainer
image: "zitadel-devcontainer-base:local"
build:
context: ../..
dockerfile: .devcontainer/base/Dockerfile
context: ../base
volumes:
- ../../:/workspaces:cached
command: sleep infinity
@@ -12,8 +12,7 @@ services:
environment:
ZITADEL_DATABASE_POSTGRES_HOST: db
ZITADEL_EXTERNALSECURE: false
DISPLAY: ' '
db:
container_name: db
image: postgres:17.0-alpine3.19

View File

@@ -1,20 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Login Integration One-Off Container - Reproduce Pull Request Checks",
"dockerComposeFile": [
"../base/docker-compose.yaml",
"./docker-compose.yaml"
],
"service": "devcontainer",
"runServices": [
"login-integration"
],
"workspaceFolder": "/workspaces",
"forwardPorts": [
22220,
22222,
3001
],
"onCreateCommand": "pnpm --filter @zitadel/login install --frozen-lockfile --dev; pnpm --filter @zitadel/login exec cypress install",
"updateContentCommand": "pnpm --filter @zitadel/login test:integration:login"
}

View File

@@ -1,22 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Login Integration Hot Reload Container - Debug and Fix Pull Request Checks",
"dockerComposeFile": [
"../base/docker-compose.yaml",
"../login-integration-ci/docker-compose.yaml",
"docker-compose.yaml"
],
"service": "login-integration",
"runServices": [
"login-integration"
],
"workspaceFolder": "/workspaces/apps/login",
"forwardPorts": [
22220,
22222,
3001
],
"onCreateCommand": "pnpm install --frozen-lockfile --filter @zitadel/login --filter @zitadel/client --filter @zitadel/proto --filter ../..",
"postStartCommand": "pnpm turbo daemon clean || true; (pnpm turbo @zitadel/login#dev&)",
"postAttachCommand": "echo 'THANKS FOR CONTRIBUTING TO ZITADEL!'; echo; echo; echo 'The login is running in hot reloading dev mode'; echo 'Run a specific test file like this:'; echo; echo 'pnpm cypress run --spec integration/login.cy.ts'; echo; echo 'Navigate to the page you want to fix at http://localhost:3001'; echo 'Change the code and reload the page to see the effects'; echo 'Repeat until all tests pass:'; echo; echo 'pnpm cypress run'"
}

View File

@@ -1,13 +0,0 @@
services:
login-integration:
container_name: login-integration-debug
network_mode: service:mock-zitadel
extends:
file: ../base/docker-compose.yaml
service: devcontainer
mock-zitadel:
ports:
- 22220:22220
- 22222:22222
- 3001:3001

View File

@@ -0,0 +1,26 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Login Integration",
"dockerComposeFile": [
"./docker-compose.yaml"
],
"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": {}
}
}

View File

@@ -1,6 +1,10 @@
services:
devcontainer:
container_name: devcontainer-login-integration
login-integration-dev:
extends:
file: ../base/docker-compose.yaml
service: devcontainer
container_name: login-integration-dev
image: "login-integration-dev:local"
env_file: ../../apps/login/.env.test
environment:
CORE_MOCK_STUBS_URL: http://localhost:22220/v1/stubs
@@ -13,12 +17,10 @@ services:
login-integration:
container_name: login-integration
image: "${LOGIN_TAG:-zitadel-login:local}"
build:
context: ../..
dockerfile: build/login/Dockerfile
env_file: ../../apps/login/.env.test
environment:
NODE_ENV: test
PORT: 3001
NEXT_PUBLIC_BASE_PATH: /ui/v2/login
ZITADEL_API_URL: http://localhost:22222
network_mode: service:mock-zitadel
mock-zitadel:
@@ -27,3 +29,7 @@ services:
context: ../../apps/login/integration/core-mock
additional_contexts:
- zitadel-protos=../../proto
ports:
- 22220:22220
- 22222:22222
- 3001:3001

View File

@@ -1,14 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Turbo Lint and Unit One-Off Container - Reproduce Pull Request Checks",
"dockerComposeFile": [
"../base/docker-compose.yaml"
],
"service": "devcontainer",
"runServices": [
"devcontainer"
],
"workspaceFolder": "/workspaces",
"onCreateCommand": "pnpm install --frozen-lockfile --recursive",
"updateContentCommand": "pnpm turbo lint test:unit"
}

View File

@@ -1,21 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Turbo Lint and Unit Hot Reload Container - Debug and Fix Pull Request Checks",
"dockerComposeFile": [
"../base/docker-compose.yaml",
"docker-compose.yaml"
],
"service": "turbo-lint-unit-debug",
"runServices": [
"turbo-lint-unit-debug"
],
"workspaceFolder": "/workspaces",
"forwardPorts": [
3001
],
"onCreateCommand": "pnpm install --recursive",
"postAttachCommand": "pnpm turbo daemon clean || true; pnpm turbo watch lint test:unit",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
}
}

View File

@@ -1,6 +0,0 @@
services:
turbo-lint-unit-debug:
container_name: turbo-lint-unit-debug
extends:
file: ../base/docker-compose.yaml
service: devcontainer

View File

@@ -0,0 +1,20 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/refs/heads/main/schemas/devContainer.schema.json",
"name": "Turbo Lint and Unit Tests",
"dockerComposeFile": [
"../base/docker-compose.yaml"
],
"service": "devcontainer",
"runServices": [
"devcontainer"
],
"workspaceFolder": "/workspaces",
"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"
}