Browse Source

Config files for various code quality services

Timothy J. Warren 3 years ago
parent
commit
ea09367e77
7 changed files with 102 additions and 17 deletions
  1. 25 0
      .scrutinizer.yml
  2. 27 0
      .travis.yml
  3. 7 3
      phpci.yml
  4. 2 2
      tests/bootstrap.php
  5. 11 12
      tests/env/autoloader.php
  6. 15 0
      tests/phinx/mysql.yml
  7. 15 0
      tests/phinx/pgsql.yml

+ 25 - 0
.scrutinizer.yml View File

@@ -0,0 +1,25 @@
1
+imports:
2
+    - php
3
+
4
+tools:
5
+    external_code_coverage:
6
+        timeout: 1000
7
+    # PHP
8
+
9
+    # Don't like PSR standards, not going to get messages for them!
10
+    php_code_sniffer: false
11
+
12
+    php_sim: true
13
+    # Can't be used with similarity analyzer
14
+    php_cpd: false
15
+
16
+    php_mess_detector: true
17
+    php_pdepend: true
18
+    php_loc: true
19
+    php_analyzer:
20
+        config:
21
+            metrics_lack_of_cohesion_methods:
22
+                enabled: true
23
+            doc_comment_fixes:
24
+                enabled: true
25
+    php_hhvm: true

+ 27 - 0
.travis.yml View File

@@ -0,0 +1,27 @@
1
+language: php
2
+
3
+php:
4
+  - 5.5
5
+  - 5.6
6
+  - hhvm
7
+
8
+install:
9
+  - composer install
10
+
11
+env:
12
+  - DB=mysql
13
+  - DB=pgsql
14
+
15
+before_script:
16
+  - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS todo_test;' -U postgres; fi"
17
+  - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database todo_test;' -U postgres; fi"
18
+  - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS todo_test;'; fi";
19
+
20
+script:
21
+  - vendor/bin/phinx migrate -e testing -c tests/phinx/$DB.yml
22
+  - mkdir -p build/logs
23
+  - cd tests && phpunit --coverage-clover build/logs/clover.xml
24
+
25
+after_script:
26
+    - wget https://scrutinizer-ci.com/ocular.phar
27
+    - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

+ 7 - 3
phpci.yml View File

@@ -10,18 +10,22 @@ build_settings:
10 10
     - "migrations"
11 11
 
12 12
 setup:
13
+  composer:
14
+    action: "install"
13 15
   env:
14 16
     APPLICATION_ENV: "development"
17
+  shell:
18
+    - "cd %BUILD_PATH% && vendor/bin/phinx rollback -e testing -t0"
19
+    - "cd %BUILD_PATH% && vendor/bin/phinx migrate -e testing"
15 20
 
16 21
 test:
17 22
   php_unit:
18 23
     config: 'tests/phpunit.xml'
19 24
     run_from: 'tests'
20
-    coverage: '../web/coverage/'
21 25
   php_mess_detector:
22 26
     allowed_warnings: 10
23 27
     rules:
24 28
       - "unusedcode"
25 29
       - "naming"
26
-  php_docblock_checker:
27
-  php_loc:
30
+#  php_docblock_checker:
31
+#  php_loc:

+ 2 - 2
tests/bootstrap.php View File

@@ -1,10 +1,10 @@
1 1
 <?php
2 2
 
3 3
 // Require base bootstrap file
4
-require_once('../application/third_party/CIUnit/bootstrap_phpunit.php');
4
+require_once(__DIR__ . '/../application/third_party/CIUnit/bootstrap_phpunit.php');
5 5
 
6 6
 // Require autoloader
7
-require_once('./env/autoloader.php');
7
+require_once(__DIR__ . '/env/autoloader.php');
8 8
 
9 9
 /**
10 10
  * Noop Controller

+ 11 - 12
tests/env/autoloader.php View File

@@ -6,30 +6,29 @@
6 6
 spl_autoload_register(function($class) {
7 7
 
8 8
 	$paths = [
9
-
10
-		'../application/controllers/',
11
-		'../application/models/',
12
-		'../application/libraries/',
13
-		'../application/core/',
14
-		'../system/core/',
15
-		'../system/libraries/'
9
+		'application/controllers',
10
+		'application/models',
11
+		'application/libraries',
12
+		'application/core',
13
+		'system/core',
14
+		'system/libraries'
16 15
 	];
17 16
 
18 17
 	foreach($paths as $path)
19 18
 	{
19
+		$path = __DIR__ . "/../../{$path}/";
20 20
 		$exact_file = "{$path}{$class}.php";
21 21
 		$lower_file = $path . mb_strtolower($class) . ".php";
22 22
 
23
-		if (file_exists($exact_file))
23
+		if (file_exists($lower_file))
24 24
 		{
25
-			require_once($exact_file);
25
+			require_once($lower_file);
26 26
 			return;
27 27
 		}
28
-		elseif (file_exists($lower_file))
28
+		else if (file_exists($exact_file))
29 29
 		{
30
-			require_once($lower_file);
30
+			require_once($exact_file);
31 31
 			return;
32 32
 		}
33 33
 	}
34
-
35 34
 });

+ 15 - 0
tests/phinx/mysql.yml View File

@@ -0,0 +1,15 @@
1
+paths:
2
+    migrations: %%PHINX_CONFIG_DIR%%/../../migrations
3
+
4
+environments:
5
+    default_migration_table: phinxlog
6
+    default_database: testing
7
+
8
+    testing:
9
+        adapter: mysql
10
+        host: localhost
11
+        name: todo_test
12
+        user: root
13
+        pass:
14
+        port: 3306
15
+        charset: utf8

+ 15 - 0
tests/phinx/pgsql.yml View File

@@ -0,0 +1,15 @@
1
+paths:
2
+    migrations: %%PHINX_CONFIG_DIR%%/../../migrations
3
+
4
+environments:
5
+    default_migration_table: phinxlog
6
+    default_database: testing
7
+
8
+    testing:
9
+        adapter: pgsql
10
+        host: localhost
11
+        name: todo_test
12
+        user: postgres
13
+        pass:
14
+        port: 5432
15
+        charset: utf8