Skip to content

Commit

Permalink
Run CI tests using Gihub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 27, 2019
1 parent d85a10d commit 5b57ea0
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 0 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: "GLPI CI"

on: ["push"]

jobs:
lint:
name: "Lint"
runs-on: "ubuntu-latest"
services:
app:
image: "glpi/githubactions-php:5.6"
options: >-
--volume /glpi:/var/glpi
steps:
- name: "Checkout"
uses: "actions/checkout@v1"
with:
fetch-depth: 1
- name: "Deploy source into app container"
run: |
sudo cp --no-target-directory --preserve --recursive `pwd` /glpi
sudo chown -R 1000:1000 /glpi
- name: "Install dependencies"
run: |
docker exec ${{ job.services.app.id }} perl -i -0 -p -e 's/,?\s*"platform"\:\s*\{[^\}]*}//i' composer.json
docker exec ${{ job.services.app.id }} rm composer.lock
docker exec ${{ job.services.app.id }} composer --version
docker exec ${{ job.services.app.id }} composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest
- name: "PHP Parallel Lint"
run: |
docker exec ${{ job.services.app.id }} vendor/bin/parallel-lint --exclude ./files/ --exclude ./plugins/ --exclude ./tools/vendor/ --exclude ./vendor/ .
- name: "PHP Security checker"
run: |
docker exec ${{ job.services.app.id }} vendor/bin/security-checker security:check
- name: "PHP CS"
run: |
docker exec ${{ job.services.app.id }} vendor/bin/phpcs -d memory_limit=512M -p -n --extensions=php --standard=vendor/glpi-project/coding-standard/GlpiStandard/ --ignore=/.git/,/config/,/files/,/lib/,/plugins/,/tests/config/,/vendor/ ./
tests:
name: "Test on PHP ${{ matrix.php-version }} using ${{ matrix.db-image }}"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
db-image:
- "mariadb:10.1"
#- "mariadb:10.2"
#- "mariadb:10.3"
- "mariadb:10.4"
- "mysql:5.6"
#- "mysql:5.7"
- "mysql:8.0"
php-version:
- "5.6"
#- "7.0"
#- "7.1"
#- "7.2"
- "7.3"
#- "7.4-rc"
exclude:
# Exclude all DB images except "mariadb:10.4" for all PHP versions except "7.3".
- {db-image: "mariadb:10.1", php-version: "5.6"}
- {db-image: "mariadb:10.1", php-version: "7.0"}
- {db-image: "mariadb:10.1", php-version: "7.1"}
- {db-image: "mariadb:10.1", php-version: "7.2"}
- {db-image: "mariadb:10.1", php-version: "7.4-rc"}
- {db-image: "mariadb:10.2", php-version: "5.6"}
- {db-image: "mariadb:10.2", php-version: "7.0"}
- {db-image: "mariadb:10.2", php-version: "7.1"}
- {db-image: "mariadb:10.2", php-version: "7.2"}
- {db-image: "mariadb:10.2", php-version: "7.4-rc"}
- {db-image: "mariadb:10.3", php-version: "5.6"}
- {db-image: "mariadb:10.3", php-version: "7.1"}
- {db-image: "mariadb:10.3", php-version: "7.0"}
- {db-image: "mariadb:10.3", php-version: "7.2"}
- {db-image: "mariadb:10.3", php-version: "7.4-rc"}
- {db-image: "mysql:5.6", php-version: "5.6"}
- {db-image: "mysql:5.6", php-version: "7.0"}
- {db-image: "mysql:5.6", php-version: "7.1"}
- {db-image: "mysql:5.6", php-version: "7.2"}
- {db-image: "mysql:5.6", php-version: "7.4-rc"}
- {db-image: "mysql:5.7", php-version: "5.6"}
- {db-image: "mysql:5.7", php-version: "7.0"}
- {db-image: "mysql:5.7", php-version: "7.1"}
- {db-image: "mysql:5.7", php-version: "7.2"}
- {db-image: "mysql:5.7", php-version: "7.4-rc"}
- {db-image: "mysql:8.0", php-version: "5.6"}
- {db-image: "mysql:8.0", php-version: "7.0"}
- {db-image: "mysql:8.0", php-version: "7.1"}
- {db-image: "mysql:8.0", php-version: "7.2"}
- {db-image: "mysql:8.0", php-version: "7.4-rc"}
services:
app:
image: "glpi/githubactions-php:${{ matrix.php-version }}"
options: >-
--volume /glpi:/var/glpi
db:
image: "glpi/githubactions-${{ matrix.db-image }}"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--shm-size=1g
steps:
- name: "Checkout"
uses: "actions/checkout@v1"
- name: "Deploy source into app container"
run: |
sudo cp --no-target-directory --preserve --recursive `pwd` /glpi
sudo chown -R 1000:1000 /glpi
- name: "Initialize databases"
run: |
docker exec ${{ job.services.db.id }} mysql --user=root --execute="CREATE DATABASE \`glpi\`;"
docker exec ${{ job.services.db.id }} mysql --user=root --execute="CREATE DATABASE \`glpitest0723\`;"
cat tests/glpi-0.72.3-empty.sql | docker exec --interactive ${{ job.services.db.id }} mysql --user=root glpitest0723
- name: "Install dependencies"
run: |
docker exec ${{ job.services.app.id }} perl -i -0 -p -e 's/,?\s*"platform"\:\s*\{[^\}]*}//i' composer.json
docker exec ${{ job.services.app.id }} rm composer.lock
docker exec ${{ job.services.app.id }} composer --version
docker exec ${{ job.services.app.id }} composer install --optimize-autoloader --prefer-dist --no-interaction --no-progress --no-suggest
- name: "Install DB tests"
run: |
docker exec ${{ job.services.app.id }} bin/console glpi:database:install --config-dir=./tests --no-interaction --db-name=glpi --db-host=db --db-user=root
docker exec ${{ job.services.app.id }} bin/console glpi:database:update --config-dir=./tests --no-interaction | grep -q "No migration needed." || (echo "glpi:database:update command FAILED" && exit 1)
- name: "Unit tests"
run: |
docker exec ${{ job.services.app.id }} vendor/bin/atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --configurations tests/telemetry.php --bootstrap-file tests/bootstrap.php --no-code-coverage -d tests/units
- name: "Functionnal tests"
run: |
docker exec ${{ job.services.app.id }} vendor/bin/atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --configurations tests/telemetry.php --bootstrap-file tests/bootstrap.php --no-code-coverage --max-children-number 1 -d tests/functionnal
- name: "WEB tests"
run: |
docker exec ${{ job.services.app.id }} php -S localhost:8088 tests/router.php &>/dev/null &
docker exec ${{ job.services.app.id }} vendor/bin/atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --configurations tests/telemetry.php --bootstrap-file tests/bootstrap.php --no-code-coverage --max-children-number 1 -d tests/web
- name: "Update DB tests"
run: |
docker exec ${{ job.services.app.id }} cp tests/github_actions.config_db.php tests/config_db.php
docker exec ${{ job.services.app.id }} bin/console glpi:database:update --config-dir=./tests --allow-unstable --no-interaction
docker exec ${{ job.services.app.id }} bin/console glpi:database:update --config-dir=./tests --allow-unstable --no-interaction | grep -q "No migration needed." || (echo "glpi:database:update command FAILED" && exit 1)
docker exec ${{ job.services.app.id }} bin/console glpi:migration:myisam_to_innodb --config-dir=./tests --no-interaction
docker exec ${{ job.services.app.id }} rm tests/config_db.php
- name: "Database tests"
run: |
docker exec ${{ job.services.app.id }} cp tests/github_actions.config_db.php tests/config_db.php
docker exec ${{ job.services.app.id }} vendor/bin/atoum -p 'php -d memory_limit=512M' --debug --force-terminal --use-dot-report --configurations tests/telemetry.php --bootstrap-file tests/bootstrap.php --no-code-coverage --max-children-number 1 -d tests/database
docker exec ${{ job.services.app.id }} rm tests/config_db.php
37 changes: 37 additions & 0 deletions tests/github_actions.config_db.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* ---------------------------------------------------------------------
* GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2015-2018 Teclib' and contributors.
*
* http://glpi-project.org
*
* based on GLPI - Gestionnaire Libre de Parc Informatique
* Copyright (C) 2003-2014 by the INDEPNET Development Team.
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* GLPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
class DB extends DBmysql {
public $dbhost = 'db';
public $dbuser = 'root';
public $dbpassword = '';
public $dbdefault = 'glpitest0723';
}

0 comments on commit 5b57ea0

Please sign in to comment.