Skip to content

Commit 6d67e6e

Browse files
committed
Add backwards-compatibility sub-action wrapping Roave's BC check
Wraps roave/backward-compatibility-check with --format=github-actions so PR violations show up as inline annotations. Inputs: php-version (default 8.2), extensions, from (default origin/<PR base ref>). Wired into the root action with an if: github.event_name == 'pull_request' guard, so root consumers don't break on non-PR triggers. Standalone consumers scope their workflow to pull_request or pass an explicit from ref.
1 parent 78c8c00 commit 6d67e6e

4 files changed

Lines changed: 95 additions & 6 deletions

File tree

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ composer require --dev setono/sylius-plugin
1414

1515
This repository also ships a suite of composite GitHub Actions that implement the Setono Sylius plugin CI pipeline. Each check is its own sub-action, addressable as `setono/sylius-plugin/<name>@<ref>`, so consumers can run each in its own job with its own matrix. There is also a root action `setono/sylius-plugin@<ref>` listed on the GitHub Marketplace that runs all checks sequentially in one job — handy for trying it out, slow for real CI.
1616

17-
Eight actions ship in this repository:
17+
Nine actions ship in this repository:
1818

1919
| Action | Purpose |
2020
|---|---|
21-
| `setono/sylius-plugin@<ref>` | Root action. Runs all seven checks sequentially in one job |
21+
| `setono/sylius-plugin@<ref>` | Root action. Runs all eight checks sequentially in one job |
2222
| `setono/sylius-plugin/coding-standards@<ref>` | composer validate, normalize, check-style, rector dry-run, yaml/twig lint |
2323
| `setono/sylius-plugin/dependency-analysis@<ref>` | composer-dependency-analyser against production deps |
2424
| `setono/sylius-plugin/static-code-analysis@<ref>` | `vendor/bin/phpstan analyse`, with `sylius/sylius` removed first |
2525
| `setono/sylius-plugin/unit-tests@<ref>` | `vendor/bin/phpunit` |
2626
| `setono/sylius-plugin/integration-tests@<ref>` | MySQL + Doctrine schema validation against `tests/Application` |
2727
| `setono/sylius-plugin/mutation-tests@<ref>` | Infection, with optional Stryker Dashboard reporting |
2828
| `setono/sylius-plugin/code-coverage@<ref>` | PHPUnit with pcov, upload to Codecov |
29+
| `setono/sylius-plugin/backwards-compatibility@<ref>` | Roave backward-compatibility-check against the PR base ref |
2930

3031
Pin the floating major (`@v2`) for automatic patch updates, or pin a specific tag (`@2.1.0`) for full reproducibility. Note the asymmetry: exact tags are bare-numeric (composer convention), the floating major uses the `v` prefix (action ecosystem convention).
3132

@@ -212,6 +213,31 @@ jobs:
212213
codecov-token: "${{ secrets.CODECOV_TOKEN }}"
213214
```
214215

216+
#### `backwards-compatibility`
217+
218+
Wraps [Roave's `backward-compatibility-check`](https://github.com/Roave/BackwardCompatibilityCheck). Compares the PR's diff against its base ref and fails on any public-API break. Inline annotations show up directly on the changed lines via `--format=github-actions`.
219+
220+
| Input | Default | Description |
221+
|---|---|---|
222+
| `php-version` | `8.2` | PHP version to install |
223+
| `extensions` | `intl, mbstring` | PHP extensions to install |
224+
| `from` | `origin/${{ github.event.pull_request.base.ref }}` | Git ref to compare against. The default only resolves on `pull_request` triggers — pass an explicit ref for other triggers |
225+
226+
The root action invokes this sub-action only on `pull_request` triggers (gated via `if:`), so it's safe to consume the root from any workflow. When invoking this sub-action standalone, scope the workflow to `on: pull_request` (or pass an explicit `from` ref).
227+
228+
```yaml
229+
name: "Backwards compatibility"
230+
231+
on:
232+
pull_request: ~
233+
234+
jobs:
235+
backwards-compatibility:
236+
runs-on: "ubuntu-latest"
237+
steps:
238+
- uses: "setono/sylius-plugin/backwards-compatibility@v2"
239+
```
240+
215241
### Root action
216242

217243
The root action runs all seven sub-actions sequentially in a single job. **It is roughly five times slower than running the same checks as parallel jobs using the sub-actions**, because each sub-action repeats checkout + PHP setup + composer install. The root exists for the GitHub Marketplace listing and as a quick way to try the suite; for real CI, use the sub-actions in parallel jobs.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ runs:
9292
dependencies: "${{ inputs.dependencies }}"
9393
extensions: "${{ inputs.extensions }}"
9494
codecov-token: "${{ inputs.codecov-token }}"
95+
96+
- if: "github.event_name == 'pull_request'"
97+
uses: "setono/sylius-plugin/backwards-compatibility@v2"
98+
with:
99+
php-version: "${{ inputs.php-version }}"
100+
extensions: "${{ inputs.extensions }}"

backwards-compatibility/action.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Backwards compatibility"
2+
description: "Run Roave's backward-compatibility-check against the pull request's base ref"
3+
4+
inputs:
5+
php-version:
6+
description: "PHP version to install"
7+
required: false
8+
default: "8.2"
9+
extensions:
10+
description: "PHP extensions to install"
11+
required: false
12+
default: "intl, mbstring"
13+
from:
14+
description: "Git ref to compare against. The default works only in pull_request triggers; pass an explicit ref otherwise."
15+
required: false
16+
default: "origin/${{ github.event.pull_request.base.ref }}"
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: "actions/checkout@v6"
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: "shivammathur/setup-php@v2"
26+
with:
27+
php-version: "${{ inputs.php-version }}"
28+
extensions: "${{ inputs.extensions }}"
29+
coverage: "none"
30+
31+
- shell: "bash"
32+
run: "composer global require roave/backward-compatibility-check"
33+
34+
- shell: "bash"
35+
run: "~/.composer/vendor/bin/roave-backward-compatibility-check --from=${{ inputs.from }} --format=github-actions"

openspec/specs/ci-composite-actions/spec.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
## Purpose
44
TBD - created by archiving change add-ci-composite-actions. Update Purpose after archive.
55
## Requirements
6-
### Requirement: Repository ships seven independently invokable composite GitHub Actions
6+
### Requirement: Repository ships eight independently invokable composite GitHub Actions
77

8-
The repository SHALL provide seven composite GitHub Actions, each in its own subdirectory at the repo root with an `action.yml` file. Each sub-action MUST be invokable in a consumer workflow as `setono/sylius-plugin/<sub-action-name>@<ref>` and MUST be self-contained (it MUST NOT depend on any other sub-action in this repo).
8+
The repository SHALL provide eight composite GitHub Actions, each in its own subdirectory at the repo root with an `action.yml` file. Each sub-action MUST be invokable in a consumer workflow as `setono/sylius-plugin/<sub-action-name>@<ref>` and MUST be self-contained (it MUST NOT depend on any other sub-action in this repo).
99

10-
The seven sub-actions are:
10+
The eight sub-actions are:
1111
- `coding-standards`
1212
- `dependency-analysis`
1313
- `static-code-analysis`
1414
- `unit-tests`
1515
- `integration-tests`
1616
- `mutation-tests`
1717
- `code-coverage`
18+
- `backwards-compatibility`
1819

1920
#### Scenario: Consumer invokes a single sub-action
2021

@@ -120,6 +121,27 @@ The `code-coverage` sub-action SHALL install composer dependencies, run `vendor/
120121
- **WHEN** the action is invoked with a valid `codecov-token`
121122
- **THEN** clover coverage is generated and uploaded to Codecov successfully
122123

124+
### Requirement: Backwards compatibility sub-action runs Roave's backward-compatibility-check against the PR base ref
125+
126+
The `backwards-compatibility` sub-action SHALL check out the consumer's repo with `fetch-depth: 0`, install PHP, install `roave/backward-compatibility-check` via `composer global require`, then run `~/.composer/vendor/bin/roave-backward-compatibility-check --from=<from> --format=github-actions`. It SHALL accept inputs `php-version` (default `8.2`), `extensions` (default `intl, mbstring`), and `from` (default `origin/${{ github.event.pull_request.base.ref }}`).
127+
128+
The sub-action itself does not gate on event type. The root action MUST gate its invocation of `backwards-compatibility` with `if: github.event_name == 'pull_request'`, so the root remains safe to consume from any workflow. Standalone consumers SHALL scope their workflow to `on: pull_request` or pass an explicit `from` ref.
129+
130+
#### Scenario: PR-triggered invocation against the base ref
131+
132+
- **WHEN** the action is invoked from a `pull_request`-triggered workflow with no `from` input
133+
- **THEN** the BC check runs against `origin/<base-ref>` and any public-API regression is reported as a GitHub Actions inline annotation on the offending source line
134+
135+
#### Scenario: Consumer overrides the comparison ref
136+
137+
- **WHEN** the action is invoked with an explicit `from` input (e.g., `from: 'origin/main'`)
138+
- **THEN** the BC check runs against the provided ref instead of the PR base ref, allowing the action to work outside `pull_request` triggers
139+
140+
#### Scenario: Root action skips backwards-compatibility on non-PR triggers
141+
142+
- **WHEN** the root action is invoked from a non-`pull_request` trigger
143+
- **THEN** the root's `if: github.event_name == 'pull_request'` guard skips the backwards-compatibility step entirely, so non-PR runs of the root succeed regardless of the BC sub-action's PR requirement
144+
123145
### Requirement: All actions follow GitHub composite-action constraints
124146

125147
Every `run:` step in every action SHALL declare `shell: bash`. No action SHALL declare a top-level `env:` block (composite actions don't support it). Environment variables that need to span multiple steps SHALL be set per-step via `env:` on each `run:` step that needs them.
@@ -140,7 +162,7 @@ Action releases SHALL reuse the repository's existing tag scheme (e.g., `2.0.0`,
140162

141163
### Requirement: README documents every sub-action and its inputs
142164

143-
`README.md` SHALL contain a section documenting each of the seven sub-actions and the root action: action reference path, all inputs (with defaults and descriptions), and at least one consumer usage example. Per the project's existing rule, no new feature is considered complete until the README reflects it.
165+
`README.md` SHALL contain a section documenting each of the eight sub-actions and the root action: action reference path, all inputs (with defaults and descriptions), and at least one consumer usage example. Per the project's existing rule, no new feature is considered complete until the README reflects it.
144166

145167
#### Scenario: Consumer reads README to learn how to invoke the actions
146168

0 commit comments

Comments
 (0)