try using hosted image #636
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: Unit Testing | |
permissions: | |
contents: write | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
phpunit: | |
name: PHPUnit | |
runs-on: ubuntu-20.04 | |
services: | |
memcached: | |
image: memcached:1.6 | |
ports: | |
- 11211:11211 | |
options: --name memcached-container | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: test | |
MYSQL_USER: test | |
MYSQL_PASSWORD: test | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
postgres: | |
image: postgres:13 | |
env: | |
POSTGRES_DB: test | |
POSTGRES_USER: test | |
POSTGRES_PASSWORD: test | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: | |
- 8.1 | |
- 8.2 | |
database: | |
- mysql | |
- pgsql | |
- sqlite | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
coverage: pcov | |
ini-values: zend.assertions=1, assert.exception=1 | |
php-version: ${{ matrix.php-version }} | |
extensions: memcached | |
tools: cs2pr | |
- name: Install dependencies with Composer | |
uses: ramsey/composer-install@v2 | |
- name: Create and set permissions on SQLite Database | |
run: | | |
touch test.db | |
echo $USER:$USER | |
sudo chown $USER:$USER test.db | |
chmod 777 test.db | |
# Verify SQLite installation and permissions | |
- name: Verify SQLite setup | |
run: | | |
sqlite3 --version | |
ls -la test.db | |
sqlite3 test.db "CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY, name TEXT);" | |
ls -la test.db | |
- name: Verify MySQL | |
run: | | |
echo "MySQL Connection String: mysql://test:test@localhost:3306/test" | |
- name: Verify PostgreSQL | |
run: | | |
echo "PostgreSQL Connection String: postgres://test:test@localhost:5432/test" | |
- name: Run PHPUnit | |
env: | |
DATABASE: ${{ matrix.database }} | |
CI: true | |
run: | | |
vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=coverage.xml | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
if: matrix.php-version == 8.1 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |