diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml new file mode 100644 index 000000000..82b56fb8c --- /dev/null +++ b/.github/workflows/integration_tests.yml @@ -0,0 +1,104 @@ +name: Integration Tests + +on: + pull_request: + branches: [ master ] + +jobs: + Sqlite: + runs-on: ubuntu-latest + container: kanboard/tests:latest + steps: + - uses: actions/checkout@v2 + - name: Validate composer.json and composer.lock + run: composer validate + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Start Apache + run: /etc/init.d/apache2 start + - name: Link document root + run: | + rm -rf /var/www/html + ln -s $GITHUB_WORKSPACE /var/www/html + cp tests/configs/config.sqlite.php /var/www/html/config.php + chown -R www-data:www-data /var/www/html/data + ls -l /var/www/html/ + - name: Integration tests with Sqlite + run: ./vendor/bin/phpunit -c tests/integration.sqlite.xml + + Postgres: + runs-on: ubuntu-latest + container: kanboard/tests:latest + services: + postgres: + image: postgres:9.4 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: kanboard + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v2 + - name: Validate composer.json and composer.lock + run: composer validate + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Start Apache + run: /etc/init.d/apache2 start + - name: Link document root + run: | + rm -rf /var/www/html + ln -s $GITHUB_WORKSPACE /var/www/html + cp tests/configs/config.postgres.php /var/www/html/config.php + chown -R www-data:www-data /var/www/html/data + ls -l /var/www/html/ + - name: Integration tests with Postgres + run: ./vendor/bin/phpunit -c tests/integration.postgres.xml + env: + DB_HOSTNAME: postgres + DB_PORT: ${{ job.services.postgres.ports[5432] }} + + Mysql: + runs-on: ubuntu-latest + container: kanboard/tests:latest + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: "kanboard" + MYSQL_DATABASE: "kanboard" + MYSQL_USER: "kanboard" + MYSQL_PASSWORD: "kanboard" + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + steps: + - uses: actions/checkout@v2 + - name: Validate composer.json and composer.lock + run: composer validate + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + - name: Start Apache + run: /etc/init.d/apache2 start + - name: Link document root + run: | + rm -rf /var/www/html + ln -s $GITHUB_WORKSPACE /var/www/html + cp tests/configs/config.mysql.php /var/www/html/config.php + chown -R www-data:www-data /var/www/html/data + ls -l /var/www/html/ + - name: Integration tests with Mysql + run: ./vendor/bin/phpunit -c tests/integration.mysql.xml + env: + DB_HOSTNAME: mysql + DB_PORT: ${{ job.services.mysql.ports[3306] }} diff --git a/Makefile b/Makefile index 9bb70a307..bc75b2808 100644 --- a/Makefile +++ b/Makefile @@ -19,30 +19,6 @@ test-mysql: test-postgres: @ ./vendor/bin/phpunit -c tests/units.postgres.xml -test-browser: - @ ./vendor/bin/phpunit -c tests/acceptance.xml - -integration-test-mysql: - @ composer install --dev - @ docker-compose -f tests/docker/compose.integration.mysql.yaml build - @ docker-compose -f tests/docker/compose.integration.mysql.yaml up -d mysql app - @ docker-compose -f tests/docker/compose.integration.mysql.yaml up tests - @ docker-compose -f tests/docker/compose.integration.mysql.yaml down - -integration-test-postgres: - @ composer install --dev - @ docker-compose -f tests/docker/compose.integration.postgres.yaml build - @ docker-compose -f tests/docker/compose.integration.postgres.yaml up -d postgres app - @ docker-compose -f tests/docker/compose.integration.postgres.yaml up tests - @ docker-compose -f tests/docker/compose.integration.postgres.yaml down - -integration-test-sqlite: - @ composer install --dev - @ docker-compose -f tests/docker/compose.integration.sqlite.yaml build - @ docker-compose -f tests/docker/compose.integration.sqlite.yaml up -d app - @ docker-compose -f tests/docker/compose.integration.sqlite.yaml up tests - @ docker-compose -f tests/docker/compose.integration.sqlite.yaml down - sql: @ pg_dump --schema-only --no-owner --no-privileges --quote-all-identifiers -n public --file app/Schema/Sql/postgres.sql kanboard @ pg_dump -d kanboard --column-inserts --data-only --table settings >> app/Schema/Sql/postgres.sql diff --git a/tests/Dockerfile b/tests/Dockerfile index e9eba8ef4..17bde054e 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,9 +1,13 @@ # This Dockerfile can be used to run unit tests. # This image is published on the Docker Hub: kanboard/tests:latest -FROM debian:10-slim +FROM ubuntu:20.04 + +ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y -q && \ apt-get install -y \ + apache2 \ + libapache2-mod-php \ php-cli \ php-mbstring \ php-sqlite3 \ @@ -21,4 +25,5 @@ RUN apt-get update -y -q && \ git \ make \ mariadb-client \ - postgresql-client + postgresql-client \ + a2enmod rewrite diff --git a/tests/acceptance.xml b/tests/acceptance.xml deleted file mode 100644 index a161f9ec4..000000000 --- a/tests/acceptance.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - acceptance - - - - - - - - - diff --git a/tests/acceptance/Base.php b/tests/acceptance/Base.php deleted file mode 100644 index e8684a9b1..000000000 --- a/tests/acceptance/Base.php +++ /dev/null @@ -1,18 +0,0 @@ -setHost(SELENIUM_HOST); - $this->setPort((integer) SELENIUM_PORT); - $this->setBrowserUrl(KANBOARD_APP_URL); - $this->setBrowser(DEFAULT_BROWSER); - } - - public function tearDown() - { - $this->stop(); - } -} diff --git a/tests/acceptance/UserAuthenticationTest.php b/tests/acceptance/UserAuthenticationTest.php deleted file mode 100644 index 3313e0506..000000000 --- a/tests/acceptance/UserAuthenticationTest.php +++ /dev/null @@ -1,86 +0,0 @@ - 'admin', - 'password' => 'admin', - ] - ]; - - return $inputs; - } - - public function invalidLoginInputsProvider() - { - $inputs[] = [ - [ - 'username' => 'wrong_username', - 'password' => 'wrong_password', - ] - ]; - - return $inputs; - } - - /** - * @dataProvider validLoginInputsProvider - */ - public function testValidLogin(array $inputs) - { - $this->url('/'); - $this->assertContains('Login', $this->title()); - - $form = $this->byTag('form'); - foreach ($inputs as $input => $value) { - $form->byName($input)->value($value); - } - $form->submit(); - - $content = $this->byClassName('sidebar')->text(); - $this->assertContains($inputs['username'], $content); - } - - /** - * @dataProvider invalidLoginInputsProvider - */ - public function testInvalidLogin(array $inputs) - { - $this->url('/'); - - // Test wrong username with correct password - $form = $this->byTag('form'); - $form->byName('username')->value($inputs['username']); - $form->byName('password')->value('admin'); - $form->submit(); - - $content = $this->byTag('body')->text(); - $this->assertContains('Bad username or password', $content); - - // Test wrong password with correct username - $form = $this->byTag('form'); - $form->byName('username')->value('admin'); - $form->byName('password')->value($inputs['password']); - $form->submit(); - - $content = $this->byTag('body')->text(); - $this->assertContains('Bad username or password', $content); - - // Test wrong username and password - $form = $this->byTag('form'); - $form->byName('username')->value($inputs['username']); - $form->byName('password')->value($inputs['password']); - $form->submit(); - - $content = $this->byTag('body')->text(); - $this->assertContains('Bad username or password', $content); - - - } -} diff --git a/tests/docker/Dockerfile.xenial b/tests/docker/Dockerfile.xenial deleted file mode 100644 index a48d05252..000000000 --- a/tests/docker/Dockerfile.xenial +++ /dev/null @@ -1,24 +0,0 @@ -FROM ubuntu:16.04 - -RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/supervisor - -RUN apt-get update -qq && \ - apt-get install -y apache2 supervisor cron curl unzip \ - libapache2-mod-php7.0 php7.0-cli php7.0-mbstring php7.0-xml php7.0-mysql php7.0-sqlite3 \ - php7.0-opcache php7.0-json php7.0-pgsql php7.0-ldap php7.0-gd php7.0-zip && \ - apt clean && \ - echo "ServerName localhost" >> /etc/apache2/apache2.conf && \ - sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf && \ - a2enmod rewrite && \ - curl -sS https://getcomposer.org/installer | php -- --filename=/usr/local/bin/composer - -COPY . /var/www/html - -RUN chown -R www-data:www-data /var/www/html/data /var/www/html/plugins - -COPY tests/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf -COPY tests/configs /configs/ - -EXPOSE 80 - -ENTRYPOINT ["/var/www/html/tests/docker/entrypoint.sh"] diff --git a/tests/docker/compose.integration.mysql.yaml b/tests/docker/compose.integration.mysql.yaml deleted file mode 100644 index 6eda5eec6..000000000 --- a/tests/docker/compose.integration.mysql.yaml +++ /dev/null @@ -1,27 +0,0 @@ -version: '2' -services: - mysql: - image: mysql:5.7 - environment: - MYSQL_ROOT_PASSWORD: "kanboard" - MYSQL_DATABASE: "kanboard" - MYSQL_USER: "kanboard" - MYSQL_PASSWORD: "kanboard" - ports: - - "3306:3306" - app: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - ports: - - "8000:80" - depends_on: - - mysql - command: config-mysql - tests: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - depends_on: - - app - command: integration-test-mysql diff --git a/tests/docker/compose.integration.postgres.yaml b/tests/docker/compose.integration.postgres.yaml deleted file mode 100644 index ed0952485..000000000 --- a/tests/docker/compose.integration.postgres.yaml +++ /dev/null @@ -1,26 +0,0 @@ -version: '2' -services: - postgres: - image: postgres:9.5 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: kanboard - ports: - - "5432:5432" - app: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - ports: - - "8000:80" - depends_on: - - postgres - command: config-postgres - tests: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - depends_on: - - app - command: integration-test-postgres diff --git a/tests/docker/compose.integration.sqlite.yaml b/tests/docker/compose.integration.sqlite.yaml deleted file mode 100644 index 6431484e0..000000000 --- a/tests/docker/compose.integration.sqlite.yaml +++ /dev/null @@ -1,16 +0,0 @@ -version: '2' -services: - app: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - ports: - - "8000:80" - command: config-sqlite - tests: - build: - context: ../.. - dockerfile: tests/docker/Dockerfile.xenial - depends_on: - - app - command: integration-test-sqlite diff --git a/tests/docker/entrypoint.sh b/tests/docker/entrypoint.sh deleted file mode 100755 index 5a37ae4e0..000000000 --- a/tests/docker/entrypoint.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -function wait_schema_creation() { - curl -s http://app/login > /dev/null - sleep $1 -} - -case "$1" in -"config-sqlite") - cp /configs/config.sqlite.php /var/www/html/config.php - /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf - ;; -"config-postgres") - cp /configs/config.postgres.php /var/www/html/config.php - /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf - ;; -"config-mysql") - cp /configs/config.mysql.php /var/www/html/config.php - /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf - ;; -"integration-test-sqlite") - wait_schema_creation 1 - /var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.sqlite.xml - ;; -"integration-test-postgres") - wait_schema_creation 10 - /var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.postgres.xml - ;; -"integration-test-mysql") - wait_schema_creation 15 - /var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.mysql.xml - ;; -esac diff --git a/tests/docker/supervisord.conf b/tests/docker/supervisord.conf deleted file mode 100644 index 4d5ee6214..000000000 --- a/tests/docker/supervisord.conf +++ /dev/null @@ -1,6 +0,0 @@ -[supervisord] -nodaemon=true - -[program:apache2] -command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND" -autorestart=true diff --git a/tests/integration.mysql.xml b/tests/integration.mysql.xml index 338131876..b0c79824e 100644 --- a/tests/integration.mysql.xml +++ b/tests/integration.mysql.xml @@ -5,8 +5,8 @@ - - + + diff --git a/tests/integration.postgres.xml b/tests/integration.postgres.xml index 338131876..b0c79824e 100644 --- a/tests/integration.postgres.xml +++ b/tests/integration.postgres.xml @@ -5,8 +5,8 @@ - - + + diff --git a/tests/integration.sqlite.xml b/tests/integration.sqlite.xml index 338131876..b0c79824e 100644 --- a/tests/integration.sqlite.xml +++ b/tests/integration.sqlite.xml @@ -5,8 +5,8 @@ - - + + diff --git a/tests/integration/AppProcedureTest.php b/tests/integration/AppProcedureTest.php index 06135dac4..2859dfdef 100644 --- a/tests/integration/AppProcedureTest.php +++ b/tests/integration/AppProcedureTest.php @@ -11,7 +11,7 @@ class AppProcedureTest extends BaseProcedureTest public function testGetVersion() { - $this->assertEquals('master', $this->app->getVersion()); + $this->assertEquals('master.unknown_revision', $this->app->getVersion()); } public function testGetApplicationRoles() diff --git a/tests/integration/BaseProcedureTest.php b/tests/integration/BaseProcedureTest.php index beb13ff72..d0bc81380 100644 --- a/tests/integration/BaseProcedureTest.php +++ b/tests/integration/BaseProcedureTest.php @@ -2,7 +2,7 @@ require_once __DIR__.'/../../vendor/autoload.php'; -abstract class BaseProcedureTest extends PHPUnit_Framework_TestCase +abstract class BaseProcedureTest extends PHPUnit\Framework\TestCase { protected $app = null; protected $admin = null; diff --git a/tests/php.ini b/tests/php.ini deleted file mode 100644 index a4f0be2c5..000000000 --- a/tests/php.ini +++ /dev/null @@ -1,3 +0,0 @@ -date.timezone = UTC -opcache.enable = Off -opcache.enable_cli = Off \ No newline at end of file