PHPUnit #575
This file contains hidden or 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: | |
# Run automatically every Monday on midnight. | |
schedule: | |
- cron: '0 0 * * 1' | |
workflow_call: | |
# Allow manually triggering the workflow. | |
workflow_dispatch: | |
permissions: | |
checks: write | |
pull-requests: write | |
jobs: | |
unit-tests: | |
runs-on: ${{ matrix.operating-system }} | |
strategy: | |
matrix: | |
operating-system: [ubuntu-latest] | |
php-versions: ['8.1', '8.4'] | |
mysql-version: ['5.7', '8.0', '8.4'] | |
services: | |
mysql: | |
image: mysql:${{ matrix.mysql-version }} | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: db | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Validate mysql service | |
run: | | |
echo "Checking mysql service" | |
sudo apt-get install -y mysql-client | |
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -uroot -proot -e "SHOW DATABASES" | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-versions }} | |
coverage: xdebug #optional, setup coverage driver | |
env: | |
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/checkout@v4 | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Install dependencies | |
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-* | |
- name: Install OpenMage | |
run: | | |
php -f install.php -- \ | |
--license_agreement_accepted 'yes' \ | |
--locale 'en_US' \ | |
--timezone 'America/New_York' \ | |
--db_host '127.0.0.1' \ | |
--db_name 'db' \ | |
--db_user 'root' \ | |
--db_pass 'root' \ | |
--db_prefix '' \ | |
--url 'http://openmage.local' \ | |
--use_rewrites 'yes' \ | |
--use_secure 'yes' \ | |
--secure_base_url 'http://openmage.local' \ | |
--use_secure_admin 'yes' \ | |
--admin_username 'admin' \ | |
--admin_lastname 'Administrator' \ | |
--admin_firstname 'OpenMage' \ | |
--admin_email '[email protected]' \ | |
--admin_password 'veryl0ngpassw0rd' \ | |
--session_save 'files' \ | |
--admin_frontname 'admin' \ | |
--backend_frontname 'admin' \ | |
--default_currency 'USD' \ | |
--enable_charts 'yes' \ | |
--skip_url_validation 'yes' | |
- name: Restore result cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: .phpunit.result.cache | |
key: phpunit-result-cache-${{ matrix.php-versions }}-${{ matrix.mysql-version }}-${{ github.run_id }} | |
restore-keys: | | |
phpunit-result-cache- | |
- name: Run phpUnit | |
run: php vendor/bin/phpunit --configuration .phpunit.dist.xml --testsuite Base,Error,Mage,Varien | |
- name: Save result cache | |
uses: actions/cache/save@v4 | |
if: always() | |
with: | |
path: .phpunit.result.cache | |
key: phpunit-result-cache-${{ matrix.php-versions }}-${{ matrix.mysql-version }}-${{ github.run_id }} | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
if: always() | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
files: tests/logging/*.xml | |
- name: SonarQube Scan | |
uses: SonarSource/sonarqube-scan-action@v5 | |
continue-on-error: true | |
if: ${{ (matrix.php-versions == '8.1') && (matrix.mysql-version == '5.7') }} | |
with: | |
args: > | |
-Dproject.settings=tests/sonar-project.properties | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |