idealo/php-rdkafka-ffi

View on GitHub
.github/workflows/test-macos.yml

Summary

Maintainability
Test Coverage
name: Build macOS

on:
  push:
  pull_request:

jobs:
  tests-macos:
    name: Tests
    runs-on: macos-latest
    strategy:
      fail-fast: true
      matrix:
        php:
          - '8.1'
          - '8.2'
          - '8.3'
          - '8.4'
    defaults:
      run:
        shell: bash
    env:
      PHP_VERSION: ${{ matrix.php }}
      KAFKA_BROKERS: localhost:9092
      COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
      GH_TOKEN: ${{ secrets.GH_TOKEN }}
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
      LIBRDKAFKA_LIBRARY_PATH: /opt/homebrew/lib/librdkafka.dylib
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install latest librdkafka & kafka via brew
        shell: bash
        run: |
          brew update
          brew install librdkafka kafka

      - name: Start Kafka
        shell: bash
        run: |
          zookeeper-server-start -daemon /opt/homebrew/etc/kafka/zookeeper.properties;
          kafka-server-start -daemon /opt/homebrew/etc/kafka/server.properties --override broker.id=111 --override advertised.listeners=${{ env.KAFKA_ADVERTISED_LISTENERS }};

      - name: Install PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          coverage: none
          extensions: ffi, pcntl
          ini-values: "${{ (matrix.php == '8.3' || matrix.php == '8.4') && 'zend.max_allowed_stack_size=256k' || '' }}"

      - name: Install dependencies
        uses: ramsey/composer-install@v2
        with:
          composer-options: "--prefer-dist --prefer-stable"

      - name: Run tests
        run: |
          composer test-init
          composer test

      - name: Stop kafka
        run: |
          kafka-server-stop;
          zookeeper-server-stop;