Skip to content

CI

CI #386

Workflow file for this run

name: CI
on:
push:
branches:
- 'main'
- 'develop'
pull_request:
workflow_dispatch:
jobs:
testsuite:
name: "Test Suite"
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
php-version: [ '8.1', '8.4' ]
db-type: [ sqlite, mysql, pgsql, agnostic ]
symfony-version: [ '5-min', '5-max', '6-min', '6-max', '7-min', '7-max']
exclude:
- symfony-version: '6-min'
php-version: '8.1'
- symfony-version: '6-max'
php-version: '8.1'
- symfony-version: '7-min'
php-version: '8.1'
- symfony-version: '7-max'
php-version: '8.1'
env:
DB_NAME: 'propel_tests'
DB_USER: 'propel'
DB_PW: 'propel'
steps:
- name: Install PostgreSQL latest
if: matrix.db-type == 'pgsql' && matrix.php-version != '8.1'
uses: CasperWA/postgresql-action@v1.2
with:
postgresql db: $DB_NAME
postgresql user: $DB_USER
postgresql password: $DB_PW
- name: Install PostgreSQL min
if: matrix.db-type == 'pgsql' && matrix.php-version == '8.1'
uses: CasperWA/postgresql-action@v1.2
with:
postgresql version: 9
postgresql db: $DB_NAME
postgresql user: $DB_USER
postgresql password: $DB_PW
- name: Install MySQL latest
if: matrix.db-type == 'mysql' && matrix.php-version != '8.1'
uses: mirromutth/mysql-action@v1.1
with:
mysql root password: $DB_PW
- name: Install MariaDb min
if: matrix.db-type == 'mysql' && matrix.php-version == '8.1'
uses: getong/mariadb-action@v1.1
with:
mariadb version: '10.2'
mysql root password: $DB_PW
- uses: actions/checkout@v3
- name: Move specific composer.json (Symfony version ${{ matrix.symfony-version }})
run: mv tests/composer/composer-symfony${{ matrix.symfony-version }}.json composer.json
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: ${{ matrix.php-version }}
symfony-version: ${{ matrix.symfony-version }}
cache-key-suffix: ${{ matrix.db-type}}
- name: Wait for MySQL server to load
if: matrix.db-type == 'mysql'
run: |
bash -c "
for i in {1..10}; do
mysqladmin -h 127.0.0.1 -u root status >/dev/null 2>&1 && exit 0 || sleep 6
echo 'trying again'
done;
echo 'could not establish connection after 10 tries'
exit 1
"
env:
MYSQL_PWD: ${{ env.DB_PW }}
- name: Create MySQL Propel user
if: matrix.db-type == 'mysql'
run: |
mysql -h 127.0.0.1 -u root -e "
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PW';
CREATE USER '$DB_USER'@'%' IDENTIFIED BY '$DB_PW';
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'%';
FLUSH PRIVILEGES;
"
env:
MYSQL_PWD: ${{ env.DB_PW }}
- name: Setup database for test suite
if: matrix.db-type != 'agnostic'
run: tests/bin/setup.${{ matrix.db-type }}.sh
- name: Run tests
shell: 'script -q -e -c "bash {0}"'
run: |
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.symfony-version }} == '5-max' ]]; then
export CODECOVERAGE=1 && vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml --verbose --coverage-clover=tests/coverage.xml
else
vendor/bin/phpunit -c tests/${{ matrix.db-type }}.phpunit.xml
fi
env:
SYMFONY_VERSION: ${{ matrix.symfony-version }}
- name: Code Coverage Report
if: success() && matrix.php-version == '8.1' && matrix.symfony-version == '5-max'
uses: codecov/codecov-action@v1
with:
flags: ${{ matrix.php-version }}, ${{ matrix.db-type }}, ${{ matrix.symfony-version }}
file: tests/coverage.xml
static-analysis:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.1
symfony-version: 6-max
cache-key-suffix: sa
- name: PHPStan
env:
PHPSTAN: 1
run: composer stan
- name: Psalm
run: composer psalm -- --php-version=${{ steps.build-container.outputs.php-version }}
code-style:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.4
symfony-version: 6-max
cache-key-suffix: cs
- name: Code Style
run: composer cs-check
model-code-style:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.4
symfony-version: 6-max
cache-key-suffix: cs
- name: Lint Model Code
run: |
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
&& composer cs-check tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*[^Query].php
model-static-analysis:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.4
symfony-version: 6-max
cache-key-suffix: cs
- name: Analyze Model Code
run: |
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
&& composer stan -- -a autoload.php.dist tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*[^Query].php
query-code-style:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.4
symfony-version: 6-max
cache-key-suffix: cs
- name: Lint Query Code
run: |
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
&& composer cs-check tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*Query.php
query-static-analysis:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- id: build-container
uses: ./.github/actions/setup-php
with:
php-version: 8.4
symfony-version: 6-max
cache-key-suffix: cs
- name: Analyze Query Code
run: |
bin/propel test:prepare --vendor=sqlite --dsn='sqlite:/tmp/perpl.sq3' --exclude-database \
&& composer stan -- -a autoload.php.dist tests/Fixtures/bookstore/build/classes/Propel/Tests/Bookstore/Base/*Query.php