diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index faa70831..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: @@ -128,6 +131,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 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..13535e49 --- /dev/null +++ b/scripts/integration.sh @@ -0,0 +1,39 @@ +#!/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 + +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 . + +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