15 runs-on: ubuntu-latest
19 php-versions: [ '8.1', '8.2' ]
21 db-image: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.2', 'mariadb:10.6', 'postgres:10', 'postgres:14']
25 db-image: 'postgres:14'
29 DB: ${{ matrix.db-image }}
32 # Label used to access the service container
35 image: ${{ matrix.db-image }}
36 # Provide env variables for both mysql and pgsql
38 POSTGRES_USER: galette_tests
39 POSTGRES_PASSWORD: g@l3tte
40 POSTGRES_DB: galette_tests
41 MYSQL_USER: galette_tests
42 MYSQL_PASSWORD: g@l3tte
43 MYSQL_ROOT_PASSWORD: g@l3tte
44 MYSQL_DATABASE: galette_tests
45 # Open network ports for both mysql and pgsql
49 # Set health checks to wait until postgres has started
51 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else mysqladmin ping; fi'"
56 name: PHP ${{ matrix.php-versions }} ${{ matrix.db-image }}
60 uses: shivammathur/setup-php@v2
62 php-version: ${{ matrix.php-versions }}
64 coverage: ${{ matrix.coverage }}
66 ini-values: apc.enable_cli=1
68 - name: "Show versions"
72 echo "node $(node --version)"
73 echo "npm $(npm --version)"
74 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else mysql --version; fi"
77 uses: actions/checkout@v3
81 - name: Get composer cache directory
84 echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
86 - name: Cache dependencies
87 uses: actions/cache@v3
89 path: ${{ steps.composer-cache.outputs.dir }}
90 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
91 restore-keys: ${{ runner.os }}-composer-
93 - name: Install dependencies
98 galette/vendor/bin/phpcs -n -p --ignore=galette_tcpdf_config.php --standard=phpcs-rules.xml galette/lib/ tests/TestsBootstrap.php tests/Galette tests/plugins galette/webroot/index.php galette/includes/
102 galette/vendor/bin/twigcs galette/templates/default --severity error --display blocking
103 if: matrix.php-versions == '8.1'
105 - name: Install checker
106 working-directory: galette
107 run: composer require maglnet/composer-require-checker -W
108 if: matrix.php-versions == '8.1'
110 - name: Check missing symbols
112 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
113 if: matrix.php-versions == '8.1'
115 - name: PHPStan checks
117 galette/vendor/bin/phpstan analyze --ansi --memory-limit=2G --no-interaction --no-progress
118 if: matrix.php-versions == '8.1'
120 - name: Init for PostgreSQL (update)
122 POSTGRES_HOST: localhost
125 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
126 if: startsWith(matrix.db-image, 'postgres')
128 - name: Init for MariaDB (update)
130 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
131 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
132 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
134 - name: Update database tests
135 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/GaletteUpdate/
136 if: matrix.coverage != 'xdebug'
138 - name: Init for PostgreSQL
140 POSTGRES_HOST: localhost
143 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
144 if: startsWith(matrix.db-image, 'postgres')
146 - name: Init for MariaDB
148 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
149 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
150 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
153 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/Galette/
154 if: matrix.coverage != 'xdebug'
156 - name: Unit tests (with coverage)
157 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php -c tests/clover.php -d tests/Galette/
158 if: matrix.coverage == 'xdebug'
160 - name: Upload code coverage (scrutinizer)
163 composer require scrutinizer/ocular
165 php galette/vendor/bin/ocular code-coverage:upload --format=php-clover tests/clover.xml
166 if: matrix.coverage == 'xdebug'
168 - name: Upload code coverage (codecov)
169 uses: codecov/codecov-action@v3
171 file: tests/clover.xml
172 if: matrix.coverage == 'xdebug'