Skip to content

Commit 741db7d

Browse files
author
Emmanuel Campait
committed
ci/docs: standardize badges and fix QA workflows across packages
1 parent 855d1ac commit 741db7d

7 files changed

Lines changed: 167 additions & 6 deletions

File tree

.github/workflows/phpstan.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PHPStan
2+
3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
jobs:
13+
phpstan:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
extensions: intl, mbstring
25+
coverage: none
26+
27+
- name: Install dependencies
28+
run: composer install --no-interaction --prefer-dist
29+
30+
- name: Run PHPStan
31+
run: vendor/bin/phpstan analyse -c phpstan.neon.dist --memory-limit=512M

.github/workflows/phpunit.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: PHPUnit
2+
3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
jobs:
13+
phpunit:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
extensions: intl, mbstring
25+
coverage: xdebug
26+
27+
- name: Install dependencies
28+
run: composer install --no-interaction --prefer-dist
29+
30+
- name: Run PHPUnit
31+
run: composer test

.github/workflows/psalm.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Psalm
2+
3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
jobs:
13+
psalm:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v5
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.2'
24+
extensions: intl, mbstring
25+
coverage: none
26+
27+
- name: Install dependencies
28+
run: composer install --no-interaction --prefer-dist
29+
30+
- name: Prepare Psalm cache directory
31+
run: mkdir -p build build/psalm
32+
33+
- name: Run Psalm
34+
run: vendor/bin/psalm --config=psalm.xml

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Bootstrap Icons for CodeIgniter 4
22

3+
[![Packagist](https://img.shields.io/packagist/v/domprojects/codeigniter4-bootstrap-icons?label=Packagist)](https://packagist.org/packages/domprojects/codeigniter4-bootstrap-icons)
4+
[![License](https://img.shields.io/github/license/domProjects/codeigniter4-bootstrap-icons)](https://github.com/domProjects/codeigniter4-bootstrap-icons/blob/main/LICENSE)
5+
[![PHPUnit](https://img.shields.io/github/actions/workflow/status/domProjects/codeigniter4-bootstrap-icons/phpunit.yml?branch=main&label=PHPUnit)](https://github.com/domProjects/codeigniter4-bootstrap-icons/actions/workflows/phpunit.yml)
6+
[![Psalm](https://img.shields.io/github/actions/workflow/status/domProjects/codeigniter4-bootstrap-icons/psalm.yml?branch=main&label=Psalm)](https://github.com/domProjects/codeigniter4-bootstrap-icons/actions/workflows/psalm.yml)
7+
[![PHPStan](https://img.shields.io/github/actions/workflow/status/domProjects/codeigniter4-bootstrap-icons/phpstan.yml?branch=main&label=PHPStan)](https://github.com/domProjects/codeigniter4-bootstrap-icons/actions/workflows/phpstan.yml)
8+
39
Bootstrap Icons asset publisher for CodeIgniter 4 projects.
410

511
## Features

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"domProjects\\CodeIgniterBootstrapIcons\\Tests\\": "tests/"
4242
}
4343
},
44+
"minimum-stability": "dev",
45+
"prefer-stable": true,
4446
"config": {
4547
"allow-plugins": {
4648
"phpstan/extension-installer": true
@@ -56,7 +58,7 @@
5658
],
5759
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.dist.php",
5860
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.dist.php",
59-
"test": "phpunit -c phpunit.xml.dist"
61+
"test": "@php -d xdebug.mode=coverage vendor/bin/phpunit -c phpunit.xml.dist"
6062
},
6163
"extra": {
6264
"branch-alias": {

psalm.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ensureOverrideAttribute="false"
77
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
88
xmlns="https://getpsalm.org/schema/config"
9-
xsi:schemaLocation="https://getpsalm.org/schema/config ../../../vendor/vimeo/psalm/config.xsd"
9+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
1010
autoloader="psalm_autoload.php"
1111
cacheDirectory="build/psalm/"
1212
findUnusedBaselineEntry="true"
@@ -17,7 +17,7 @@
1717
<directory name="tests/" />
1818
<ignoreFiles>
1919
<directory name="build" />
20-
<directory name="../../../vendor" />
20+
<directory name="vendor" />
2121
<directory name="tests/_support" />
2222
</ignoreFiles>
2323
</projectFiles>

tests/bootstrap.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14-
$rootPath = realpath(__DIR__ . '/../../../../');
14+
$packageRoot = realpath(__DIR__ . '/..');
15+
$rootPath = $packageRoot;
16+
$packageMode = $packageRoot !== false && is_file($packageRoot . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
1517

16-
if ($rootPath === false) {
18+
if (! $packageMode) {
19+
$rootPath = realpath(__DIR__ . '/../../../../');
20+
}
21+
22+
if ($rootPath === false || ! is_file($rootPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
1723
throw new RuntimeException('Unable to resolve the project root for bootstrap icons tests.');
1824
}
1925

@@ -23,8 +29,59 @@
2329
throw new RuntimeException('Unable to create the test public directory for bootstrap icons tests.');
2430
}
2531

32+
if ($packageMode) {
33+
$testAppRoot = $rootPath . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'test-app';
34+
$configPath = $testAppRoot . DIRECTORY_SEPARATOR . 'Config';
35+
$writablePath = $rootPath . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'writable';
36+
$frameworkRoot = $rootPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'codeigniter4' . DIRECTORY_SEPARATOR . 'framework';
37+
$pathsFile = $configPath . DIRECTORY_SEPARATOR . 'Paths.php';
38+
39+
if (! is_dir($configPath) && ! mkdir($configPath, 0775, true) && ! is_dir($configPath)) {
40+
throw new RuntimeException('Unable to create the test config directory for bootstrap icons tests.');
41+
}
42+
43+
foreach ([$writablePath, $writablePath . DIRECTORY_SEPARATOR . 'cache', $writablePath . DIRECTORY_SEPARATOR . 'logs', $writablePath . DIRECTORY_SEPARATOR . 'session', $writablePath . DIRECTORY_SEPARATOR . 'uploads'] as $directory) {
44+
if (! is_dir($directory) && ! mkdir($directory, 0775, true) && ! is_dir($directory)) {
45+
throw new RuntimeException('Unable to create the writable directory for bootstrap icons tests.');
46+
}
47+
}
48+
49+
$pathsContents = <<<PHP
50+
<?php
51+
52+
namespace Config;
53+
54+
class Paths
55+
{
56+
public string \$systemDirectory = %s;
57+
public string \$appDirectory = %s;
58+
public string \$writableDirectory = %s;
59+
public string \$testsDirectory = %s;
60+
public string \$viewDirectory = %s;
61+
public string \$envDirectory = %s;
62+
}
63+
PHP;
64+
65+
$pathsContents = sprintf(
66+
$pathsContents,
67+
var_export(str_replace('\\', '/', $frameworkRoot . '/system'), true),
68+
var_export(str_replace('\\', '/', $frameworkRoot . '/app'), true),
69+
var_export(str_replace('\\', '/', $writablePath), true),
70+
var_export(str_replace('\\', '/', $rootPath . DIRECTORY_SEPARATOR . 'tests'), true),
71+
var_export(str_replace('\\', '/', $frameworkRoot . '/app/Views'), true),
72+
var_export(str_replace('\\', '/', $rootPath), true),
73+
);
74+
75+
if (! is_file($pathsFile) || file_get_contents($pathsFile) !== $pathsContents) {
76+
file_put_contents($pathsFile, $pathsContents);
77+
}
78+
79+
defined('CONFIGPATH') || define('CONFIGPATH', $configPath . DIRECTORY_SEPARATOR);
80+
} else {
81+
defined('CONFIGPATH') || define('CONFIGPATH', $rootPath . DIRECTORY_SEPARATOR . 'app/Config' . DIRECTORY_SEPARATOR);
82+
}
83+
2684
defined('HOMEPATH') || define('HOMEPATH', $rootPath . DIRECTORY_SEPARATOR);
27-
defined('CONFIGPATH') || define('CONFIGPATH', $rootPath . DIRECTORY_SEPARATOR . 'app/Config' . DIRECTORY_SEPARATOR);
2885
defined('PUBLICPATH') || define('PUBLICPATH', $publicPath . DIRECTORY_SEPARATOR);
2986
defined('TESTPATH') || define('TESTPATH', __DIR__ . DIRECTORY_SEPARATOR);
3087
defined('SUPPORTPATH') || define('SUPPORTPATH', __DIR__ . DIRECTORY_SEPARATOR . '_support' . DIRECTORY_SEPARATOR);

0 commit comments

Comments
 (0)