15 runs-on: ubuntu-latest
19 php-versions: [ '7.3', '7.4', '8.0' ]
21 db-image: ['mysql:5.7', 'mysql:8.0', 'mariadb:10.2', 'mariadb:10.6', 'postgres:10', 'postgres:14']
25 db-image: 'postgres:14'
28 db-image: 'mysql:8.0' #due to a mysql config; fixed as of php 7.4
32 DB: ${{ matrix.db-image }}
35 # Label used to access the service container
38 image: ${{ matrix.db-image }}
39 # Provide env variables for both mysql and pgsql
41 POSTGRES_USER: galette_tests
42 POSTGRES_PASSWORD: g@l3tte
43 POSTGRES_DB: galette_tests
44 MYSQL_USER: galette_tests
45 MYSQL_PASSWORD: g@l3tte
46 MYSQL_ROOT_PASSWORD: g@l3tte
47 MYSQL_DATABASE: galette_tests
48 # Open network ports for both mysql and pgsql
52 # Set health checks to wait until postgres has started
54 --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else mysqladmin ping; fi'"
59 name: PHP ${{ matrix.php-versions }} ${{ matrix.db-image }}
63 uses: shivammathur/setup-php@v2
65 php-version: ${{ matrix.php-versions }}
67 coverage: ${{ matrix.coverage }}
69 ini-values: apc.enable_cli=1
71 - name: "Show versions"
75 echo "node $(node --version)"
76 echo "npm $(npm --version)"
77 docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else mysql --version; fi"
80 uses: actions/checkout@v2
82 - name: Get composer cache directory
85 echo "::set-output name=dir::$(composer config cache-files-dir)"
87 - name: Cache dependencies
88 uses: actions/cache@v2
90 path: ${{ steps.composer-cache.outputs.dir }}
91 key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
92 restore-keys: ${{ runner.os }}-composer-
94 - name: Install dependencies
99 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/fields_defs/ galette/includes/smarty_plugins/ galette/includes/functions.inc.php galette/includes/galette.inc.php galette/includes/dependencies.php galette/includes/main.inc.php
101 - name: Install checker
102 working-directory: galette
103 run: composer require maglnet/composer-require-checker
104 if: matrix.php-versions == '7.4'
106 - name: Check missing symbols
108 galette/vendor/bin/composer-require-checker check --config-file=.composer-require-checker.config.json galette/composer.json
109 if: matrix.php-versions == '7.4'
111 - name: Init for PostgreSQL (update)
113 POSTGRES_HOST: localhost
116 PGPASSWORD=g@l3tte psql -d galette_tests -a -f tests/pgsql_06.sql -U galette_tests -h localhost
117 if: startsWith(matrix.db-image, 'postgres')
119 - name: Init for MariaDB (update)
121 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
122 mysql -e 'use galette_tests; source tests/mysql_06.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
123 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
125 - name: Update database tests
126 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/GaletteUpdate/
127 if: matrix.coverage != 'xdebug'
129 - name: Init for PostgreSQL
131 POSTGRES_HOST: localhost
134 PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette/install/scripts/pgsql.sql -U galette_tests -h localhost
135 if: startsWith(matrix.db-image, 'postgres')
137 - name: Init for MariaDB
139 mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
140 mysql -e 'use galette_tests; source galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306
141 if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')
144 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php --no-cc -d tests/Galette/
145 if: matrix.coverage != 'xdebug'
147 - name: Unit tests (with coverage)
148 run: galette/vendor/bin/atoum -mcn 1 -bf tests/TestsBootstrap.php -c tests/clover.php -d tests/Galette/
149 if: matrix.coverage == 'xdebug'
151 - name: Upload code coverage (scrutinizer)
153 wget https://scrutinizer-ci.com/ocular.phar
154 php ocular.phar code-coverage:upload --format=php-clover tests/clover.xml
155 if: matrix.coverage == 'xdebug'
157 - name: Upload code coverage (codecov)
158 uses: codecov/codecov-action@v1
160 file: tests/clover.xml
161 if: matrix.coverage == 'xdebug'