Skip to content

Php 8.3 in workflows #181

Php 8.3 in workflows

Php 8.3 in workflows #181

Workflow file for this run

name: 'php'
on:
pull_request:
paths:
- '**/*.php'
- '.github/workflows/php.yml'
- 'composer.json'
push:
paths:
- '**/*.php'
- '.github/workflows/php.yml'
- 'composer.json'
jobs:
cs:
uses: bedita/github-workflows/.github/workflows/php-cs.yml@v2
with:
php_versions: '["8.3"]'
stan:
uses: bedita/github-workflows/.github/workflows/php-stan.yml@v2
with:
php_versions: '["8.3"]'
unit:
name: 'Run unit tests'
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
matrix:
php:
- '8.2'
db:
- '{"vendor": "MySQL 8.0", "pdo": "mysql", "dsn": "mysql://bedita:bedita@127.0.0.1:3306/bedita", "image": "mysql:8.0", "options": "--health-cmd \"mysqladmin ping -h localhost\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
elastic:
- '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- '{"vendor": "OpenSearch 1", "image": "opensearchproject/opensearch:1", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
# Disable HTTPS with "options" because the combination of openssl and curl versions breaks with this image (see https://github.com/php/php-src/issues/8369),
# and setting it in the service's "env" crashes OpenSearch with "unknown configuration" (maybe just ignore it?!)
- '{"vendor": "ElasticSearch 8", "image": "elasticsearch:8.11.0", "dsn": "http://elastic:admin@127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=elasticsearch&auth_type=basic", "options": "--env \"xpack.security.http.ssl.enabled=false\" --health-cmd \"curl --fail --output /dev/null --silent --user elastic:admin http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- '{"vendor": "ElasticSearch 7", "image": "elasticsearch:7.17.14", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=elasticsearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
include:
- php: '8.2'
db: '{"vendor": "SQLite", "pdo": "sqlite", "dsn": "sqlite://tmp/test.sql", "image": "busybox", "options": "--entrypoint \"/bin/yes\" --health-cmd \"/bin/true\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- php: '8.2'
db: '{"vendor": "MySQL 5.7", "pdo": "mysql", "dsn": "mysql://bedita:bedita@127.0.0.1:3306/bedita?realVendor=mysql5.7", "image": "mysql:5.7", "options": "--health-cmd \"mysqladmin ping -h localhost\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- php: '8.2'
db: '{"vendor": "PostgreSQL", "pdo": "pgsql", "dsn": "postgres://bedita:bedita@127.0.0.1:5432/bedita", "image": "postgres:14", "options": "--health-cmd \"pg_isready\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- php: '8.3'
db: '{"vendor": "SQLite", "pdo": "sqlite", "dsn": "sqlite://tmp/test.sql", "image": "busybox", "options": "--entrypoint \"/bin/yes\" --health-cmd \"/bin/true\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- php: '8.3'
db: '{"vendor": "MySQL 5.7", "pdo": "mysql", "dsn": "mysql://bedita:bedita@127.0.0.1:3306/bedita?realVendor=mysql5.7", "image": "mysql:5.7", "options": "--health-cmd \"mysqladmin ping -h localhost\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
- php: '8.3'
db: '{"vendor": "PostgreSQL", "pdo": "pgsql", "dsn": "postgres://bedita:bedita@127.0.0.1:5432/bedita", "image": "postgres:14", "options": "--health-cmd \"pg_isready\" --health-interval 10s --health-timeout 5s --health-retries 5"}'
elastic: '{"vendor": "OpenSearch 2", "image": "opensearchproject/opensearch:2", "dsn": "http://127.0.0.1:9200/?className=Cake\\ElasticSearch\\Datasource\\Connection&driver=opensearch", "options": "--health-cmd \"curl --fail --output /dev/null --silent http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s\" --health-interval 1s --health-timeout 2s --health-retries 5"}'
env:
PHP_VERSION: '${{ matrix.php }}'
DB_VENDOR: '${{ fromJson(matrix.db).vendor }}'
ELASTIC_VERSION: '${{ fromJson(matrix.elastic).vendor }}'
db_dsn: '${{ fromJson(matrix.db).dsn }}'
es_dsn: '${{ fromJson(matrix.elastic).dsn }}'
services:
db:
image: '${{ fromJson(matrix.db).image }}'
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_USER: 'bedita'
MYSQL_PASSWORD: 'bedita'
MYSQL_DATABASE: 'bedita'
POSTGRES_USER: 'bedita'
POSTGRES_PASSWORD: 'bedita'
POSTGRES_DB: 'bedita'
ports:
- '3306:3306'
- '5432:5432'
options: '${{ fromJson(matrix.db).options }}'
elastic:
image: '${{ fromJson(matrix.elastic).image }}'
env:
discovery.type: 'single-node'
# OpenSearch
DISABLE_INSTALL_DEMO_CONFIG: 'true'
DISABLE_SECURITY_PLUGIN: 'true'
# ElasticSearch
ELASTIC_PASSWORD: 'admin'
ports:
- '9200:9200'
- '9300:9300'
options: '${{ fromJson(matrix.elastic).options }}'
steps:
- name: 'Checkout current revision'
uses: 'actions/checkout@v4'
- name: 'Composer config GH token if available'
run: 'if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi'
- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '${{ matrix.php }}'
tools: 'composer:v2'
extensions: 'mbstring, intl, pdo_${{ fromJson(matrix.db).pdo }}'
coverage: 'pcov'
ini-values: 'pcov.directory=., pcov.exclude="~vendor~"'
- name: 'Discover Composer cache directory'
id: 'cachedir'
run: echo "path=$(composer global config cache-dir)" >> $GITHUB_OUTPUT
- name: 'Share Composer cache across runs'
uses: 'actions/cache@v4'
with:
path: '${{ steps.cachedir.outputs.path }}'
key: "composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}"
restore-keys: |
composer-${{ matrix.php }}-
composer-
- name: 'Install dependencies with Composer'
run: 'composer install --prefer-dist --no-interaction'
- name: 'Dump Composer autoloader'
run: 'composer dump-autoload --optimize --no-cache'
- name: 'Run PHPUnit with coverage'
run: 'vendor/bin/phpunit --coverage-clover=${{ matrix.php }}-${{ strategy.job-index }}-clover.xml'
- name: 'Export coverage results'
uses: 'codecov/codecov-action@v4'
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
files: '${{ matrix.php }}-${{ strategy.job-index }}-clover.xml'
env_vars: PHP_VERSION
- name: 'Archive code coverage results'
uses: 'actions/upload-artifact@v4'
with:
name: 'PHP-${{ matrix.php }}-with-${{ fromJson(matrix.db).vendor }}-strategy-job-index-${{ strategy.job-index }}'
path: '${{ matrix.php }}-${{ strategy.job-index }}-clover.xml'