fix(executor): trim the evaluated job name
GitHub shows 'm two 2', not 'm two 2 ', when the last matrix value is empty (recorded: matrix-include-exclude).
- commit
- 79df48391aa9efd9fd4591cf8000c2e07f91322a
- author
- brice · · 2026-10-13 03:27 UTC
- parent
- 37766e4
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +36 -1
M internal/executor/job.go +4 -1
| @@ -642,7 +642,10 @@ func (j *job) jobDisplayName() string { | |||
| 642 | 642 | if err != nil { | |
| 643 | 643 | return fallback("the name does not evaluate", err) | |
| 644 | 644 | } | |
| 645 | - | return name | |
| 645 | + | // GitHub shows "Display name of", not "Display name of " (recorded: | |
| 646 | + | // matrix-include-exclude, an empty last matrix value). The recordings only | |
| 647 | + | // show trailing spaces; both ends are trimmed, as ermite's server does. | |
| 648 | + | return strings.TrimSpace(name) | |
| 646 | 649 | } | |
| 647 | 650 | ||
| 648 | 651 | // comboIndex finds the combination of the strategy that is this job. Without a | |
| @@ -642,7 +642,10 @@ func (j *job) jobDisplayName() string { | |||||
| 642 | if err != nil { | 642 | if err != nil { | ||
| 643 | return fallback("the name does not evaluate", err) | 643 | return fallback("the name does not evaluate", err) | ||
| 644 | } | 644 | } | ||
| 645 | - | return name | 645 | + | // GitHub shows "Display name of", not "Display name of " (recorded: |
| 646 | + | // matrix-include-exclude, an empty last matrix value). The recordings only | |||
| 647 | + | // show trailing spaces; both ends are trimmed, as ermite's server does. | |||
| 648 | + | return strings.TrimSpace(name) | |||
| 646 | } | 649 | } | ||
| 647 | 650 | ||||
| 648 | // comboIndex finds the combination of the strategy that is this job. Without a | 651 | // comboIndex finds the combination of the strategy that is this job. Without a | ||
A internal/executor/jobname_test.go +32 -0
| @@ -0,0 +1,32 @@ | |||
| 1 | + | // SPDX-License-Identifier: MIT | |
| 2 | + | ||
| 3 | + | package executor | |
| 4 | + | ||
| 5 | + | import "testing" | |
| 6 | + | ||
| 7 | + | // Recorded on github.com (matrix-include-exclude): "m two 2", not "m two 2 ". | |
| 8 | + | func TestJobNameIsTrimmed(t *testing.T) { | |
| 9 | + | needTools(t, "bash") | |
| 10 | + | yaml := `on: push | |
| 11 | + | jobs: | |
| 12 | + | main: | |
| 13 | + | name: m ${{ matrix.os }} ${{ matrix.extra }} | |
| 14 | + | runs-on: ubuntu-24.04 | |
| 15 | + | strategy: | |
| 16 | + | matrix: | |
| 17 | + | os: [one] | |
| 18 | + | include: | |
| 19 | + | - os: one | |
| 20 | + | extra: '' | |
| 21 | + | steps: | |
| 22 | + | - run: echo hi | |
| 23 | + | ` | |
| 24 | + | rec, res := runLocal(t, yaml, "main", func(c *Config) { c.MatrixJSON = `{"os":"one","extra":""}` }) | |
| 25 | + | if res.Conclusion != ConclusionSuccess { | |
| 26 | + | t.Fatalf("%+v", res) | |
| 27 | + | } | |
| 28 | + | log := rec.steps[0].Log | |
| 29 | + | if last := log[len(log)-1]; last != "Complete job name: m one" { | |
| 30 | + | t.Errorf("%q", last) | |
| 31 | + | } | |
| 32 | + | } | |
| @@ -0,0 +1,32 @@ | |||||
| 1 | + | // SPDX-License-Identifier: MIT | |||
| 2 | + | ||||
| 3 | + | package executor | |||
| 4 | + | ||||
| 5 | + | import "testing" | |||
| 6 | + | ||||
| 7 | + | // Recorded on github.com (matrix-include-exclude): "m two 2", not "m two 2 ". | |||
| 8 | + | func TestJobNameIsTrimmed(t *testing.T) { | |||
| 9 | + | needTools(t, "bash") | |||
| 10 | + | yaml := `on: push | |||
| 11 | + | jobs: | |||
| 12 | + | main: | |||
| 13 | + | name: m ${{ matrix.os }} ${{ matrix.extra }} | |||
| 14 | + | runs-on: ubuntu-24.04 | |||
| 15 | + | strategy: | |||
| 16 | + | matrix: | |||
| 17 | + | os: [one] | |||
| 18 | + | include: | |||
| 19 | + | - os: one | |||
| 20 | + | extra: '' | |||
| 21 | + | steps: | |||
| 22 | + | - run: echo hi | |||
| 23 | + | ` | |||
| 24 | + | rec, res := runLocal(t, yaml, "main", func(c *Config) { c.MatrixJSON = `{"os":"one","extra":""}` }) | |||
| 25 | + | if res.Conclusion != ConclusionSuccess { | |||
| 26 | + | t.Fatalf("%+v", res) | |||
| 27 | + | } | |||
| 28 | + | log := rec.steps[0].Log | |||
| 29 | + | if last := log[len(log)-1]; last != "Complete job name: m one" { | |||
| 30 | + | t.Errorf("%q", last) | |||
| 31 | + | } | |||
| 32 | + | } | |||