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
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Keep development-only files out of dist installs (Packagist zips). CI and local module work must
# therefore install this module as a PATH repository with symlink: true, or a real checkout -
# a dist install contains no tests at all.
/tests export-ignore
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.editorconfig export-ignore
/phpunit.xml.dist export-ignore
214 changes: 214 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: CI

on:
push:
# master is the repository's current default branch; main is listed too so CI keeps running
# unchanged once the default branch is renamed to the portfolio convention.
branches: [master, main]
pull_request:
workflow_dispatch:

jobs:
test:
name: SS${{ matrix.silverstripe }} / PHP ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
include:
# One job per supported Silverstripe major, at the oldest and newest PHP that major is
# used with here. The module's composer.json is the source of truth for the supported
# range; this matrix must follow it.
- silverstripe: '5'
php: '8.1'
recipe: '^5'
testing: '^3'
- silverstripe: '5'
php: '8.3'
recipe: '^5'
testing: '^3'
- silverstripe: '6'
php: '8.3'
recipe: '^6'
testing: '^4'
- silverstripe: '6'
php: '8.4'
recipe: '^6'
testing: '^4'

services:
database:
# MariaDB rather than MySQL: it matches both the local dev machines and the Forge
# servers, so a version-specific failure here means something real.
image: mariadb:11.4
env:
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: ss_ci
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s --health-timeout=5s --health-retries=10

steps:
- name: Check out the module
uses: actions/checkout@v4
with:
path: module

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, pdo_mysql, mysqli, gd, zip, dom, xml, tokenizer, simplexml, ctype, hash, session
tools: composer:v2
coverage: none

- name: Build a host project
# The module cannot be tested on its own: it needs a booted Silverstripe app. The host
# composer.json is written by hand; recipe-cms brings in the admin (whose LeftAndMain
# loads the module's script and stylesheet) and the CMS (whose page edit form the suite
# renders the fields in).
#
# The module is pulled in through a PATH repository pointing at the checkout, symlinked
# rather than mirrored: /tests is export-ignore in .gitattributes, so a mirrored
# (dist-style) install would contain no tests at all and the suite would silently pass
# with nothing in it.
run: |
mkdir -p app-host
cd app-host
cat > composer.json <<JSON
{
"name": "restruct/ci-host",
"require": {
"silverstripe/recipe-cms": "${{ matrix.recipe }}",
"silverstripe/recipe-testing": "${{ matrix.testing }}",
"restruct/silverstripe-inline-infofield": "*"
},
"repositories": [
{ "type": "path", "url": "../module", "options": { "symlink": true } }
],
"autoload-dev": {
"psr-4": {
"Restruct\\\\InfoField\\\\Tests\\\\": "vendor/restruct/silverstripe-inline-infofield/tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": { "allow-plugins": true }
}
JSON
# Silverstripe 5 is in security-fixes-only until its April 2027 EOL, and every release of
# silverstripe/cms 5 is covered by advisory PKSA-pjvm-vnw2-n3m2 (range <6.2.1), which will
# not be patched there. Composer therefore refuses to install it under the default policy.
# Blocking is disabled HERE ONLY, in a throwaway CI host project.
composer config policy.advisories.block false
composer update --no-interaction --no-progress

- name: Configure the test suite
# The module's own phpunit.xml.dist is the single copy of the runner settings (bootstrap,
# failOnWarning pinned because warning-to-error escalation differs between PHPUnit 9 on
# SS5 and 11 on SS6). CI copies it and appends only the consumer suite, so a settings
# change cannot drift between the two.
run: |
cd app-host
cp ../module/phpunit.xml.dist phpunit.xml
perl -0pi -e 's#(\s*)</testsuites>#$1 <testsuite name="consumer">$1 <directory>app/tests</directory>$1 </testsuite>$1</testsuites>#' phpunit.xml
grep -q '<testsuite name="consumer">' phpunit.xml
cat phpunit.xml

- name: Add a consumer-shape database test
# A module's own suite cannot catch a test fixture that breaks CONSUMING projects: its
# fixtures are loaded by PHPUnit, not registered in the class manifest. This test runs as
# the consumer would, with the module's tests/ in the manifest, and must still build the
# temp database.
run: |
mkdir -p app-host/app/tests
cat > app-host/app/tests/ConsumerDbTest.php <<'PHP'
<?php

use SilverStripe\Dev\SapphireTest;
use SilverStripe\Security\Member;

class ConsumerDbTest extends SapphireTest
{
protected $usesDatabase = true;

public function testTempDatabaseBuilds()
{
$m = Member::create(['FirstName' => 'x']);
$m->write();
$this->assertGreaterThan(0, $m->ID);
}
}
PHP

- name: Run tests
working-directory: app-host
env:
SS_DATABASE_CLASS: MySQLDatabase
SS_DATABASE_SERVER: 127.0.0.1
SS_DATABASE_PORT: 3306
SS_DATABASE_USERNAME: root
SS_DATABASE_PASSWORD: root
SS_DATABASE_NAME: ss_ci
SS_ENVIRONMENT_TYPE: dev
# PHPUnit 11 (SS6) ignores a `flush=1` argument, so the manifest is flushed through
# this instead. It is read only by framework 6: on framework 5 it does nothing and does
# NOT flush, so the SS5 legs flush with a path-first `flush=1` argument below.
SS_PHPUNIT_FLUSH: 1
# Flush on every run, or a stale test manifest reads as a broken test. On SS5 the flush
# must be a `flush=1` argument AFTER a path: `--testsuite <name> flush=1` silently does
# not flush, so the suites are addressed by their directories there.
#
# Every suite runs with --fail-on-empty-test-suite (PHPUnit 9.6 on SS5 accepts it too, it is
# only missing from its --help), so a suite that silently ran nothing (a file the manifest
# no longer finds, a broken consumer-test heredoc) fails instead of ending green.
# Not a grep for "OK (N tests": PHPUnit exits 0 with "OK, but there were issues!" or
# "OK, but some tests were skipped!", so such a count guard turns a passing suite red on
# the first upstream deprecation notice.
run: |
if [ "${{ matrix.silverstripe }}" = "6" ]; then
vendor/bin/phpunit --fail-on-empty-test-suite --testsuite infofield
vendor/bin/phpunit --fail-on-empty-test-suite --testsuite consumer
else
vendor/bin/phpunit --fail-on-empty-test-suite vendor/restruct/silverstripe-inline-infofield/tests flush=1
vendor/bin/phpunit --fail-on-empty-test-suite app/tests flush=1
fi

- name: Boot the app and build the database
# The suite proves the classes behave; this proves the module does not break a real boot
# or a flush (where an unguarded optional dependency would fatal).
working-directory: app-host
env:
SS_DATABASE_CLASS: MySQLDatabase
SS_DATABASE_SERVER: 127.0.0.1
SS_DATABASE_PORT: 3306
SS_DATABASE_USERNAME: root
SS_DATABASE_PASSWORD: root
SS_DATABASE_NAME: ss_ci
SS_ENVIRONMENT_TYPE: dev
run: |
if [ "${{ matrix.silverstripe }}" = "6" ]; then
vendor/bin/sake db:build --flush
else
vendor/bin/sake dev/build flush=1
fi

lint:
name: Lint PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# The floor and the ceiling of the module's declared php constraint.
php: ['8.1', '8.4']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Syntax check every PHP file
run: find src tests -name '*.php' -print0 | xargs -0 -n1 php -l
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Changelog

## 3.0.0 (2026-09-25)

Silverstripe 5 and 6. Silverstripe 4 is dropped, which is why this is a major release. See
[UPGRADING.md](UPGRADING.md).

### Breaking

- **Silverstripe 4 is no longer supported.** `silverstripe/framework` is now `^5 || ^6` (was
`^4.4`), `silverstripe/vendor-plugin` `^2 || ^3` (was `^1.0`), and PHP `^8.1` (was not declared).
Silverstripe 4 projects keep resolving the `2.x` tags.
- **`silverstripe/admin` (`^2 || ^3`) is now required.** The module's config targets `LeftAndMain`
and both fields exist for CMS forms; it was used but not declared. A framework-only project
now pulls in the admin.
- **`InfoField` now boxes object content too.** Content passed as an object (for example a
`DBHTMLText` from `DBField::create_field()` or `renderWith()`) used to be output bare, without the
info box; it is now wrapped in the same `div.message.info` as string content. If you relied on
the bare output, use a plain `LiteralField` for that content.

### Fixed

- `InfoField` dropped its info box for object content (see above).
- `InlineInfoField` wrote the target field name into its `data-target` attribute unescaped; it is
now attribute-escaped. The help text itself is still output as HTML, as documented.

### Added

- A behavioural test suite (`tests/`), run in CI against Silverstripe 5 and 6: the markup of both
fields (the contract with the CMS script and stylesheet), the CMS requirements and their
publication, and a real CMS page edit form.
- README: what the module does (the previous text described a different field), requirements,
installation, a version compatibility table, usage of both fields, the assets it loads and where
the inline field works.
- README credits nathancox/silverstripe-helpfield, which `InlineInfoField` is derived from (the
2.0 README credited it; 2.1 dropped the credit).
- `funding` and PSR-4 `autoload` in `composer.json`. Its description and keywords described a
cookie notice and are corrected.

### Licence

- Still no licence declared, as in every `2.x` release: there is no `LICENSE` file and no
`license` key in `composer.json`.

### Issues

- No issues or pull requests were open (or had ever been filed) at the time of this release.

## 2.1.1

- Remove a leftover `console.log` from the CMS script.
- (After the tag, on `master`: `silverstripe/vendor-plugin` added as a requirement.)

## 2.1

- Minor fixes.

## 2.0

- Silverstripe 4 vendor module.
Loading
Loading