Skip to content

Commit

Permalink
Add support for PHP 8 and rdkafka v5
Browse files Browse the repository at this point in the history
- improve CI
- upgrade deps
- require PHP 7.4 min
  • Loading branch information
simPod committed Jan 23, 2021
1 parent 706497a commit 7186416
Show file tree
Hide file tree
Showing 32 changed files with 350 additions and 355 deletions.
4 changes: 3 additions & 1 deletion .ci/install_rdkafka.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
#!/bin/bash

set -eux

git clone --depth 1 --branch "${LIBRDKAFKA_VERSION}" https://github.com/edenhill/librdkafka.git
(
Expand Down
17 changes: 8 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text eol=lf
/.ci export-ignore
/.github export-ignore
/tests export-ignore
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/infection.json.dist export-ignore
/phpcs.xml.dist export-ignore
/phpstan.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml export-ignore
.gitignore export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/tests export-ignore
201 changes: 50 additions & 151 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,37 @@
name: CI
name: "CI"

on:
pull_request:
push:
branches:
- "master"
schedule:
- cron: "0 17 * * *"
- cron: "42 3 * * *"

env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
LIBRDKAFKA_VERSION: v1.4.2

jobs:
coding-standard:
runs-on: ubuntu-18.04
name: Coding Standard
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"

steps:
- uses: actions/checkout@v2

- name: Install librdkafka
run: |
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: Install PHP
uses: shivammathur/setup-php@2.2.0
with:
php-version: 7.3
coverage: none
tools: pecl
extensions: json, mbstring, rdkafka

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Dependencies
run: composer install ${DEPENDENCIES}

- name: Coding Standard
run: vendor/bin/phpcs

phpstan:
runs-on: ubuntu-18.04
name: PHPStan

steps:
- uses: actions/checkout@v2

- name: Install librdkafka
run: |
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: Install PHP
uses: shivammathur/setup-php@2.2.0
with:
php-version: 7.3
coverage: none
tools: pecl
extensions: json, mbstring, rdkafka

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Dependencies
run: composer install ${DEPENDENCIES}

- name: PHPStan
run: vendor/bin/phpstan analyse

coverage:
runs-on: ubuntu-18.04
name: Code Coverage
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
dependencies:
- "highest"
include:
- dependencies: "lowest"
php-version: "7.4"

steps:
- uses: actions/checkout@v2
- name: "Checkout"
uses: "actions/checkout@v2"
with:
ref: ${{ github.ref }}
fetch-depth: 2

- name: Build the docker-compose stack
run: docker-compose -f tests/docker-compose.yaml up -d
Expand All @@ -104,85 +41,47 @@ jobs:
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: Install PHP
uses: shivammathur/setup-php@2.2.0
with:
php-version: 7.3
coverage: pcov
tools: pecl
extensions: json, mbstring, rdkafka

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v1
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
extensions: "rdkafka"
ini-values: "zend.assertions=1"

- name: Install Dependencies
run: composer install ${DEPENDENCIES}
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: Code coverage
run: |
./vendor/bin/phpunit --coverage-clover /tmp/coverage/clover.xml
- name: "Run PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml"

- name: Report to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_RUN_LOCALLY: 1
run: vendor/bin/php-coveralls --coverage_clover /tmp/coverage/clover.xml --json_path /tmp/coverage/coveralls.json
- name: "Upload coverage file"
uses: "actions/upload-artifact@v2"
with:
name: "phpunit-${{ matrix.deps }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

test_with-php-versions:
runs-on: ubuntu-18.04
strategy:
matrix:
php: [7.3, 7.4]
env: [
'DEPENDENCIES=--prefer-lowest',
'',
]
name: PHP ${{ matrix.php }} Test ${{ matrix.env }}
upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-20.04"
needs:
- "phpunit"

steps:
- uses: actions/checkout@v2

- name: Build the docker-compose stack
run: docker-compose -f tests/docker-compose.yaml up -d

- name: Install librdkafka
run: |
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: Install PHP
uses: shivammathur/setup-php@2.2.0
- name: "Checkout"
uses: "actions/checkout@v2"
with:
php-version: ${{ matrix.php }}
coverage: none
tools: pecl
extensions: json, mbstring, rdkafka

- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
fetch-depth: 2

- name: Cache dependencies
uses: actions/cache@v1
- name: "Download coverage files"
uses: "actions/download-artifact@v2"
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
restore-keys: ${{ runner.os }}-composer-
path: "reports"

- name: Install Dependencies
run: composer install ${DEPENDENCIES}

- name: Run tests
run: |
export $ENV
./vendor/bin/phpunit
env:
ENV: ${{ matrix.env}}
- name: "Upload to Codecov"
uses: "codecov/codecov-action@v1"
with:
directory: reports
38 changes: 38 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Coding Standards"

on:
pull_request:
push:
branches:
- "master"

env:
LIBRDKAFKA_VERSION: v1.4.2

jobs:
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-20.04"

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

- name: Install librdkafka
run: |
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
coverage: "none"
extensions: "rdkafka"
tools: "cs2pr, pecl"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Run PHP_CodeSniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
43 changes: 43 additions & 0 deletions .github/workflows/infection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Infection

on:
pull_request:
push:
branches:
- "master"

env:
LIBRDKAFKA_VERSION: v1.4.2

jobs:
Infection:
runs-on: ubuntu-20.04

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: Build the docker-compose stack
run: docker-compose -f tests/docker-compose.yaml up -d

- name: Install librdkafka
run: |
chmod +x .ci/install_rdkafka.sh
.ci/install_rdkafka.sh
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
coverage: "pcov"
extensions: "rdkafka"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: Run Infection
run: vendor/bin/roave-infection-static-analysis-plugin --min-msi=40 --min-covered-msi=50 --log-verbosity=none -s
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
41 changes: 0 additions & 41 deletions .github/workflows/infection.yml

This file was deleted.

Loading

0 comments on commit 7186416

Please sign in to comment.