Skip to content

Fix CI to run real XOOPS test suite instead of placeholder, enable Co… #431

Fix CI to run real XOOPS test suite instead of placeholder, enable Co…

Fix CI to run real XOOPS test suite instead of placeholder, enable Co… #431

Workflow file for this run

name: CI
on: [push, pull_request]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: PHP ${{ matrix.php }}${{ matrix.deps && format(' / {0}', matrix.deps) || '' }}${{ matrix.coverage && ' / Coverage' || '' }}
runs-on: ubuntu-22.04
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
# Lowest supported dependencies test
- php: "8.2"
deps: "lowest"
# Standard tests across supported versions
- php: "8.2"
- php: "8.3"
- php: "8.4"
- php: "8.5"
# Coverage run
- php: "8.4"
coverage: true
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
with:
php-version: ${{ matrix.php }}
extensions: intl, mbstring, mysqli
tools: composer
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
- name: Show versions
run: |
php -v
composer --version
- name: Get Composer cache dir
id: composer-cache
run: echo "dir=$(composer config --global cache-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php }}-${{ matrix.deps || 'stable' }}-${{ hashFiles('**/composer.json', '.github/workflows/ci.yml') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php }}-
- name: Install XMF library dependencies
working-directory: htdocs/class/libraries
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": "${{ matrix.php }}"
},
"allow-plugins": {
"composer/installers": true
}
},
"require": {
"php": "^${{ matrix.php }}",
"xoops/base-requires25": "^1.1.10@beta"
},
"minimum-stability": "beta",
"prefer-stable": true
}
EOL
if [ "${{ matrix.deps }}" = "lowest" ]; then
composer update --prefer-lowest --prefer-stable --no-interaction --prefer-dist --no-progress
else
composer update --prefer-stable --no-interaction --prefer-dist --no-progress
fi
- name: Install PHPUnit
run: |
composer global require phpunit/phpunit:^11.2 --no-interaction --prefer-dist --no-progress
echo "$(composer global config bin-dir --absolute)" >> $GITHUB_PATH
- name: Check platform requirements
working-directory: htdocs/class/libraries
run: composer check-platform-reqs
- name: Ensure build directory exists
run: mkdir -p build/logs
- name: Run XOOPS tests
if: ${{ !matrix.coverage }}
run: cd tests && phpunit --configuration phpunit.xml.dist --stderr
- name: Run XOOPS tests with coverage
if: ${{ matrix.coverage }}
run: cd tests && phpunit --configuration phpunit.xml.dist --stderr --coverage-clover ../build/logs/clover.xml
- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
with:
files: build/logs/clover.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false