mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 06:02:23 +00:00
specify environments explicitly
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -7,8 +7,8 @@ dist
|
||||
dist-ssr
|
||||
*.local
|
||||
.env
|
||||
apps/login/.env.local.?.bak
|
||||
apps/login/.env.local.??.bak
|
||||
apps/login/.env.local
|
||||
apps/login/.env.acceptance
|
||||
.cache
|
||||
server/dist
|
||||
public/dist
|
||||
|
||||
@@ -38,21 +38,6 @@ However, it might be easier to develop against your ZITADEL Cloud instance
|
||||
if you don't have docker installed
|
||||
or have limited resources on your local machine.
|
||||
|
||||
### Testing
|
||||
|
||||
You can execute the following commands `pnpm test` for a single test run or `pnpm test:watch` in the following directories:
|
||||
|
||||
- apps/login
|
||||
- packages/zitadel-client
|
||||
- packages/zitadel-server
|
||||
- packages/zitadel-react
|
||||
- packages/zitadel-next
|
||||
- The projects root directory: all tests in the project are executed
|
||||
|
||||
In apps/login, these commands also spin up the application and a ZITADEL gRPC API mock server to run integration tests using [Cypress](https://www.cypress.io/) against them.
|
||||
If you want to run the integration tests standalone against an environment of your choice, navigate to ./apps/login, create your .env.local file and run `pnpm test:integration:run` or `pnpm test:integration:open`.
|
||||
Then you need to lifecycle the mock process using the command `pnpm mock` or the more fine grained commands `pnpm mock:build`, `pnpm mock:build:nocache`, `pnpm mock:run` and `pnpm mock:destroy`.
|
||||
|
||||
### Developing Against Your Local ZITADEL Instance
|
||||
|
||||
```sh
|
||||
@@ -64,15 +49,18 @@ docker compose --file ./acceptance/docker-compose.yaml pull
|
||||
|
||||
# Run ZITADEL and configure ./apps/login/.env.local
|
||||
docker compose --file ./acceptance/docker-compose.yaml run setup
|
||||
|
||||
# Configure your shell to use the environment variables written to ./apps/login/.env.acceptance
|
||||
source ./apps/login/.env.acceptance
|
||||
```
|
||||
|
||||
### Developing Against Your ZITADEL Cloud Instance
|
||||
|
||||
Create the file ./apps/login/.env.local with the following content:
|
||||
Configure your shell by exporting the following environment variables:
|
||||
```sh
|
||||
ZITADEL_API_URL=<your cloud instance URL here>
|
||||
ZITADEL_ORG_ID=<your service accounts organization id here>
|
||||
ZITADEL_SERVICE_USER_TOKEN=<your service account personal access token here>
|
||||
export ZITADEL_API_URL=<your cloud instance URL here>
|
||||
export ZITADEL_ORG_ID=<your service accounts organization id here>
|
||||
export ZITADEL_SERVICE_USER_TOKEN=<your service account personal access token here>
|
||||
```
|
||||
|
||||
### Setting up local environment
|
||||
@@ -90,4 +78,20 @@ pnpm dev
|
||||
|
||||
The application is now available at `http://localhost:3000`
|
||||
|
||||
### Testing
|
||||
|
||||
You can execute the following commands `pnpm test` for a single test run or `pnpm test:watch` in the following directories:
|
||||
|
||||
- apps/login
|
||||
- packages/zitadel-client
|
||||
- packages/zitadel-server
|
||||
- packages/zitadel-react
|
||||
- packages/zitadel-next
|
||||
- The projects root directory: all tests in the project are executed
|
||||
|
||||
In apps/login, these commands also spin up the application and a ZITADEL gRPC API mock server to run integration tests using [Cypress](https://www.cypress.io/) against them.
|
||||
If you want to run the integration tests standalone against an environment of your choice, navigate to ./apps/login, [configure your shell as you like](# Developing Against Your ZITADEL Cloud Instance) and run `pnpm test:integration:run` or `pnpm test:integration:open`.
|
||||
Then you need to lifecycle the mock process using the command `pnpm mock` or the more fine grained commands `pnpm mock:build`, `pnpm mock:build:nocache`, `pnpm mock:run` and `pnpm mock:destroy`.
|
||||
|
||||
|
||||
That's it! 🎉
|
||||
|
||||
@@ -11,7 +11,7 @@ echo "Using audience ${AUDIENCE} for which the key is used."
|
||||
SERVICE=${SERVICE:-$AUDIENCE}
|
||||
echo "Using the service ${SERVICE} to connect to ZITADEL. For example in docker compose this can differ from the audience."
|
||||
|
||||
WRITE_ENVIRONMENT_FILE=${WRITE_ENVIRONMENT_FILE:-$(dirname "$0")/../apps/login/.env.local}
|
||||
WRITE_ENVIRONMENT_FILE=${WRITE_ENVIRONMENT_FILE:-$(dirname "$0")/../apps/login/.env.acceptance}
|
||||
echo "Writing environment file to ${WRITE_ENVIRONMENT_FILE} when done."
|
||||
|
||||
AUDIENCE_HOST="$(echo $AUDIENCE | cut -d/ -f3)"
|
||||
@@ -44,27 +44,6 @@ echo "${ORG_RESPONSE}" | jq
|
||||
ORG_ID=$(echo -n ${ORG_RESPONSE} | jq --raw-output '.org.id')
|
||||
echo "Extracted default org id ${ORG_ID}"
|
||||
|
||||
ENVIRONMENT_BACKUP_FILE=${WRITE_ENVIRONMENT_FILE}
|
||||
# If the original file already exists, rename it
|
||||
if [[ -e ${WRITE_ENVIRONMENT_FILE} ]]; then
|
||||
if grep -q 'localhost' ${WRITE_ENVIRONMENT_FILE}; then
|
||||
echo "Current environment file ${WRITE_ENVIRONMENT_FILE} contains localhost. Overwriting:"
|
||||
cat ${WRITE_ENVIRONMENT_FILE}
|
||||
else
|
||||
i=0
|
||||
# If a backup file already exists, increment counter until a free filename is found
|
||||
while [[ -e ${ENVIRONMENT_BACKUP_FILE}.${i}.bak ]]; do
|
||||
let "i++"
|
||||
if [[ ${i} -eq 50 ]]; then
|
||||
echo "Warning: Too many backup files (limit is 50), overwriting ${ENVIRONMENT_BACKUP_FILE}.${i}.bak"
|
||||
break
|
||||
fi
|
||||
done
|
||||
mv ${WRITE_ENVIRONMENT_FILE} ${ENVIRONMENT_BACKUP_FILE}.${i}.bak
|
||||
echo "Renamed existing environment file to ${ENVIRONMENT_BACKUP_FILE}.${i}.bak"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "ZITADEL_API_URL=${AUDIENCE}
|
||||
ZITADEL_ORG_ID=${ORG_ID}
|
||||
ZITADEL_SERVICE_USER_TOKEN=${TOKEN}" > ${WRITE_ENVIRONMENT_FILE}
|
||||
|
||||
1
apps/login/.env.integration
Normal file
1
apps/login/.env.integration
Normal file
@@ -0,0 +1 @@
|
||||
ZITADEL_API_URL=http://localhost:22222
|
||||
@@ -17,4 +17,4 @@ RUN go install github.com/eliobischof/grpc-mock/cmd/grpc-mock@4de05333a51075cb3a
|
||||
|
||||
COPY --from=config / .
|
||||
|
||||
ENTRYPOINT [ "sh", "-c", "grpc-mock -proto $(tr '\n' ',' < ./mocked-services.cfg) -stub-dir ./initial-stubs" ]
|
||||
ENTRYPOINT [ "sh", "-c", "grpc-mock -v 1 -proto $(tr '\n' ',' < ./mocked-services.cfg) -stub-dir ./initial-stubs" ]
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"test": "concurrently --group --timings --kill-others-on-fail 'npm:test:unit' 'npm:test:integration'",
|
||||
"test": "concurrently --timings --kill-others-on-fail 'npm:test:unit' 'npm:test:integration'",
|
||||
"test:watch": "concurrently --kill-others 'npm:test:unit:watch' 'npm:test:integration:watch'",
|
||||
"test:unit": "jest --config ./__test__/jest.config.ts",
|
||||
"test:unit:watch": "pnpm test:unit --watch",
|
||||
"test:integration": "export ZITADEL_API_URL=http://localhost:22222; pnpm mock:build && concurrently --group --names 'mock,test' --success command-test --kill-others 'pnpm:mock' 'start-server-and-test start http://localhost:3000 \"test:integration:run\"'",
|
||||
"test:integration:watch": "concurrently --names 'mock,test' --kill-others 'pnpm:mock' 'ZITADEL_API_URL=http://localhost:22222 start-server-and-test dev http://localhost:3000 \"pnpm nodemon -e js,jsx,ts,tsx,css,scss --ignore \\\"__test__/**\\\" --exec \\\"pnpm test:integration:run\\\"\"'",
|
||||
"test:integration": "pnpm mock:build && concurrently --names 'mock,test' --success command-test --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test start http://localhost:3000 \"test:integration:run\"'",
|
||||
"test:integration:watch": "concurrently --names 'mock,test' --kill-others 'pnpm:mock' 'env-cmd -f ./.env.integration start-server-and-test dev http://localhost:3000 \"pnpm nodemon -e js,jsx,ts,tsx,css,scss --ignore \\\"__test__/**\\\" --exec \\\"pnpm test:integration:run\\\"\"'",
|
||||
"test:integration:run": "cypress run --config-file ./cypress/cypress.config.ts --quiet",
|
||||
"test:integration:open": "cypress open --config-file ./cypress/cypress.config.ts",
|
||||
"mock": "pnpm mock:build && pnpm mock:run",
|
||||
@@ -69,6 +69,7 @@
|
||||
"concurrently": "^8.1.0",
|
||||
"cypress": "^12.14.0",
|
||||
"del-cli": "5.0.0",
|
||||
"env-cmd": "^10.1.0",
|
||||
"eslint-config-zitadel": "workspace:*",
|
||||
"grpc-tools": "1.11.3",
|
||||
"jest": "^29.5.0",
|
||||
@@ -87,4 +88,4 @@
|
||||
"typescript": "5.0.4",
|
||||
"zitadel-tailwind-config": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -135,6 +135,9 @@ importers:
|
||||
del-cli:
|
||||
specifier: 5.0.0
|
||||
version: 5.0.0
|
||||
env-cmd:
|
||||
specifier: ^10.1.0
|
||||
version: 10.1.0
|
||||
eslint-config-zitadel:
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/eslint-config-zitadel
|
||||
@@ -3394,6 +3397,15 @@ packages:
|
||||
engines: {node: '>=0.12'}
|
||||
dev: true
|
||||
|
||||
/env-cmd@10.1.0:
|
||||
resolution: {integrity: sha512-mMdWTT9XKN7yNth/6N6g2GuKuJTsKMDHlQFUDacb/heQRRWOTIZ42t1rMHnQu4jYxU1ajdTeJM+9eEETlqToMA==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
commander: 4.1.1
|
||||
cross-spawn: 7.0.3
|
||||
dev: true
|
||||
|
||||
/error-ex@1.3.2:
|
||||
resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==}
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user