Skip to content

Commit c96c003

Browse files
committed
refactor(repeat): Move Repeat plugin in a separated repository
1 parent 743cb4f commit c96c003

16 files changed

Lines changed: 167 additions & 4 deletions

.github/.release-please-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
33
"release-type": "php",
4+
"separate-pull-requests": true,
45
"packages": {
56
".": {
67
"package-name": "testo",
7-
"changelog-path": "/CHANGELOG.md"
8+
"changelog-path": "/CHANGELOG.md",
9+
"exclude-paths": ["plugin/**", "bridge/**"]
10+
},
11+
"plugin/repeat": {
12+
"package-name": "testo/repeat",
13+
"component": "repeat",
14+
"include-component-in-tag": true,
15+
"changelog-path": "CHANGELOG.md"
816
}
917
},
1018
"bump-patch-for-minor-pre-major": true,
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
3+
# Splits plugin/bridge subtrees into their own dedicated repositories
4+
# whenever release-please tags a new component release in the monorepo.
5+
#
6+
# Each job:
7+
# - watches for tags matching its component prefix (e.g. "repeat-v0.1.0",
8+
# produced by release-please thanks to per-package include-component-in-tag);
9+
# - extracts the bare semver portion of the tag (e.g. "v0.1.0");
10+
# - uses symplify/monorepo-split-github-action to push the subdirectory
11+
# into the target repo with that bare tag, so Packagist sees a normal
12+
# v0.1.0 release.
13+
#
14+
# References:
15+
# - https://github.com/symplify/monorepo-split-github-action
16+
# - https://github.com/googleapis/release-please/blob/main/docs/customizing.md#subpackages
17+
#
18+
# Required secrets:
19+
# - RELEASE_TOKEN: a GitHub token (PAT or fine-grained) with `contents: write`
20+
# access to every target repo listed below. Same secret is reused for release-please.
21+
22+
on: # yamllint disable-line rule:truthy
23+
push:
24+
tags:
25+
- 'repeat-v*'
26+
27+
name: 📦 Split publish
28+
29+
jobs:
30+
split-repeat:
31+
name: ↪ plugin/repeat → php-testo/repeat
32+
if: startsWith(github.ref, 'refs/tags/repeat-v')
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: ⤵ Checkout monorepo (full history)
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: 🏷 Extract bare version from component tag
41+
id: tag
42+
run: echo "version=${GITHUB_REF_NAME#repeat-}" >> "$GITHUB_OUTPUT"
43+
44+
- name: 🌿 Resolve source branch for the tag
45+
id: branch
46+
# The tag is created on a major-version branch (1.x, 2.x, …).
47+
# Push the subtree into the same branch name on the target repo so
48+
# major series stay isolated end-to-end.
49+
run: |
50+
branch=$(git branch --remotes --contains "${GITHUB_REF_NAME}" \
51+
| sed 's|origin/||' \
52+
| grep -v 'HEAD' \
53+
| head -n 1 \
54+
| tr -d ' ')
55+
echo "name=${branch}" >> "$GITHUB_OUTPUT"
56+
57+
- name: 🚀 Push subtree to php-testo/repeat
58+
uses: symplify/monorepo-split-github-action@v2.3.0
59+
with:
60+
tag: ${{ steps.tag.outputs.version }}
61+
package_directory: plugin/repeat
62+
repository_organization: php-testo
63+
repository_name: repeat
64+
branch: ${{ steps.branch.outputs.name }}
65+
user_name: testo-bot
66+
user_email: bot@testo.dev
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
69+
70+
...

composer.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"psr/event-dispatcher": "^1.0",
3232
"symfony/console": "^6.4 || ^7 || ^8.0",
3333
"symfony/finder": "^6.4 || ^7 || ^8.0",
34+
"testo/repeat": "^1.0@dev",
3435
"yiisoft/injector": "^1.2"
3536
},
3637
"require-dev": {
@@ -55,7 +56,8 @@
5556
},
5657
"autoload-dev": {
5758
"psr-4": {
58-
"Tests\\": "tests/"
59+
"Tests\\": "tests/",
60+
"Tests\\Repeat\\": "plugin/repeat/tests/"
5961
},
6062
"files": [
6163
"tests/Fixture/functions.php"
@@ -71,6 +73,13 @@
7173
"options": {
7274
"symlink": true
7375
}
76+
},
77+
{
78+
"type": "path",
79+
"url": "plugin/repeat",
80+
"options": {
81+
"symlink": true
82+
}
7483
}
7584
],
7685
"config": {

plugin/repeat/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# testo/repeat
2+
3+
Repeat policy plugin for the [Testo](https://github.com/php-testo/testo) testing framework.
4+
5+
Apply `#[Repeat]` to a test method/function/class to run the test multiple times in a row.
6+
Combined with `#[Retry]`, the repeat cycle runs inside each retry attempt.
7+
8+
## Install
9+
10+
```bash
11+
composer require --dev testo/repeat
12+
```
13+
14+
## Usage
15+
16+
```php
17+
use Testo\Repeat;
18+
use Testo\Test;
19+
20+
#[Test]
21+
final class FlakyDetectionTest
22+
{
23+
#[Repeat(times: 5)]
24+
public function probablyDeterministic(): void
25+
{
26+
// executed 5 times; any single failure stops the loop and reports failure
27+
}
28+
}
29+
```
30+
31+
`#[Repeat]` can be placed on a method, a free function, or a whole class. When attached to a class, every test in it inherits the repeat policy unless overridden at the method level.
32+
33+
## Source
34+
35+
This package is split-published from the [`php-testo/testo`](https://github.com/php-testo/testo) monorepo (`plugin/repeat/`). Issues and pull requests should target the monorepo, not this read-only mirror.
36+
37+
## License
38+
39+
BSD-3-Clause. See [LICENSE](https://github.com/php-testo/testo/blob/1.x/LICENSE.md) in the monorepo.

plugin/repeat/composer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "testo/repeat",
3+
"description": "Repeat policy plugin for the Testo testing framework.",
4+
"license": "BSD-3-Clause",
5+
"type": "library",
6+
"keywords": [
7+
"testo",
8+
"repeat",
9+
"test"
10+
],
11+
"authors": [
12+
{
13+
"name": "Aleksei Gagarin (roxblnfk)",
14+
"homepage": "https://github.com/roxblnfk"
15+
}
16+
],
17+
"require": {
18+
"php": ">=8.2",
19+
"testo/testo": "*"
20+
},
21+
"autoload": {
22+
"psr-4": {
23+
"Testo\\Repeat\\": "src/"
24+
},
25+
"files": [
26+
"Repeat.php"
27+
]
28+
},
29+
"minimum-stability": "dev",
30+
"prefer-stable": true,
31+
"extra": {
32+
"branch-alias": {
33+
"dev-1.x": "0.1.x-dev"
34+
}
35+
}
36+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)