diff --git a/.artifacts/zitadel/.gitignore b/.artifacts/zitadel/.gitignore new file mode 100644 index 0000000000..bf27f3114d --- /dev/null +++ b/.artifacts/zitadel/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!.gitkeep diff --git a/.artifacts/zitadel/.gitkeep b/.artifacts/zitadel/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.github/workflows/zitadel-pr.yml b/.github/workflows/zitadel-pr.yml index d8c14c5f21..7ddbb4e771 100644 --- a/.github/workflows/zitadel-pr.yml +++ b/.github/workflows/zitadel-pr.yml @@ -28,11 +28,14 @@ jobs: - name: Install NPM Modules working-directory: ./console run: npm ci - - name: Test - run: ./e2e/install.sh + - name: Build and Test Binary + run: GOOS="linux" GOARCH="amd64" goreleaser build --snapshot --single-target --rm-dist --single-target --output .artifacts/zitadel/zitadel - name: Publish go coverage uses: codecov/codecov-action@v3.1.0 with: file: .artifacts/codecov/profile.cov name: go-codecov - + - name: Build Docker Image + run: ./e2e/docker-compose.sh build + - name: Run E2E Tests + run: ./e2e/docker-compose.sh run e2e diff --git a/.gitignore b/.gitignore index 9f5525c78a..ed9eaa0085 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ openapi/**/*.json build/local/*.env migrations/cockroach/migrate_cloud.go .notifications -.artifacts +/.artifacts/* +!/.artifacts/zitadel /zitadel diff --git a/console/cypress.config.ts b/console/cypress.config.ts index fb1143e9a1..8b65ee5d8d 100644 --- a/console/cypress.config.ts +++ b/console/cypress.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'cypress'; +import { env } from 'process'; let tokensCache = new Map() let initmfaandpwrequired = true @@ -17,7 +18,12 @@ export default defineConfig({ trashAssetsBeforeRuns: false, defaultCommandTimeout: 10000, + env: { + ORGANIZATION: process.env.CYPRESS_ORGANIZATION || 'zitadel' + }, + e2e: { + baseUrl: process.env.CYPRESS_BASE_URL || 'http://localhost:8080', experimentalSessionAndOrigin: true, setupNodeEvents(on, config) { require('cypress-terminal-report/src/installLogsPrinter')(on); @@ -33,18 +39,6 @@ export default defineConfig({ return tokensCache.get(key) || null; } }) - on('task', { - initmfaandpwrequired(){ - if (config.env.noInitMFAAndPWRequired == 'true'){ - initmfaandpwrequired = false - } - if (initmfaandpwrequired){ - initmfaandpwrequired = false - return true - } - return false - } - }) }, }, }); diff --git a/console/package.json b/console/package.json index 37b08967be..ddf9ae14bb 100644 --- a/console/package.json +++ b/console/package.json @@ -7,8 +7,12 @@ "build": "ng build", "prodbuild": "ng build --configuration production --base-href=/ui/console/", "lint": "ng lint && stylelint './src/**/*.scss' --syntax scss", - "e2e": "./cypress.sh run ../e2e/dev.env", - "e2e:open": "./cypress.sh open ../e2e/dev.env" + "e2e:build:binary": "cd .. && GOOS=linux GOARCH=amd64 goreleaser build --snapshot --single-target --rm-dist --output .artifacts/zitadel/zitadel", + "e2e:build:image": "../e2e/docker-compose.sh build", + "e2e:build": "npm run e2e:build:binary && npm run e2e:build:image", + "e2e:test": "../e2e/docker-compose.sh run e2e", + "e2e": "npm run e2e:build && npm run e2e:test", + "e2e:open": "npx cypress open" }, "private": true, "dependencies": { diff --git a/e2e/docker-compose-overwrite.yaml b/e2e/docker-compose-overwrite.yaml index f12cad7a6b..7239087725 100644 --- a/e2e/docker-compose-overwrite.yaml +++ b/e2e/docker-compose-overwrite.yaml @@ -1,6 +1,9 @@ services: zitadel: - image: '${ZITADEL_IMAGE}' + image: ${ZITADEL_IMAGE:-zitadel:latest} + build: + context: ../.artifacts/zitadel + dockerfile: ../../build/Dockerfile environment: # TODO: localhost? ZITADEL_EXTERNALDOMAIN: zitadel @@ -16,6 +19,6 @@ services: - zitadel working_dir: /e2e volumes: - - ${PWD}/console:/e2e + - ../console:/e2e networks: - zitadel diff --git a/e2e/docker-compose.sh b/e2e/docker-compose.sh index 0e34db373d..79f746bec8 100755 --- a/e2e/docker-compose.sh +++ b/e2e/docker-compose.sh @@ -1,3 +1,5 @@ #!/bin/bash -COMPOSE_DOCKER_CLI_BUILD=1 docker compose --file ${projectRoot}/e2e/docker-compose-workdir.yaml --file ${projectRoot}/docs/docs/guides/deploy/docker-compose.yaml --file ${projectRoot}/e2e/docker-compose-overwrite.yaml "$@" +SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +COMPOSE_DOCKER_CLI_BUILD=1 docker compose --file ${SCRIPTPATH}/docker-compose-workdir.yaml --file ${SCRIPTPATH}/../docs/docs/guides/deploy/docker-compose.yaml --file ${SCRIPTPATH}/docker-compose-overwrite.yaml "$@" diff --git a/e2e/install.sh b/e2e/install.sh deleted file mode 100755 index 8df21776dd..0000000000 --- a/e2e/install.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# TODO: ONLY BUILD HERE AND PRINT BUILT IMAGE TO STDOUT? - -set -e - -export projectRoot="." - -DO_BUILD=1 -DO_DEPLOY=1 - -while getopts 'bd:' OPTION; do - case "$OPTION" in - b) - echo "skipping build" - DO_BUILD=0 - ;; - d) - echo "skipping deployment" - DO_DEPLOY=0 - ;; - ?) - echo "script usage: $(basename \$0) [-b] [-d] [-t]" >&2 - echo "-b skip build" - echo "-d skip deployment" - exit 1 - ;; - esac -done -shift "$(($OPTIND -1))" - -if [ "$DO_BUILD" -eq "1" ]; then - # build the zitadel binary - GOOS="linux" GOARCH="amd64" goreleaser build --snapshot --single-target --rm-dist -fi - -# extract some metadata for building and tagging the docker image -function extract_metadata () -{ - cat .artifacts/goreleaser/$1 | jq -r $2 -} -BUILD_DATE="$(extract_metadata metadata.json '.date')" - -# Use simple local date -BUILD_DATE="${BUILD_DATE%.*}" -# Replace colons and plus signs -export BUILD_DATE="${BUILD_DATE//:/_}" -export ZITADEL_IMAGE="${ZITADEL_IMAGE:-zitadel:${BUILD_DATE}}" - -if [ "$DO_BUILD" -eq "1" ]; then - BUILD_PATH="$(dirname $(extract_metadata artifacts.json '.[0].path'))" - BUILD_VERSION="$(extract_metadata metadata.json '.version')" - - # build the docker image - DOCKER_BUILDKIT=1 docker build --file ./build/Dockerfile --tag zitadel:latest --tag zitadel:$BUILD_VERSION --tag zitadel:$BUILD_DATE $BUILD_PATH -fi - -if [ "$DO_DEPLOY" -eq "1" ]; then - echo "Testing ZITADEL image $ZITADEL_IMAGE" - # run cockroach and zitadel - ./e2e/docker-compose.sh run e2e -fi