|
11 | 11 | pull_request:
|
12 | 12 |
|
13 | 13 | jobs:
|
14 |
| - ubuntu-latest: |
| 14 | + lint: |
15 | 15 | runs-on: ubuntu-latest
|
16 | 16 |
|
17 | 17 | strategy:
|
@@ -86,3 +86,128 @@ jobs:
|
86 | 86 | run: |
|
87 | 87 | cd galette-core/galette/plugins/plugin-auto
|
88 | 88 | ../../vendor/bin/docheader --docheader=../../../.docheader check lib ./*.php
|
| 89 | +
|
| 90 | + unit-tests: |
| 91 | + runs-on: ubuntu-latest |
| 92 | + |
| 93 | + strategy: |
| 94 | + matrix: |
| 95 | + include: |
| 96 | + #always tests higher stable php version with lower db version |
| 97 | + #enable coverage on higher stable php version with higher postrgesql version |
| 98 | + #lower php version |
| 99 | + - { php-version: "8.1", db-image: "mysql:5.7", coverage: none, always: false } |
| 100 | + - { php-version: "8.1", db-image: "mysql:8.1", coverage: none, always: false } |
| 101 | + - { php-version: "8.1", db-image: "mariadb:10.4", coverage: none, always: false } |
| 102 | + - { php-version: "8.1", db-image: "mariadb:11", coverage: none, always: false } |
| 103 | + - { php-version: "8.1", db-image: "postgres:11", coverage: none, always: false } |
| 104 | + - { php-version: "8.1", db-image: "postgres:16", coverage: none, always: false } |
| 105 | + #higher stable php version |
| 106 | + - { php-version: "8.3", db-image: "mysql:5.7", coverage: none, always: true } |
| 107 | + - { php-version: "8.3", db-image: "mysql:8.1", coverage: none, always: false } |
| 108 | + - { php-version: "8.3", db-image: "mariadb:10.4", coverage: none, always: true } |
| 109 | + - { php-version: "8.3", db-image: "mariadb:11", coverage: none, always: false } |
| 110 | + - { php-version: "8.3", db-image: "postgres:11", coverage: none, always: true } |
| 111 | + - { php-version: "8.3", db-image: "postgres:16", coverage: none, always: true } |
| 112 | + fail-fast: false |
| 113 | + |
| 114 | + env: |
| 115 | + skip: ${{ matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette-auto' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags'))) }} |
| 116 | + DB: ${{ matrix.db-image }} |
| 117 | + |
| 118 | + services: |
| 119 | + # Label used to access the service container |
| 120 | + db: |
| 121 | + # Docker Hub image |
| 122 | + image: ${{ matrix.db-image }} |
| 123 | + # Provide env variables for both mysql and pgsql |
| 124 | + env: |
| 125 | + POSTGRES_USER: galette_tests |
| 126 | + POSTGRES_PASSWORD: g@l3tte |
| 127 | + POSTGRES_DB: galette_tests |
| 128 | + MYSQL_USER: galette_tests |
| 129 | + MYSQL_PASSWORD: g@l3tte |
| 130 | + MYSQL_ROOT_PASSWORD: g@l3tte |
| 131 | + MYSQL_DATABASE: galette_tests |
| 132 | + # Open network ports for both mysql and pgsql |
| 133 | + ports: |
| 134 | + - 3306:3306 |
| 135 | + - 5432:5432 |
| 136 | + # Set health checks to wait until postgres has started |
| 137 | + options: >- |
| 138 | + --health-cmd="bash -c 'if [[ -n $(command -v pg_isready) ]]; then pg_isready; else if [[ -n $(command -v mysqladmin) ]]; then mysqladmin ping; else mariadb-admin ping; fi fi'" |
| 139 | + --health-interval=10s |
| 140 | + --health-timeout=5s |
| 141 | + --health-retries=10 |
| 142 | +
|
| 143 | + name: PHP ${{ matrix.php-version }} ${{ matrix.db-image }} ${{ (matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/galette' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')))) && ' (skipped)' || matrix.coverage == 'xdebug' && ' (with coverage)' || ''}} |
| 144 | + |
| 145 | + steps: |
| 146 | + - name: PHP |
| 147 | + if: env.skip != 'true' |
| 148 | + uses: shivammathur/setup-php@v2 |
| 149 | + with: |
| 150 | + php-version: ${{ matrix.php-versions }} |
| 151 | + tools: composer, pecl |
| 152 | + coverage: ${{ matrix.coverage }} |
| 153 | + extensions: apcu |
| 154 | + ini-values: apc.enable_cli=1 |
| 155 | + |
| 156 | + - name: "Show versions" |
| 157 | + if: env.skip != 'true' |
| 158 | + run: | |
| 159 | + php --version |
| 160 | + composer --version |
| 161 | + echo "node $(node --version)" |
| 162 | + echo "npm $(npm --version)" |
| 163 | + docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi" |
| 164 | +
|
| 165 | + - name: Checkout Galette core |
| 166 | + if: env.skip != 'true' |
| 167 | + uses: actions/checkout@v4 |
| 168 | + with: |
| 169 | + repository: galette/galette |
| 170 | + path: galette-core |
| 171 | + fetch-depth: 1 |
| 172 | + ref: develop |
| 173 | + |
| 174 | + - name: Checkout plugin |
| 175 | + uses: actions/checkout@v4 |
| 176 | + with: |
| 177 | + path: galette-core/galette/plugins/plugin-auto |
| 178 | + |
| 179 | + - name: "Restore dependencies cache" |
| 180 | + if: env.skip != 'true' |
| 181 | + uses: actions/cache@v4 |
| 182 | + with: |
| 183 | + path: | |
| 184 | + ~/.composer/cache/ |
| 185 | + ~/.npm/_cacache/ |
| 186 | + key: "${{ runner.os }}-galette-${{ matrix.php-version }}-${{ hashFiles('galette/composer.lock', 'package-lock.json') }}" |
| 187 | + restore-keys: | |
| 188 | + ${{ runner.os }}-galette-${{ matrix.php-version }}- |
| 189 | +
|
| 190 | + - name: Install dependencies |
| 191 | + if: env.skip != 'true' |
| 192 | + run: | |
| 193 | + cd galette-core |
| 194 | + bin/install_deps |
| 195 | +
|
| 196 | + - name: Init for PostgreSQL |
| 197 | + env: |
| 198 | + POSTGRES_HOST: localhost |
| 199 | + POSTGRES_PORT: 5432 |
| 200 | + run: | |
| 201 | + PGPASSWORD=g@l3tte psql -d galette_tests -a -f galette-core/galette/install/scripts/pgsql.sql -U galette_tests -h localhost |
| 202 | + if: env.skip != 'true' && startsWith(matrix.db-image, 'postgres') |
| 203 | + |
| 204 | + - name: Init for MariaDB |
| 205 | + run: | |
| 206 | + mysql -e 'create database IF NOT EXISTS galette_tests;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306 |
| 207 | + mysql -e 'use galette_tests; source galette/-core/galette/install/scripts/mysql.sql;' -u galette_tests --password=g@l3tte -h 127.0.0.1 -P 3306 |
| 208 | + if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')) |
| 209 | + |
| 210 | + - name: Unit tests |
| 211 | + run: | |
| 212 | + cd galette-core/galette/plugins/plugin-auto |
| 213 | + ../../vendor/bin/phpunit --test-suffix=.php --bootstrap tests/TestsBootstrap.php --no-coverage --process-isolation tests/GaletteAuto/ |
0 commit comments