Skip to content

Commit

Permalink
[Kafka Messenger] Update CI, update dependencies, Upgrade to PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalzombie committed Aug 20, 2022
1 parent d5230da commit 485cffa
Show file tree
Hide file tree
Showing 43 changed files with 535 additions and 457 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .docker/docker-compose.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .docker/php/8.1/Dockerfile

This file was deleted.

43 changes: 43 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM php:8.1-fpm-alpine

ENV COMPOSER_ALLOW_SUPERUSER=1
ENV PATH=$HOME/.composer/vendor/bin:$PATH

# Download script to install PHP extensions and dependencies
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod uga+x /usr/local/bin/install-php-extensions && sync

# install system utilities
RUN apk add --no-cache \
curl \
nano \
git \
zip unzip

# Install dev libraries
RUN apk add --no-cache \
icu-dev \
libpq-dev \
libxml2-dev \
librdkafka-dev \
unixodbc-dev

# Install PHP
RUN install-php-extensions \
bz2 \
pcntl \
intl \
zip \
sockets \
xdebug-stable \
rdkafka-stable \
@composer

# Configure PHP
COPY conf/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
COPY conf/php.development.ini /usr/local/etc/php/php.ini

WORKDIR /var/www/html

CMD sleep infinity
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

144 changes: 80 additions & 64 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
name: CI

on:
push:
branches: [ main ]

pull_request:
branches: [ main ]

page_build:
release:
types: [ published, created, edited ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
php:
- "8.0"
- "8.1"
- "8.1"
include:
- php-version: "8.0"
composer-options: "--ignore-platform-reqs"

- php-version: "8.1"
composer-options: "--ignore-platform-reqs"
- php-version: "8.1"
composer-options: "--ignore-platform-reqs"

services:
kafka:
Expand All @@ -41,56 +35,78 @@ jobs:
- 8082:8082
- 8083:8083
- 2181:2181

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install rdkafka
run: sudo add-apt-repository universe && sudo apt update && sudo apt install netcat librdkafka1 librdkafka-dev

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: mbstring, intl, rdkafka
coverage: xdebug
tools: pecl, phpunit, composer
ini-values: post_max_size=256M
env:
runner: kafka-messenger
MESSENGER_KAFKA_DSN: 'kafka://0.0.0.0:9092'
MESSENGER_KAFKA_DEBUG: false

- name: Check Kafka Extension
run: php -v && php --ri rdkafka

- name: Setup Composer
uses: ramsey/composer-install@v1
with:
composer-options: "${{ matrix.composer-options }}"

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install

- name: Wait for Kafka
run: .github/workflows/wait-for-kafka.sh

- name: Unit Tests
run: ./vendor/bin/phpunit --colors=always --verbose --configuration phpunit.xml.dist --log-junit var/tests/.phpunit.output.xml
env:
MESSENGER_KAFKA_DSN: 'kafka://0.0.0.0:9092'
MESSENGER_KAFKA_DEBUG: false
- name: Checkout
uses: actions/checkout@v2

- name: Install rdkafka
run: sudo add-apt-repository universe && sudo apt update && sudo apt install netcat librdkafka1 librdkafka-dev

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
extensions: mbstring, intl, rdkafka
coverage: xdebug
tools: pecl, phpunit, composer
ini-values: post_max_size=256M
env:
MESSENGER_KAFKA_DSN: ${{ secrets.MESSENGER_KAFKA_DSN }}
MESSENGER_KAFKA_DEBUG: ${{ secrets.MESSENGER_KAFKA_DEBUG }}

- name: Check Kafka Extension
run: php -v && php --ri rdkafka

- name: Setup Composer
uses: ramsey/composer-install@v1
with:
composer-options: "${{ matrix.composer-options }}"

- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer update --prefer-dist --no-progress

- name: Setup tests directories
run: mkdir -p build/logs

- name: Wait for Kafka
run: .github/workflows/wait-for-kafka.sh -s localhost -p 2181

- name: Unit Tests
run: ./vendor/bin/phpunit --colors=always --configuration phpunit.xml.dist
env:
MESSENGER_KAFKA_DSN: ${{ secrets.MESSENGER_KAFKA_DSN }}
MESSENGER_KAFKA_DEBUG: ${{ secrets.MESSENGER_KAFKA_DEBUG }}

- name: Push to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: php-${{ matrix.php-versions }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls -v
finish:
needs: [ build ]
runs-on: ubuntu-18.04

steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
13 changes: 8 additions & 5 deletions .github/workflows/wait-for-kafka.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#! /bin/bash
end=$((SECONDS+60))
END=$((SECONDS+60))
SLEEP_TIME_BEFORE_RECONNECT=5

while [ $SECONDS -lt $end ]; do
while [ $SECONDS -lt $END ]; do
if echo dump | nc localhost 2181 | grep broker ; then
exit 0
else
echo "Kafka didn't start in time"
echo "$(date) - Trying connect to kafka:2181"
fi
sleep 1
done
sleep $SLEEP_TIME_BEFORE_RECONNECT
done

echo "$(date) - Connection to kafka:2181 established"
10 changes: 4 additions & 6 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$finder = PhpCsFixer\Finder::create()
->exclude('var')
->exclude('vendor')
->exclude('Documentation')
->notPath('#Enum#')
->in(__DIR__)
;
Expand All @@ -16,17 +17,14 @@
'@Symfony:risky' => true,
'@PhpCsFixer' => true,
'@PHP80Migration' => true,
'@PHP81Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'],
'date_time_immutable' => true,
'single_line_throw' => true,
'native_constant_invocation' => false,
'phpdoc_align' => ['align' => 'left'],
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'php_unit_test_case_static_method_calls' => false,
'php_unit_test_class_requires_covers' => false,
'phpdoc_line_span' => ['const' => 'single', 'property' => 'single', 'method' => 'single'],
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'php_unit_internal_class' => false,
];

return (new PhpCsFixer\Config())
Expand Down
26 changes: 6 additions & 20 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,16 @@ build:
analysis:
tests:
override:
- php-scrutinizer-run

coverage:
tests:
override:
- command: php -n -dzend_extension=xdebug -dxdebug.mode=coverage vendor/bin/phpunit --colors=always --verbose --configuration phpunit.xml.dist --log-junit var/tests/.phpunit.output.xml --coverage-clover var/tests/coverage/coverage.xml
coverage:
file: var/tests/coverage/coverage.xml
format: clover

dependencies:
before:
- sudo apt-get install -y librdkafka1 librdkafka-dev

- php-scrutinizer-run

environment:
php:
version: 8.0.13
pecl_extensions:
- rdkafka
- xdebug
php: 8.1.9

filter:
excluded_paths:
- "Resources/*"
- "Tests/*"
- "var/*"
- "Resources/*"
- "build/*"
dependency_paths:
- "vendor/*"
Loading

0 comments on commit 485cffa

Please sign in to comment.