fix: use PHP to run dbtable.php since it contains PHP code not SQL #28
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: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_ROOT_PASSWORD: root | |
| MYSQL_DATABASE: blogware_test | |
| MYSQL_USER: blogwareuser | |
| MYSQL_PASSWORD: userblogware | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="mysqladmin ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.1' | |
| extensions: pdo, pdo_mysql | |
| - name: Install dependencies | |
| run: composer install --no-interaction --prefer-dist | |
| - name: Setup test database | |
| run: | | |
| mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE IF NOT EXISTS blogware_test;" | |
| php -r ' | |
| require "src/install/include/dbtable.php"; | |
| $tables = get_table_definitions(""); | |
| $pdo = new PDO("mysql:host=127.0.0.1;dbname=blogware_test", "root", "root"); | |
| foreach ($tables as $sql) { | |
| $pdo->exec($sql); | |
| } | |
| echo "Tables created successfully\n"; | |
| ' | |
| - name: Run PHPUnit | |
| run: vendor/bin/phpunit tests/unit tests/service tests/integration --testdox --colors=never |