Skip to content

Continuous integration

A reference CI workflow ships at .github/workflows/ci.yml. Copy it into each flyokai/* module's .github/workflows/ and adapt as needed.

What it runs

Step What it does When it fails
composer validate --strict Lints composer.json (well-formed, license, no missing fields) Always — every PR
composer install --prefer-dist Resolves dependencies, generates autoload Every PR
composer run cs-check Coding-style check (only if defined in the module's composer.json) Soft — skipped if absent
composer test PHPUnit (only if defined in the module's composer.json) Soft — exits 0 if absent (until tests are added)

The matrix runs on PHP 8.2 and 8.3 by default — adjust per module.

Adding tests to a module

Add this to the module's composer.json:

{
    "require-dev": {
        "phpunit/phpunit": "^9.6 || ^10.5"
    },
    "scripts": {
        "test":  "phpunit --colors=always",
        "test-coverage": "phpunit --coverage-clover=clover.xml"
    }
}

Add a phpunit.xml.dist:

<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
         colors="true"
         bootstrap="vendor/autoload.php"
         cacheResultFile=".phpunit.cache/test-results"
         executionOrder="depends,defects"
         beStrictAboutOutputDuringTests="true">
    <testsuites>
        <testsuite name="unit">
            <directory>test/</directory>
        </testsuite>
    </testsuites>
</phpunit>

Tests live under test/. Use the namespace Flyokai\<Module>\Test\.

DB-touching tests

For modules that hit MySQL (driver-amp, driver-async, db-schema, search-criteria, indexer, oauth-server, user, application):

services:
  mysql:
    image: mysql:8.0
    env:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: flyokai_test
    ports:
      - 3306:3306
    options: >-
      --health-cmd="mysqladmin ping" --health-interval=10s
      --health-timeout=5s --health-retries=3

Pass connection details to the test bootstrap via env vars (DB_HOST, DB_NAME, DB_USER, DB_PASS).

OpenSearch-touching tests

For flyokai/amp-opensearch:

services:
  opensearch:
    image: opensearchproject/opensearch:2.11.1
    env:
      discovery.type: single-node
      DISABLE_SECURITY_PLUGIN: "true"
    ports:
      - 9200:9200

Badges

Once CI is wired:

[![CI](https://github.com/flyokai/<module>/actions/workflows/ci.yml/badge.svg)](https://github.com/flyokai/<module>/actions/workflows/ci.yml)

Drop this at the top of the module's README.md, just under the # title.

Coverage

Coverage uploads to Codecov / Coveralls are intentionally not in the reference workflow — the framework predates a coverage strategy. Add per-module if you want it.