From 9cc667851ca508a404571d1087f3bf6251849c3b Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 30 Apr 2023 20:17:51 +0530 Subject: [PATCH 1/3] feat: run integration tests using nightwatch js --- Makefile | 3 +++ scripts/integration.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100755 scripts/integration.sh diff --git a/Makefile b/Makefile index d3befa05..a73d4fc7 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,9 @@ test: frontend-test frontend ## Run all available tests cargo test --no-fail-fast # ./scripts/tests.sh +test.integration: ## run integration tests with nightwatch.js + ./scripts/integration.sh + xml-test-coverage: migrate ## Generate code coverage report in XML format $(call cache_bust) cargo tarpaulin -t 1200 --out Xml diff --git a/scripts/integration.sh b/scripts/integration.sh new file mode 100755 index 00000000..4a0b02d3 --- /dev/null +++ b/scripts/integration.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -Eeuo pipefail +trap cleanup SIGINT SIGTERM ERR EXIT + +readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))) + +source $PROJECT_ROOT/scripts/lib.sh + + + +docker-compose down -v --remove-orphans || true +docker-compose up -d +cd $(mktemp -d) +git clone https://github.com/mCaptcha/integration . +yarn install +npx nightwatch ./test/mCaptcha.ts +cd $PROJECT_ROOT +docker-compose down -v --remove-orphans || true From 43dab030dfa06b9b9c0524431feb373c0139d684 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 30 Apr 2023 20:18:47 +0530 Subject: [PATCH 2/3] feat: run nightwatch integration tests on CI --- .github/workflows/linux.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index faa70831..94b71320 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -128,6 +128,9 @@ jobs: POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}" + - name: run integration tests + run: make test.integration + - name: Login to DockerHub if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha' uses: docker/login-action@v1 From 5324969bd29d25e6d1186bc825f9d9eadfcb0a76 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 30 Apr 2023 21:10:59 +0530 Subject: [PATCH 3/3] feat: install selenium drivers --- .github/workflows/linux.yml | 3 +++ scripts/integration.sh | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 94b71320..2e924696 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -104,6 +104,9 @@ jobs: profile: minimal override: true + - name: install nightwatch dep + run: sudo apt-get install xvfb + - name: Run migrations run: make migrate env: diff --git a/scripts/integration.sh b/scripts/integration.sh index 4a0b02d3..13535e49 100755 --- a/scripts/integration.sh +++ b/scripts/integration.sh @@ -7,13 +7,33 @@ readonly PROJECT_ROOT=$(realpath $(dirname $(dirname "${BASH_SOURCE[0]}"))) source $PROJECT_ROOT/scripts/lib.sh +is_ci(){ + if [ -z ${CI+x} ]; + then + return 1 + else + return 0 + fi +} + docker-compose down -v --remove-orphans || true docker-compose up -d cd $(mktemp -d) +pwd +find git clone https://github.com/mCaptcha/integration . -yarn install -npx nightwatch ./test/mCaptcha.ts + +if is_ci +then + yarn install + xvfb-run --auto-servernum npm run test.chrome + xvfb-run --auto-servernum npm run test.firefox +else + yarn install + npx nightwatch ./test/mCaptcha.ts +fi + cd $PROJECT_ROOT docker-compose down -v --remove-orphans || true