Run integration tests on Github Actions
This commit is contained in:
parent
55f4a6ed74
commit
d636cec8f3
|
|
@ -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] }}
|
||||
24
Makefile
24
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
<phpunit stopOnError="true" stopOnFailure="true" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="Kanboard">
|
||||
<directory>acceptance</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="SELENIUM_HOST" value="localhost" />
|
||||
<const name="SELENIUM_PORT" value="4444" />
|
||||
<const name="DEFAULT_BROWSER" value="firefox" />
|
||||
<const name="KANBOARD_APP_URL" value="http://localhost:8001" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Base extends PHPUnit_Extensions_Selenium2TestCase
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->setHost(SELENIUM_HOST);
|
||||
$this->setPort((integer) SELENIUM_PORT);
|
||||
$this->setBrowserUrl(KANBOARD_APP_URL);
|
||||
$this->setBrowser(DEFAULT_BROWSER);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$this->stop();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__.'/Base.php';
|
||||
|
||||
class UserAuthenticationTest extends Base
|
||||
{
|
||||
|
||||
public function validLoginInputsProvider()
|
||||
{
|
||||
$inputs[] = [
|
||||
[
|
||||
'username' => '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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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"]
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:apache2]
|
||||
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
|
||||
autorestart=true
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="BASE_URL" value="http://app/" />
|
||||
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||
<const name="BASE_URL" value="http://127.0.0.1/" />
|
||||
<const name="API_URL" value="http://127.0.0.1/jsonrpc.php" />
|
||||
<const name="API_KEY" value="test" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="BASE_URL" value="http://app/" />
|
||||
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||
<const name="BASE_URL" value="http://127.0.0.1/" />
|
||||
<const name="API_URL" value="http://127.0.0.1/jsonrpc.php" />
|
||||
<const name="API_KEY" value="test" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<const name="BASE_URL" value="http://app/" />
|
||||
<const name="API_URL" value="http://app/jsonrpc.php" />
|
||||
<const name="BASE_URL" value="http://127.0.0.1/" />
|
||||
<const name="API_URL" value="http://127.0.0.1/jsonrpc.php" />
|
||||
<const name="API_KEY" value="test" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
date.timezone = UTC
|
||||
opcache.enable = Off
|
||||
opcache.enable_cli = Off
|
||||
Loading…
Reference in New Issue