Skip to content

Commit 0375cc6

Browse files
committed
update workflows/phpunit.yml to use qltysh/qlty-action/coverage@v1 vs paambaati/codeclimate-action@v8.0.0
1 parent f0e03f4 commit 0375cc6

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

.github/workflows/phpunit.yml

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
name: PHPUnit
2-
on: [push, pull_request]
3-
permissions: read-all
2+
on: [push, pull_request, workflow_dispatch]
3+
permissions:
4+
contents: read
5+
id-token: write
46
jobs:
57
run:
68
runs-on: ${{ matrix.operating-system }}
9+
timeout-minutes: 15
710
strategy:
811
matrix:
912
operating-system: [ubuntu-latest]
@@ -13,15 +16,26 @@ jobs:
1316
MYSQL_DATABASE: test
1417
MYSQL_USERNAME: root
1518
MYSQL_PASSWORD: root
19+
COVERAGE_VER: '8.3'
1620
steps:
1721
- name: Set up MySQL
18-
continue-on-error: true
1922
run: |
20-
sudo /etc/init.d/mysql start --default-auth=mysql_native_password
21-
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_USERNAME }} -p${{ env.MYSQL_PASSWORD }}
22-
mysqld --version
23+
# Start MySQL service
24+
sudo systemctl start mysql
25+
# Wait for MySQL to be ready
26+
sudo mysql --wait --connect-timeout=60 -e "SELECT 1" 2>/dev/null || sleep 5
27+
# Create database
28+
sudo mysql -e 'CREATE DATABASE IF NOT EXISTS ${{ env.MYSQL_DATABASE }};'
29+
# Set up root user with legacy authentication for older PHP versions compatibility
30+
sudo mysql -e "ALTER USER '${{ env.MYSQL_USERNAME }}'@'localhost' IDENTIFIED WITH mysql_native_password BY '${{ env.MYSQL_PASSWORD }}';" 2>/dev/null || \
31+
sudo mysql -e "SET PASSWORD FOR '${{ env.MYSQL_USERNAME }}'@'localhost' = PASSWORD('${{ env.MYSQL_PASSWORD }}');" 2>/dev/null || \
32+
sudo mysql -e "UPDATE mysql.user SET Password=PASSWORD('${{ env.MYSQL_PASSWORD }}') WHERE User='${{ env.MYSQL_USERNAME }}';" 2>/dev/null
33+
sudo mysql -e "FLUSH PRIVILEGES;"
34+
# Verify connection works
35+
mysql -u${{ env.MYSQL_USERNAME }} -p${{ env.MYSQL_PASSWORD }} -e "SHOW DATABASES;" | grep ${{ env.MYSQL_DATABASE }}
36+
echo "MySQL version: $(mysqld --version)"
2337
- name: Checkout
24-
uses: actions/checkout@v4
38+
uses: actions/checkout@v4.1.1
2539
- name: Install PHP
2640
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
2741
with:
@@ -48,19 +62,17 @@ jobs:
4862
composer --version
4963
composer install --prefer-dist --no-progress
5064
- name: Unit test
65+
# This step runs tests for all PHP versions except where we're collecting coverage in the next step
66+
if: ${{ matrix.php-version != env.COVERAGE_VER || github.ref_name != 'master' }}
5167
run: composer run test
52-
# continue-on-error: ${{ matrix.php-version == '5.4' }}
68+
- name: Run code coverage
69+
if: ${{ matrix.php-version == env.COVERAGE_VER && github.ref_name == 'master' }}
70+
run: |
71+
vendor/bin/phpunit --coverage-clover coverage/clover.xml
72+
php -f vendor/bdk/devutil/src/coverageChecker.php -- coverage/clover.xml
5373
- name: Publish code coverage
54-
if: ${{ matrix.php-version == '8.2' && github.ref_name == 'master' }}
55-
uses: paambaati/codeclimate-action@v8.0.0
56-
continue-on-error: true
57-
env:
58-
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
74+
if: ${{ matrix.php-version == env.COVERAGE_VER && github.ref_name == 'master' }}
75+
uses: qltysh/qlty-action/coverage@v1
5976
with:
60-
debug: false
61-
coverageCommand: vendor/bin/phpunit --coverage-clover coverage/clover.xml
62-
coverageLocations: coverage/clover.xml:clover
63-
- name: Coverage summary
64-
if: ${{ matrix.php-version == '8.2' && github.ref_name == 'master' }}
65-
continue-on-error: true
66-
run: php -f vendor/bdk/devutil/src/coverageChecker.php -- coverage/clover.xml
77+
files: coverage/clover.xml
78+
oidc: true

0 commit comments

Comments
 (0)