.github/workflows/test.yml
name: Build
on:
push:
pull_request:
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php: '8.1'
librdkafka: 'v2.6.0'
publish: true
exclude:
- php: '8.1'
librdkafka: 'v2.6.0'
publish: false
php:
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'
librdkafka:
- 'v2.6.0'
- 'v2.5.3'
- 'v2.4.0'
- 'v2.3.0'
- 'v2.2.0'
- 'v2.1.1'
- 'v2.0.2'
- 'v1.9.2'
- 'v1.8.2'
- 'v1.7.0'
- 'v1.6.2'
- 'v1.5.3'
- 'v1.4.4'
- 'v1.3.0'
- 'v1.2.2'
- 'v1.1.0'
- 'v1.0.1'
- 'master'
publish:
- false
continue-on-error: ${{ matrix.librdkafka == 'master' }}
services:
zookeeper:
image: confluentinc/cp-zookeeper:7.7.1
ports:
- 2181:2181
env:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.7.1
ports:
- 9092:9092
env:
KAFKA_BROKER_ID: 111
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
env:
PHP_VERSION: ${{ matrix.php }}
LIBRDKAFKA_VERSION: ${{ matrix.librdkafka }}
KAFKA_BROKERS: localhost:9092
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache librdkafka ${{ matrix.librdkafka }} build
id: librdkafka-build-cache
uses: actions/cache@v4
with:
path: ~/build-cache/librdkafka
key: ${{ runner.os }}-librdkafka-${{ matrix.librdkafka }}
- name: Build librdkafka ${{ matrix.librdkafka }}
if: ${{ steps.librdkafka-build-cache.outputs.cache-hit != 'true' }}
run: |
git clone --branch "${{ matrix.librdkafka }}" -c advice.detachedHead=false --depth 1 https://github.com/confluentinc/librdkafka.git /tmp/librdkafka; \
cd /tmp/librdkafka
./configure --install-deps
make
mkdir -p ~/build-cache/librdkafka
sudo make install DESTDIR=~/build-cache/librdkafka
- name: Install librdkafka ${{ matrix.librdkafka }}
run: |
sudo rsync -av ~/build-cache/librdkafka/ /
sudo ldconfig
- name: Install PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: ffi, pcntl
ini-values: "${{ matrix.php == '8.3' && 'zend.max_allowed_stack_size=-1' || '' }}"
- name: Install dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--prefer-dist --prefer-stable"
- name: Run tests
run: |
composer test-init
composer test-coverage
- name: Publish code coverage to codeclimate
if: matrix.publish == true && github.event_name == 'push'
uses: paambaati/codeclimate-action@v5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
- name: Prepare docs
if: matrix.publish == true && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
composer prepare-docs
- name: Setup Python
if: matrix.publish == true && github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Setup mkdocs-material
if: matrix.publish == true && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
pip install mkdocs-material mkdocs-awesome-pages-plugin
- name: Generate & publish docs
if: matrix.publish == true && github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
mkdocs gh-deploy --force