Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CI tests using Gihub actions (9.5) #2

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ad9918e
Fix parsing of classes on Search::testSearchOptions()
cedric-anne Sep 30, 2019
54621ad
Fix notice trigerred when ticket has no followup
cedric-anne Sep 30, 2019
87b0ed1
Bump simplepie/simplepie from 1.5.2 to 1.5.3
dependabot-preview[bot] Oct 1, 2019
b33119f
Bump zendframework/zend-i18n from 2.9.1 to 2.9.2
dependabot-preview[bot] Oct 1, 2019
d0555ad
Fix error handling in unit tests
cedric-anne Sep 30, 2019
39d2dce
Fix glpi_documents_items.date_creation column type
cedric-anne Oct 1, 2019
742f013
Impact analysis 1/2 (#5954)
AdrienClairembault Oct 1, 2019
27f5a09
Planning V2
orthagh Jun 24, 2019
e1a6f1d
Multiple fixes
cedric-anne Oct 1, 2019
a6fdb70
Fix invalid nothing return type in PHPDoc
cedric-anne Oct 1, 2019
175acab
Use UK wording for analyse
trasher Oct 1, 2019
bc294cf
Add DB::quote for future PDO compat
trasher Sep 25, 2019
7dabe27
Add missing PDU links
cconard96 Oct 1, 2019
4371de6
fix links in event list
cconard96 Oct 1, 2019
a4a4999
Drop dead code causing SQL error
cconard96 Oct 1, 2019
fa6a7b6
give the ID of the user after init session
btry Oct 2, 2019
24f67d1
set execution time only if request succeeds
btry Oct 3, 2019
785b363
Run CI tests using Gihub actions
cedric-anne Sep 2, 2019
2c0e627
Remove builds for 7.0, not needed
trasher Oct 3, 2019
9d4b3d7
Use same openldap host on all CI env
cedric-anne Oct 3, 2019
0f500ef
Merge branch '9.4/bugfixes' into 9.5/bugfixes
trasher Oct 3, 2019
bbf5c75
Adapt Github Actions to 9.5
cedric-anne Sep 2, 2019
03cd8aa
Fix npm install on alpine 3.7
cedric-anne Sep 27, 2019
0dccf31
Remove type hinting to prevent warns from atoum on PHP 7.4
cedric-anne Sep 30, 2019
4940e96
Fix merge
cedric-anne Oct 3, 2019
57be413
Remove type hinting to prevent warns from atoum on PHP 7.4
cedric-anne Oct 3, 2019
314a23c
Reorder tests
cedric-anne Oct 3, 2019
a24a0de
Remove type hinting to prevent warns from atoum on PHP 7.4
cedric-anne Oct 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ workflows:
filters:
tags:
only: /.*/ # run also on tag creation
branches:
ignore: /.*/ # do not run on branch update
- php_7_1_test_suite:
requires:
- checkout
Expand Down
140 changes: 140 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: "GLPI CI"

on: ["push"]

jobs:
lint:
name: "Lint"
runs-on: "ubuntu-latest"
services:
app:
image: "glpi/githubactions-php:7.0"
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 }} composer config --unset platform
docker exec ${{ job.services.app.id }} rm composer.lock
docker exec ${{ job.services.app.id }} composer --version
docker exec ${{ job.services.app.id }} echo "node version: $(node --version)"
docker exec ${{ job.services.app.id }} echo "npm version: $(npm --version)"
docker exec ${{ job.services.app.id }} bin/console dependencies install --ci
- 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/,/node_modules/,/plugins/,/tests/config/,/vendor/ ./
- name: "ESLint"
run: |
docker exec ${{ job.services.app.id }} node_modules/.bin/eslint ./js && echo "ESLint found no errors"
docker exec ${{ job.services.app.id }} node_modules/.bin/eslint --env=node --parser-options=ecmaVersion:6 --rule 'indent: ["error", 4]' ./webpack.config.js && echo "ESLint found no errors"
- name: "Check CSS compilation"
run: |
docker exec ${{ job.services.app.id }} bin/console build:compile_scss

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:
#- "7.0"
#- "7.1"
#- "7.2"
- "7.3"
- "7.4-rc"
exclude:
- {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
dovecot:
image: "glpi/githubactions-dovecot"
openldap:
image: "glpi/githubactions-openldap"
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 }} composer config --unset platform
docker exec ${{ job.services.app.id }} rm composer.lock
docker exec ${{ job.services.app.id }} composer --version
docker exec ${{ job.services.app.id }} echo "node version: $(node --version)"
docker exec ${{ job.services.app.id }} echo "npm version: $(npm --version)"
docker exec ${{ job.services.app.id }} bin/console dependencies install --ci
- name: "Update DB tests"
run: |
docker exec ${{ job.services.app.id }} bin/console glpi:database:configure --config-dir=./tests --no-interaction --reconfigure --db-name=glpitest0723 --db-host=db --db-user=root
docker exec ${{ job.services.app.id }} bin/console glpi:migration:myisam_to_innodb --config-dir=./tests --no-interaction
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 }} bin/console glpi:migration:timestamps --config-dir=./tests --no-interaction
- name: "Install DB tests"
run: |
docker exec ${{ job.services.app.id }} bin/console glpi:database:install --config-dir=./tests --no-interaction --reconfigure --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: "Database tests"
run: |
docker exec ${{ job.services.app.id }} bin/console glpi:database:configure --config-dir=./tests --no-interaction --reconfigure --db-name=glpitest0723 --db-host=db --db-user=root
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 }} bin/console glpi:database:configure --config-dir=./tests --no-interaction --reconfigure --db-name=glpi --db-host=db --db-user=root
- 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: "LDAP tests"
run: |
for f in `ls tests/LDAP/ldif/*.ldif`; do cat $f | docker exec --interactive ${{ job.services.openldap.id }} ldapadd -x -H ldap://127.0.0.1:3890/ -D "cn=Manager,dc=glpi,dc=org" -w insecure ; done
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/LDAP
- name: "IMAP tests"
run: |
for f in `ls tests/emails-tests/*.eml`; do cat $f | docker exec --user glpi --interactive ${{ job.services.dovecot.id }} getmail_maildir /home/glpi/Maildir/ ; done
docker exec ${{ job.services.app.id }} sed -e 's/127.0.0.1/dovecot/g' -i tests/imap/MailCollector.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/imap
- 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
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,58 @@ script:
#note: default maria version is 5.5 for all main php versions list exept nightly
matrix:
include:
hosts:
- openldap
- php: 7.0
addons:
mariadb: 10.2
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
- php: 7.1
addons:
mariadb: 10.1
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
- php: 7.2
addons:
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
- php: 7.3
addons:
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
- php: 7.4snapshot
addons:
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
- php: nightly
addons:
apt:
packages:
- ldap-utils
- slapd
hosts:
- openldap
allow_failures:
- php: nightly
- php: 7.4snapshot
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The present file will list all changes made to the project; according to the
- Add and answer approvals from timeline
- Add lightbox with PhotoSwipe to timeline images
- Ability to copy tasks while merging tickets
- the API gives the ID of the user who logs in with initSession

### Changed

Expand Down
34 changes: 28 additions & 6 deletions ajax/dropdownTrackingDeviceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,27 @@

Session::checkLoginUser();

// Read parameters
$context = $_POST['context'] ?? '';
$itemtype = $_POST["itemtype"] ?? '';

// Check for required params
if (empty($itemtype)) {
http_response_code(400);
Toolbox::logWarning("Bad request: itemtype cannot be empty");
die;
}

// Check if itemtype is valid in the given context
if ($context == "impact") {
$isValidItemtype = isset($CFG_GLPI['impact_asset_types'][$itemtype]);
} else {
$isValidItemtype = CommonITILObject::isPossibleToAssignType($itemtype);
}

// Make a select box
if (isset($_POST["itemtype"])
&& CommonITILObject::isPossibleToAssignType($_POST["itemtype"])) {
$table = getTableForItemType($_POST["itemtype"]);
if ($isValidItemtype) {
$table = getTableForItemType($itemtype);

$rand = mt_rand();
if (isset($_POST["rand"])) {
Expand All @@ -52,19 +69,24 @@
}
echo "<br>";
$field_id = Html::cleanId("dropdown_".$_POST['myname'].$rand);
$p = ['itemtype' => $_POST["itemtype"],
$p = ['itemtype' => $itemtype,
'entity_restrict' => $_POST['entity_restrict'],
'table' => $table,
'multiple' => $_POST["multiple"],
'myname' => $_POST["myname"],
'rand' => $_POST["rand"]];

if (isset($_POST["used"]) && !empty($_POST["used"])) {
if (isset($_POST["used"][$_POST["itemtype"]])) {
$p["used"] = $_POST["used"][$_POST["itemtype"]];
if (isset($_POST["used"][$itemtype])) {
$p["used"] = $_POST["used"][$itemtype];
}
}

// Add context if defined
if (!empty($context)) {
$p["context"] = $context;
}

echo Html::jsAjaxDropdown($_POST['myname'], $field_id,
$CFG_GLPI['root_doc']."/ajax/getDropdownFindNum.php",
$p);
Expand Down
Loading