Skip to content

Commit 0558bd4

Browse files
Merge pull request #1 from xphp-lang/feat/symfony-bundle-and-demo
MVP: write generics, compile, and deploy
2 parents a30e160 + 762d679 commit 0558bd4

42 files changed

Lines changed: 2453 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.docker/php.Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM php:8.4-cli-alpine
2+
3+
# Composer: copied from the official multi-arch image instead of curl-
4+
# piped install. Reproducible across rebuilds and gets composer 2.x
5+
# without an interactive installer. Both Makefile entry points
6+
# (`make test` and `make test/mutation`) shell out to `composer
7+
# install`, so this needs to be in PATH.
8+
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
9+
10+
RUN apk add --update --no-cache linux-headers
11+
RUN apk add --no-cache \
12+
php84-dev \
13+
build-base \
14+
git \
15+
unzip
16+
17+
# Both coverage drivers are installed. Xdebug runs as the dev-time
18+
# debugger; PCOV is used exclusively for Infection's coverage pass
19+
# (orders of magnitude less memory than Xdebug, which avoids the
20+
# host OOM-killer firing during the initial test run on tight
21+
# containers). Infection auto-detects PCOV when it's loaded and
22+
# Xdebug is disabled via XDEBUG_MODE=off; the mutation Makefile
23+
# target does both.
24+
RUN pecl install \
25+
xdebug \
26+
pcov \
27+
&& docker-php-ext-enable \
28+
xdebug \
29+
pcov

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
# Run the full test suite (unit + mutation) on every PR targeting main and
4+
# whenever those changes land on main (e.g. a PR merge).
5+
on:
6+
pull_request:
7+
push:
8+
branches: [main]
9+
10+
# Cancel superseded runs on the same ref (e.g. new pushes to an open PR).
11+
concurrency:
12+
group: ci-${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
tests:
20+
name: Unit + Mutation (PHP ${{ matrix.php }})
21+
runs-on: ubuntu-latest
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
php: ['8.4']
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
coverage: pcov # Infection's coverage driver (PCOV; Xdebug off)
36+
tools: composer:v2
37+
ini-values: memory_limit=-1
38+
39+
- name: Cache Composer packages
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cache/composer/files
43+
key: composer-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('composer.json') }}
44+
restore-keys: composer-${{ runner.os }}-php${{ matrix.php }}-
45+
46+
# `make test` / `make test/mutation` each run `composer install` first, so the
47+
# Makefile stays the single source of truth for how the suite runs locally and in CI.
48+
- name: Unit tests (PHPUnit)
49+
run: make test
50+
51+
- name: Mutation tests (Infection, min-msi=100)
52+
run: make test/mutation
53+
54+
demo:
55+
name: Demo app (PHP ${{ matrix.php }})
56+
runs-on: ubuntu-latest
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
php: ['8.4']
61+
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Setup PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: ${{ matrix.php }}
70+
coverage: none
71+
tools: composer:v2
72+
ini-values: memory_limit=-1
73+
74+
- name: Cache Composer packages
75+
uses: actions/cache@v4
76+
with:
77+
path: ~/.cache/composer/files
78+
key: composer-demo-${{ runner.os }}-php${{ matrix.php }}-${{ hashFiles('demo/composer.json') }}
79+
restore-keys: composer-demo-${{ runner.os }}-php${{ matrix.php }}-
80+
81+
# The demo consumes the bundle from the checkout via a Composer path repository.
82+
- name: Install demo dependencies
83+
working-directory: demo
84+
run: composer install --prefer-dist --no-interaction --no-progress
85+
86+
# app:find exercises the opt-in DI path: an .xphp command autowiring a
87+
# CachedFinder<User> specialization (compiled at container build).
88+
- name: Run app:find (generic service via DI)
89+
working-directory: demo
90+
run: |
91+
php bin/console app:find | tee find.out
92+
grep -q "Ada" find.out
93+
grep -q "Autowired" find.out
94+
grep -q "cache-aside" find.out
95+
96+
# app:demo exercises the value-type path: a generic Box<Plastic> monomorphized
97+
# and called from compiled code.
98+
- name: Run app:demo (value-type generic)
99+
working-directory: demo
100+
run: |
101+
php bin/console app:demo | tee demo.out
102+
grep -q "blue" demo.out
103+
grep -q "monomorphized" demo.out

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/docker-compose.override.yml
2+
/app
3+
4+
/vendor/
5+
/composer.lock
6+
/var/
7+
/.phpunit.cache/
8+
/.phpunit.result.cache
9+
/phpunit.xml
10+
/infection.log

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: install test test/mutation
2+
3+
install:
4+
composer install --no-interaction --prefer-dist
5+
6+
test: install
7+
XDEBUG_MODE=coverage vendor/bin/phpunit
8+
9+
test/mutation: install
10+
XDEBUG_MODE=off vendor/bin/infection --threads=max --min-msi=100 --min-covered-msi=100

0 commit comments

Comments
 (0)