make tests pass #65
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: "PHPUnit" | |
on: | |
pull_request: | |
push: | |
jobs: | |
phpunit: | |
name: "PHPUnit" | |
env: | |
LC_ALL: en_US.UTF-8 | |
CODE_COVERAGE: none | |
runs-on: ${{ matrix.operating-system }} | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: ccm_tests | |
ports: | |
- 3306:3306/tcp | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
matrix: | |
php-version: | |
- "7.3" | |
- "7.4" | |
- "8.0" | |
dependencies: | |
- "locked" | |
operating-system: | |
- "ubuntu-latest" | |
composer: | |
- "composer:v2" | |
include: | |
- php-version: 8.0 | |
operating-system: "ubuntu-latest" | |
dependencies: "highest" | |
- php-version: 7.3 | |
operating-system: "ubuntu-latest" | |
dependencies: "locked" | |
- php-version: 8.1 | |
operating-system: "ubuntu-latest" | |
dependencies: "locked" | |
- php-version: 8.2 | |
operating-system: "ubuntu-latest" | |
dependencies: "locked" | |
steps: | |
- name: Enable code coverage | |
if: matrix.php-version == '7.4' && startsWith(matrix.operating-system, 'ubuntu') && matrix.dependencies == 'locked' && github.repository_owner == 'concrete5' | |
run: printf 'CODE_COVERAGE=pcov\n' >> "$GITHUB_ENV" | |
- name: "Checkout" | |
uses: "actions/checkout@v2" | |
with: | |
fetch-depth: 2 | |
- name: "Install PHP" | |
uses: shivammathur/setup-php@2.11.0 | |
with: | |
php-version: "${{ matrix.php-version }}" | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, mysql | |
coverage: ${{ env.CODE_COVERAGE }} | |
ini-values: memory_limit=-1, pcov.directory=concrete, pcov.exclude="~(vendor|tests|js|css|config)~" | |
tools: ${{matrix.composer}} | |
- name: "Prepare mysql user" | |
run: | | |
mysql -h127.0.0.1 -uroot -proot -e "CREATE USER 'ccm_test'@'%' IDENTIFIED BY '';" | |
mysql -h127.0.0.1 -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'ccm_test'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;" | |
- name: "Install lowest dependencies" | |
if: ${{ matrix.dependencies == 'lowest' }} | |
run: | | |
composer update --prefer-lowest --no-interaction --no-progress --no-suggest | |
# Run twice for mediawiki merge | |
composer update --prefer-lowest --no-interaction --no-progress --no-suggest | |
- name: "Install highest dependencies" | |
if: ${{ matrix.dependencies == 'highest' }} | |
run: | | |
composer update --no-interaction --no-progress --no-suggest | |
- name: "Install locked dependencies" | |
if: ${{ matrix.dependencies == 'locked' }} | |
run: | | |
composer install --no-interaction --no-progress --no-suggest | |
- name: "Tests" | |
if: env.CODE_COVERAGE == 'none' | |
run: php ./concrete/vendor/phpunit/phpunit/phpunit | |
- name: "Tests with coverage" | |
if: env.CODE_COVERAGE != 'none' | |
run: php ./concrete/vendor/phpunit/phpunit/phpunit --coverage-clover=coverage.clover | |
- name: "Upload coverage" | |
if: env.CODE_COVERAGE != 'none' | |
run: | | |
wget --tries=5 https://scrutinizer-ci.com/ocular.phar | |
php ocular.phar code-coverage:upload --format=php-clover coverage.clover |