XMF 1.2.31 #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push, pull_request] | |
jobs: | |
phpunit-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# PHP 8.1 | |
- php_version: "8.1" | |
phpunit_version: "9.6" | |
# PHP 8.2 | |
- php_version: "8.2" | |
phpunit_version: "10.5" | |
# PHP 8.3 | |
- php_version: "8.3" | |
phpunit_version: "10.5" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php_version }} | |
coverage: xdebug | |
tools: composer:v2 | |
- name: Create composer.json | |
working-directory: htdocs/class/libraries | |
env: | |
PHP_VERSION: ${{ matrix.php_version }} | |
PHPUNIT_VERSION: ${{ matrix.phpunit_version }} | |
run: | | |
cat > composer.json << EOL | |
{ | |
"name": "xoopscore25/libraries", | |
"license": "GPL-2.0-or-later", | |
"type": "project", | |
"description": "Libraries for XOOPS 2.5.12", | |
"config": { | |
"platform": { | |
"php": "$PHP_VERSION" | |
}, | |
"allow-plugins": { | |
"composer/installers": true | |
} | |
}, | |
"require": { | |
"php": ">=${PHP_VERSION}", | |
"xoops/base-requires25": "^1.1.6" | |
}, | |
"require-dev": { | |
"phpunit/phpunit": "^${PHPUNIT_VERSION}" | |
}, | |
"minimum-stability": "stable" | |
} | |
EOL | |
cat composer.json | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: | | |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache Composer Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install Dependencies | |
working-directory: htdocs/class/libraries | |
env: | |
PHPUNIT_VERSION: ${{ matrix.phpunit_version }} | |
run: | | |
composer update --prefer-dist --no-interaction --no-progress | |
# The phpunit dependency is already specified in composer.json, so no need to require it again. | |
ls -la vendor/bin | |
if [ -f "vendor/bin/phpunit" ]; then | |
echo "PHPUnit is installed" | |
vendor/bin/phpunit --version | |
else | |
echo "PHPUnit installation failed" | |
exit 1 | |
fi | |
- name: Create PHPUnit Config | |
working-directory: htdocs/class/libraries | |
run: | | |
cat > phpunit.xml << EOL | |
<?xml version="1.0" encoding="UTF-8"?> | |
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | |
bootstrap="vendor/autoload.php" | |
colors="true" | |
verbose="true" | |
failOnRisky="true" | |
failOnWarning="true" | |
testdox="true"> | |
<testsuites> | |
<testsuite name="XOOPS Test Suite"> | |
<directory>tests</directory> | |
</testsuite> | |
</testsuites> | |
<coverage> | |
<include> | |
<directory>src</directory> | |
</include> | |
</coverage> | |
<php> | |
<ini name="error_reporting" value="-1"/> | |
<ini name="display_errors" value="On"/> | |
<ini name="display_startup_errors" value="On"/> | |
</php> | |
</phpunit> | |
EOL | |
- name: Create Test Directory and Sample Test | |
working-directory: htdocs/class/libraries | |
run: | | |
mkdir -p tests | |
cat > tests/SampleTest.php << EOL | |
<?php | |
use PHPUnit\Framework\TestCase; | |
class SampleTest extends TestCase | |
{ | |
public function testTrue(): void | |
{ | |
\$this->assertTrue(true); | |
} | |
} | |
EOL | |
- name: Run PHPUnit | |
working-directory: htdocs/class/libraries | |
run: | | |
echo "Current directory: $(pwd)" | |
echo "Contents of vendor/bin:" | |
ls -la vendor/bin | |
vendor/bin/phpunit --version | |
vendor/bin/phpunit --configuration phpunit.xml --stderr |