Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .docker/php.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM php:8.4-cli-alpine

# Composer: copied from the official multi-arch image instead of curl-
# piped install. Reproducible across rebuilds and gets composer 2.x
# without an interactive installer. Both Makefile entry points
# (`make test` and `make test/mutation`) shell out to `composer
# install`, so this needs to be in PATH.
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer

RUN apk add --update --no-cache linux-headers
RUN apk add --no-cache \
php84-dev \
build-base \
git \
unzip

# Both coverage drivers are installed. Xdebug runs as the dev-time
# debugger; PCOV is used exclusively for Infection's coverage pass
# (orders of magnitude less memory than Xdebug, which avoids the
# host OOM-killer firing during the initial test run on tight
# containers). Infection auto-detects PCOV when it's loaded and
# Xdebug is disabled via XDEBUG_MODE=off; the mutation Makefile
# target does both.
RUN pecl install \
xdebug \
pcov \
&& docker-php-ext-enable \
xdebug \
pcov
103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI

# Run the full test suite (unit + mutation) on every PR targeting main and
# whenever those changes land on main (e.g. a PR merge).
on:
pull_request:
push:
branches: [main]

# Cancel superseded runs on the same ref (e.g. new pushes to an open PR).
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
tests:
name: Unit + Mutation (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4']

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov # Infection's coverage driver (PCOV; Xdebug off)
tools: composer:v2
ini-values: memory_limit=-1

- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ~/.cache/composer/files
key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('composer.json') }}
restore-keys: composer-${{ runner.os }}-php${{ matrix.php }}-

# `make test` / `make test/mutation` each run `composer install` first, so the
# Makefile stays the single source of truth for how the suite runs locally and in CI.
- name: Unit tests (PHPUnit)
run: make test

- name: Mutation tests (Infection, min-msi=100)
run: make test/mutation

demo:
name: Demo app (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.4']

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
ini-values: memory_limit=-1

- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ~/.cache/composer/files
key: composer-demo-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('demo/composer.json') }}
restore-keys: composer-demo-${{ runner.os }}-php${{ matrix.php }}-

# The demo consumes the bundle from the checkout via a Composer path repository.
- name: Install demo dependencies
working-directory: demo
run: composer install --prefer-dist --no-interaction --no-progress

# app:find exercises the opt-in DI path: an .xphp command autowiring a
# CachedFinder<User> specialization (compiled at container build).
- name: Run app:find (generic service via DI)
working-directory: demo
run: |
php bin/console app:find | tee find.out
grep -q "Ada" find.out
grep -q "Autowired" find.out
grep -q "cache-aside" find.out

# app:demo exercises the value-type path: a generic Box<Plastic> monomorphized
# and called from compiled code.
- name: Run app:demo (value-type generic)
working-directory: demo
run: |
php bin/console app:demo | tee demo.out
grep -q "blue" demo.out
grep -q "monomorphized" demo.out
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/docker-compose.override.yml
/app

/vendor/
/composer.lock
/var/
/.phpunit.cache/
/.phpunit.result.cache
/phpunit.xml
/infection.log
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.PHONY: install test test/mutation

install:
composer install --no-interaction --prefer-dist

test: install
XDEBUG_MODE=coverage vendor/bin/phpunit

test/mutation: install
XDEBUG_MODE=off vendor/bin/infection --threads=max --min-msi=100 --min-covered-msi=100
Loading
Loading