Skip to content

Commit df0b144

Browse files
committed
Drop the redundant prefix from grouped leg names
Confirmed against wp-cli/wp-cli-tests#352 that the fanned-out shape does group the legs in the run view. What it also showed is that the leg names then repeat their group: a group called "Behat | PHP 8.5" containing "Behat | PHP 8.5 | WP latest | SQLite". wordpress-develop handles this by suppressing the prefix in the called workflow whenever the calling job already states it — its leg name only includes "PHP {0} with" for the test-group and coverage callers, which are exactly the ones whose job name is not "PHP {0}". Do the same, with an explicit `grouped` input rather than inferring it from unrelated inputs. Wrapped callers leave it at its default of false and are unaffected; their names still have to stand on their own because their calling job is not surfaced. The expression is written as `!grouped && <prefix> || ''` rather than the more natural looking `grouped && '' || <prefix>`, because an empty string is falsy and the latter would fall through to the prefix in both cases. That is the same trap that made fetch-depth always evaluate to 1 earlier in this branch; zizmor's unsound-ternary audit is clean on the form used here. Noted in the README that a grouped leg name is only unique within its group, so the back-out is to set `grouped: false` for that caller. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jy4dmjymj9VmoTBaqrV4iX
1 parent 10bf92f commit df0b144

4 files changed

Lines changed: 54 additions & 14 deletions

File tree

‎.github/workflows/reusable-functional.yml‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ on:
2929
type: string
3030
required: false
3131
default: ''
32+
grouped:
33+
description: 'Set when the calling job name already states the suite and PHP version, so this workflow leaves them out instead of repeating them inside the group.'
34+
type: boolean
35+
required: false
36+
default: false
3237

3338
permissions:
3439
contents: read
3540

3641
jobs:
3742
functional:
38-
# This name has to stand on its own. The run view labels a nested job with its
39-
# own name only; the calling job's name is not surfaced at this depth, so
40-
# anything omitted here is not shown anywhere. The database version is spelled
41-
# out because "MySQL" alone rendered the mysql-8.0 and mysql-8.4 legs
42-
# identically.
43-
name: Behat | PHP ${{ inputs.php }} | WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.mysql || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
43+
# When the caller wraps this workflow, its own name is not surfaced in the run
44+
# view, so this name has to carry everything. When the caller fans out, its job
45+
# name becomes the group header and already states the suite and PHP version,
46+
# so repeating them here reads as noise. `grouped` picks between the two.
47+
#
48+
# Written as `!grouped && <prefix> || ''` rather than `grouped && '' || <prefix>`
49+
# on purpose: an empty string is falsy, so the latter would fall through to the
50+
# prefix in both cases.
51+
#
52+
# The database version is spelled out because "MySQL" alone rendered the
53+
# mysql-8.0 and mysql-8.4 legs identically.
54+
name: ${{ !inputs.grouped && format('Behat | PHP {0} | ', inputs.php) || '' }}WP ${{ inputs.wp }} | ${{ inputs.dbtype == 'sqlite' && 'SQLite' || inputs.mysql || 'MySQL' }}${{ inputs.object_cache == 'sqlite' && ' (Obj Cache)' || '' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
4455
# Repositories with a heavy Behat suite can point the default Linux legs at a
4556
# larger runner by setting the `RUNNERS_NAME` repository variable, without
4657
# having to fork this workflow. Explicit macOS/Windows legs are unaffected.

‎.github/workflows/reusable-unit.yml‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@ on:
1414
type: string
1515
required: false
1616
default: ''
17+
grouped:
18+
description: 'Set when the calling job name already states the suite and PHP version, so this workflow leaves them out instead of repeating them inside the group.'
19+
type: boolean
20+
required: false
21+
default: false
1722

1823
permissions:
1924
contents: read
2025

2126
jobs:
2227
unit:
23-
# This name has to stand on its own. The run view labels a nested job with its
24-
# own name only; the calling job's name is not surfaced at this depth, so
25-
# anything omitted here is not shown anywhere.
26-
name: Unit | PHP ${{ inputs.php }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
28+
# See the note on the equivalent name in reusable-functional.yml: `grouped`
29+
# picks between a name that stands on its own and one that sits inside a group
30+
# header which already states the suite and PHP version.
31+
name: ${{ !inputs.grouped && format('Unit | PHP {0}', inputs.php) || 'PHPUnit' }}${{ inputs.coverage && ' (with coverage)' || '' }}${{ startsWith( inputs.os, 'windows' ) && ' (Windows)' || '' }}${{ startsWith( inputs.os, 'macos' ) && ' (macOS)' || '' }}
2732
# Repositories can point the default Linux legs at a larger runner by setting
2833
# the `RUNNERS_NAME` repository variable, without having to fork this workflow.
2934
# Explicit macOS/Windows legs are unaffected.

‎.github/workflows/testing.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ jobs:
4545
php: ${{ matrix.php }}
4646
coverage: ${{ matrix.coverage == true }}
4747
os: ${{ matrix.os || '' }}
48+
# The job name above already states the suite and PHP version.
49+
grouped: true
4850

4951
functional:
5052
needs: prepare
@@ -63,3 +65,5 @@ jobs:
6365
object_cache: ${{ matrix.object_cache }}
6466
coverage: ${{ matrix.coverage == true }}
6567
os: ${{ matrix.os || '' }}
68+
# The job name above already states the suite and PHP version.
69+
grouped: true

‎README.md‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,30 @@ surfaced, so all fifty legs appear as one flat list. Fanning out puts the matrix
4444
at the top level, so the run view collapses to one entry per PHP version.
4545

4646
It costs about thirty lines in a file that is not synced, so every future change
47-
to the fan-out has to be repeated in each package that adopts it. The leg names
48-
are self-describing in both shapes and repeat the PHP version inside the group,
49-
because the same called workflows serve both. Prefer the wrapped shape unless a
50-
package has a large enough matrix that the flat list is genuinely hard to read.
47+
to the fan-out has to be repeated in each package that adopts it. Prefer the
48+
wrapped shape unless a package has a large enough matrix that the flat list is
49+
genuinely hard to read.
50+
51+
A fanned-out caller should pass `grouped: true` to `reusable-unit.yml` and
52+
`reusable-functional.yml`. Their job names then leave out the suite and PHP
53+
version, because the group header already states both:
54+
55+
```
56+
Behat | PHP 8.5 <- the calling job
57+
WP latest | mysql-8.0 <- the called workflow, with grouped: true
58+
WP trunk | SQLite
59+
```
60+
61+
Without it the legs read `Behat | PHP 8.5 | WP latest | mysql-8.0` inside a group
62+
already called `Behat | PHP 8.5`. Wrapped callers must leave it at its default of
63+
`false`, because there is no group header for them and the name has to stand on
64+
its own.
65+
66+
The one thing to watch is that with `grouped: true` a leg name is only unique
67+
within its group — `WP latest | SQLite` occurs under every PHP version. That is
68+
fine wherever the group header is part of the name, which is how the run view and
69+
the checks list both render it. If a leg ever shows up somewhere without its
70+
group, set `grouped: false` for that caller and the full name comes back.
5171

5272
#### Branch Alias Checker
5373

0 commit comments

Comments
 (0)