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
4 changes: 4 additions & 0 deletions .docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
localhost {
root * /app/public
php_server
}
38 changes: 38 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG PHP_VERSION=8.3
FROM dunglas/frankenphp:php${PHP_VERSION}

RUN install-php-extensions \
intl \
gd \
mysqli \
pdo_mysql \
zip \
bcmath \
exif \
pcov

RUN echo 'pcov.directory=/module/src' > /usr/local/etc/php/conf.d/99-pcov.ini

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

WORKDIR /app

COPY app/composer.json /app/composer.json

# SilverStripe requires Page and PageController classes in the project.
# Generated here (not stored in the repo) to avoid duplicate-class detection
# when the module is symlinked into vendor/.
RUN mkdir -p /app/src /app/_config \
&& printf '<?php\n\nuse SilverStripe\\CMS\\Model\\SiteTree;\n\nclass Page extends SiteTree\n{\n}\n' > /app/src/Page.php \
&& printf '<?php\n\nuse SilverStripe\\CMS\\Controllers\\ContentController;\n\nclass PageController extends ContentController\n{\n}\n' > /app/src/PageController.php

COPY app/_config/ /app/_config/
COPY app/phpunit.xml.dist /app/phpunit.xml.dist
COPY app/phpstan.neon.dist /app/phpstan.neon.dist
COPY app/rector.php /app/rector.php

COPY Caddyfile /etc/caddy/Caddyfile
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

ENTRYPOINT ["entrypoint.sh"]
Empty file added .docker/app/_config/.gitkeep
Empty file.
59 changes: 59 additions & 0 deletions .docker/app/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"silverstripe/recipe-cms": "^6.0",
"wedevelopnl/silverstripe-menustructure": "*"
},
"repositories": [
{
"type": "path",
"url": "/module",
"options": {
"symlink": true
}
}
],
"autoload": {
"classmap": [
"src/"
]
},
"require-dev": {
"cambis/silverstan": "^2.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-deprecation-rules": "^2.0",
"phpunit/phpunit": "^11.3",
"tomasvotruba/type-coverage": "^2.0",
"wernerkrauss/silverstripe-rector": "^1.0"
},
"autoload-dev": {
"psr-4": {
"WeDevelop\\Menustructure\\Tests\\": "vendor/wedevelopnl/silverstripe-menustructure/tests/"
}
},
"extra": {
"project-files-installed": [
".htaccess",
"app/.htaccess",
"app/_config/mimevalidator.yml",
"app/_config/mysite.yml",
"app/src/Page.php",
"app/src/PageController.php"
],
"public-files-installed": [
".htaccess",
"index.php",
"web.config"
]
},
"config": {
"allow-plugins": {
"composer/installers": true,
"phpstan/extension-installer": true,
"silverstripe/recipe-plugin": true,
"silverstripe/vendor-plugin": true
}
}
}
13 changes: 13 additions & 0 deletions .docker/app/phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parameters:
level: max
phpVersion:
min: 80300
max: 80599
paths:
- /module/src
type_coverage:
return_type: 100
param_type: 100
property_type: 100
constant_type: 100
declare: 100
18 changes: 18 additions & 0 deletions .docker/app/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/silverstripe/framework/tests/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
colors="true"
beStrictAboutTestsThatDoNotTestAnything="true">
<testsuites>
<testsuite name="default">
<directory>vendor/wedevelopnl/silverstripe-menustructure/tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">vendor/wedevelopnl/silverstripe-menustructure/src</directory>
</include>
</coverage>
</phpunit>
33 changes: 33 additions & 0 deletions .docker/app/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

use Netwerkstatt\SilverstripeRector\Set\SilverstripeLevelSetList;
use Netwerkstatt\SilverstripeRector\Set\SilverstripeSetList;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;

return RectorConfig::configure()
->withPaths([
'/module/src',
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
instanceOf: true,
earlyReturn: true,
rectorPreset: true,
)
->withPhpSets(php83: true)
->withSets([
SilverstripeSetList::CODE_STYLE,
SilverstripeLevelSetList::UP_TO_SS_6_0,
])
->withSkip([
ChangeOrIfContinueToMultiContinueRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
PostIncDecToPreIncDecRector::class,
]);
55 changes: 55 additions & 0 deletions .docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
services:
app:
build:
context: .
dockerfile: Dockerfile
args:
PHP_VERSION: ${PHP_VERSION:-8.3}
ports:
- "${WEB_PORT}:443"
volumes:
- ../composer.json:/module/composer.json:ro
- ../src:/module/src
- ../tests:/module/tests
- ../_config:/module/_config:ro
- ../templates:/module/templates:ro
- ../coverage:/app/coverage
- vendor:/app/vendor
healthcheck:
test: test -f /tmp/.app-ready
interval: 3s
start_period: 60s
retries: 20
depends_on:
db:
condition: service_healthy
environment:
SS_DATABASE_SERVER: db
SS_DATABASE_NAME: silverstripe
SS_DATABASE_USERNAME: silverstripe
SS_DATABASE_PASSWORD: silverstripe
SS_DEFAULT_ADMIN_USERNAME: admin
SS_DEFAULT_ADMIN_PASSWORD: admin
SS_ENVIRONMENT_TYPE: dev
SS_PHPUNIT_FLUSH: 1

db:
image: mysql:8
ports:
- "${DB_PORT}:3306"
volumes:
- db-data:/var/lib/mysql
- ./db-init:/docker-entrypoint-initdb.d:ro
environment:
MYSQL_DATABASE: silverstripe
MYSQL_USER: silverstripe
MYSQL_PASSWORD: silverstripe
MYSQL_ROOT_PASSWORD: root
healthcheck:
test: mysqladmin ping -h localhost
interval: 5s
retries: 10

volumes:
vendor:
db-data:
4 changes: 4 additions & 0 deletions .docker/db-init/grant-test-privileges.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Grant CREATE/DROP DATABASE privileges for SilverStripe's test framework
-- which creates temporary databases matching ss_tmpdb_*
GRANT ALL PRIVILEGES ON *.* TO 'silverstripe'@'%';
FLUSH PRIVILEGES;
26 changes: 26 additions & 0 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -e

composer install --no-interaction

# FrankenPHP ships a default phpinfo() index.php. Replace it with the proper
# SilverStripe bootstrap after composer install makes the recipe available.
cp -f vendor/silverstripe/recipe-core/public/index.php /app/public/index.php

# Ensure all vendor package resources are exposed. composer install skips the
# vendor-expose step when the named Docker volume already has packages from a
# previous run (nothing new to install → no post-install event fires).
composer vendor-expose

# vendor-plugin uses realpath() to resolve library paths, which follows the
# symlink from vendor/wedevelopnl/silverstripe-menustructure → /module.
# Because /module is outside /app, getRelativePath() produces a broken path
# and the exposed resources are never created. Create them manually.
_res=/app/public/_resources/vendor/wedevelopnl/silverstripe-menustructure
mkdir -p "$_res"

vendor/bin/sake dev/build flush=1

touch /tmp/.app-ready

exec frankenphp run --config /etc/caddy/Caddyfile
23 changes: 23 additions & 0 deletions .docker/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
WORKTREE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
DIR_NAME="$(basename "$WORKTREE_DIR")"

HASH=$(printf '%s' "$DIR_NAME" | cksum | awk '{print $1}')
OFFSET=$((HASH % 1000))

WEB_PORT=$((8000 + OFFSET))
DB_PORT=$((13000 + OFFSET))

cat > "$SCRIPT_DIR/.env" <<EOF
COMPOSE_PROJECT_NAME=${DIR_NAME}
WEB_PORT=${WEB_PORT}
DB_PORT=${DB_PORT}
EOF

echo "Generated .docker/.env:"
echo " COMPOSE_PROJECT_NAME=${DIR_NAME}"
echo " WEB_PORT=${WEB_PORT}"
echo " DB_PORT=${DB_PORT}"
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Build artefacts that should never enter the image
vendor/
node_modules/
coverage/

# VCS / docs / CI — never needed in the image
.git/
.github/
docs/

# Editor / OS clutter
.vscode/
.idea/
.DS_Store

# php-cs-fixer cache / phpunit cache
.php-cs-fixer.cache
.phpunit.cache/
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exclude development files from Packagist distributions
/.claude export-ignore
/.docker export-ignore
/.dockerignore export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.vscode export-ignore
/CLAUDE.md export-ignore
/docs export-ignore
/Makefile export-ignore
/tests export-ignore
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

updates:
- package-ecosystem: composer
directory: /
schedule:
interval: daily

- package-ecosystem: docker
directory: /.docker
schedule:
interval: weekly

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: ['6']
pull_request:
branches: ['6']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
static-analysis:
name: Static analysis
runs-on: ubuntu-latest
env:
COMPOSE: docker compose -f .docker/compose.yml
steps:
- uses: actions/checkout@v6
- run: make .docker/.env
- run: $COMPOSE up -d --build --wait app
name: Start services
- run: make analyse
- run: make rector-dry

phpunit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-latest
permissions:
checks: write
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4', '8.5']
env:
PHP_VERSION: ${{ matrix.php }}
COMPOSE: docker compose -f .docker/compose.yml
steps:
- uses: actions/checkout@v6
- run: make .docker/.env
- run: $COMPOSE up -d --build --wait
name: Start services
- run: mkdir -p reports
- run: >-
$COMPOSE exec app vendor/bin/phpunit
--log-junit /app/coverage/phpunit-junit.xml
name: Run PHPUnit
- run: cp coverage/phpunit-junit.xml reports/phpunit-junit.xml
if: always()
- uses: dorny/test-reporter@v3
if: always()
with:
name: PHPUnit Results (PHP ${{ matrix.php }})
path: reports/phpunit-junit.xml
reporter: java-junit
Loading