diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5ea07d2a2f..32d499f92b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -331,8 +331,14 @@ jobs: GITEA_DEPLOY_IMAGE_TAG: ':${{ needs.get_version.outputs.gitea_sha }}' shell: bash run: | - token=$(scripts/pre_e2e.sh) + scripts/generate_e2e_fixtures.sh + + # start gitea so we can generate the admin token required for e2e + docker-compose -f docker-compose.yml -f docker-compose.deploy.yml up -d + until docker logs kitspace_gitea_1 | grep -q 'ORM engine initialization successful' ; do sleep 3s; done + token="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)" docker-compose stop + echo "CYPRESS_GITEA_ADMIN_TOKEN=${token}" >> $GITHUB_ENV - name: e2e diff --git a/README.md b/README.md index bdbb897b15..68b3fd53dd 100644 --- a/README.md +++ b/README.md @@ -339,32 +339,22 @@ docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-co > Note: The GITEA_ADMIN_TOKEN is needed because the Gitea service is hidden and inaccessible to other containers. -> Before running e2e tests locally make sure to source the `.env` file: ` set -o allexport && source .env && set +o allexport` - -### Without docker - -Make sure that npm packages are installed - -```console -yarn --cwd e2e -``` -then you can run the tests with +Before running e2e tests locally make sure to: +1. source the `.env` file: ` set -o allexport && source .env && set +o allexport` +2. have all services running: `docker-compose up` and the frontend is being served at [http://kitspace.test:3000](http://kitspace.test:3000). +3. install npm packages: `yarn --cwd e2e` +### Without docker ```console -yarn --cwd e2e e2e --env GITEA_ADMIN_TOKEN=$(scripts/pre_e2e.sh) +GITEA_ADMIN_TOKEN="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)" +yarn --cwd e2e e2e --env GITEA_ADMIN_TOKEN="$GITEA_ADMIN_TOKEN" ``` ### GUI -Make sure that npm packages are installed - -```console -yarn --cwd e2e -``` -then you can open the GUI with - ```console -yarn --cwd e2e gui --env GITEA_ADMIN_TOKEN=$(scripts/pre_e2e.sh) +GITEA_ADMIN_TOKEN="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)" +yarn --cwd e2e gui --env GITEA_ADMIN_TOKEN="$GITEA_ADMIN_TOKEN" ``` diff --git a/scripts/generate_e2e_fixtures.sh b/scripts/generate_e2e_fixtures.sh new file mode 100755 index 0000000000..d0ea75815d --- /dev/null +++ b/scripts/generate_e2e_fixtures.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail + +# Generate big files which are used during testing +# `uploadProject.spec.js` -> should reject files bigger than `MAX_FILE_SIZE` +auto_gen_fixtures_path=e2e/cypress/fixtures/auto-gen +rm -rf $auto_gen_fixtures_path && mkdir $auto_gen_fixtures_path +truncate -s "${MAX_FILE_SIZE}" "${auto_gen_fixtures_path}/big.txt" diff --git a/scripts/pre_e2e.sh b/scripts/pre_e2e.sh deleted file mode 100755 index 24fc2d31d6..0000000000 --- a/scripts/pre_e2e.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -Eeuo pipefail - -# Generate big files which are used during testing -# `uploadProject.spec.js` -> should reject files bigger than `MAX_FILE_SIZE` -auto_gen_fixtures_path=e2e/cypress/fixtures/auto-gen -rm -rf $auto_gen_fixtures_path && mkdir $auto_gen_fixtures_path -truncate -s "${MAX_FILE_SIZE}" "${auto_gen_fixtures_path}/big.txt" - -# generate admin token used for importing projects during e2e tests -if [[ "${CI:-}" = "true" ]]; then - docker-compose -f docker-compose.yml -f docker-compose.deploy.yml up -d - until docker logs kitspace_gitea_1 | grep -q 'ORM engine initialization successful' ; do sleep 3s; done -else - # The tests are running locally. - docker-compose up -d -fi - -token="$(deno run --allow-env --allow-net --allow-run ./scripts/importBoardsTxt.ts --tokenOnly)" -# reutrn the token so it can be used as $(./scripts/pre_e2e.sh) -echo $token