Skip to content

Commit 0ee0284

Browse files
authored
Fix release pipeline tests and workflow (#64831)
1 parent 655f026 commit 0ee0284

7 files changed

Lines changed: 67 additions & 3 deletions

File tree

‎.github/workflows/create-cherry-pick-pr.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ jobs:
6666
run: git switch --detach "origin/$TARGET_BRANCH"
6767
- run: npm ci
6868
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
69+
if: ${{ !cancelled() }}
6970
with:
7071
client-id: ${{ vars.AZURE_CLIENT_ID }}
7172
tenant-id: ${{ vars.AZURE_TENANT_ID }}
7273
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
7374
- name: Create GitHub App token
75+
if: ${{ !cancelled() }}
7476
id: app-token
7577
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
7678
with:

‎.github/workflows/new-release-branch.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ jobs:
108108
git config core.hooksPath /dev/null
109109
git commit -m "Bump version to $PACKAGE_VERSION"
110110
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
111+
if: ${{ !cancelled() }}
111112
with:
112113
client-id: ${{ vars.AZURE_CLIENT_ID }}
113114
tenant-id: ${{ vars.AZURE_TENANT_ID }}
114115
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
115116
- name: Create GitHub App token
117+
if: ${{ !cancelled() }}
116118
id: app-token
117119
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
118120
with:
@@ -121,6 +123,7 @@ jobs:
121123
owner: microsoft
122124
repositories: TypeScript
123125
permission-contents: write
126+
permission-issues: write
124127
- name: Configure git for GitHub App token
125128
env:
126129
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}

‎.github/workflows/set-version.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ jobs:
125125
git config core.hooksPath /dev/null
126126
git commit -m "Bump version to $PACKAGE_VERSION"
127127
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
128+
if: ${{ !cancelled() }}
128129
with:
129130
client-id: ${{ vars.AZURE_CLIENT_ID }}
130131
tenant-id: ${{ vars.AZURE_TENANT_ID }}
131132
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
132133
- name: Create GitHub App token
134+
if: ${{ !cancelled() }}
133135
id: app-token
134136
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
135137
with:
@@ -138,6 +140,7 @@ jobs:
138140
owner: microsoft
139141
repositories: TypeScript
140142
permission-contents: write
143+
permission-issues: write
141144
- name: Configure git for GitHub App token
142145
if: steps.configure.outputs.changed == 'true'
143146
env:

‎.github/workflows/sync-branch.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,13 @@ jobs:
116116
exit 1
117117
fi
118118
- uses: azure/login@a641126d1b8aa4d1fa005f4f92df94a3a4c4c906 # v3.1.0
119+
if: ${{ !cancelled() }}
119120
with:
120121
client-id: ${{ vars.AZURE_CLIENT_ID }}
121122
tenant-id: ${{ vars.AZURE_TENANT_ID }}
122123
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
123124
- name: Create GitHub App token
125+
if: ${{ !cancelled() }}
124126
id: app-token
125127
uses: microsoft/create-github-app-token-via-key-vault@5ba0d436e9c3cac52feff4d1f2f66f9698ce4a2d # v1
126128
with:
@@ -129,6 +131,7 @@ jobs:
129131
owner: microsoft
130132
repositories: TypeScript
131133
permission-contents: write
134+
permission-issues: write
132135
- name: Configure git for GitHub App token
133136
env:
134137
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}

‎tsc/internal/execute/tsctests/sys.go‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,22 @@ var (
485485

486486
func (o *outputSanitizer) addOutputLine(s string) {
487487
s = strings.ReplaceAll(s, fmt.Sprintf("'%s'", core.Version()), fmt.Sprintf("'%s'", harnessutil.FakeTSVersion))
488-
s = strings.ReplaceAll(s, englishVersion, fakeEnglishVersion)
489-
s = strings.ReplaceAll(s, czechVersion, fakeCzechVersion)
488+
s = sanitizeVersion(s, englishVersion, fakeEnglishVersion)
489+
s = sanitizeVersion(s, czechVersion, fakeCzechVersion)
490490
s = fsbaselineutil.SanitizeInternalSymbolName(s)
491491
o.outputLines = append(o.outputLines, s)
492492
}
493493

494+
func sanitizeVersion(s string, version string, replacement string) string {
495+
if before, after, ok := strings.Cut(s, version); ok && strings.HasPrefix(after, " ") {
496+
// Preserve the padded field width when replacing the version in the help header.
497+
suffix := strings.TrimLeft(after, " ")
498+
width := len(version) + len(after) - len(suffix)
499+
s = before + fmt.Sprintf("%-*s", width, replacement) + suffix
500+
}
501+
return strings.ReplaceAll(s, version, replacement)
502+
}
503+
494504
func (o *outputSanitizer) sanitizeBuildStatusTimeStamp() string {
495505
statusLine := o.lines[o.index]
496506
hhSeparator := strings.IndexRune(statusLine, ':')

‎tsc/internal/execute/tsctests/tsc_test.go‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,54 @@ import (
77
"testing"
88

99
"github.com/microsoft/TypeScript/tsc/internal/core"
10+
"github.com/microsoft/TypeScript/tsc/internal/diagnostics"
11+
"github.com/microsoft/TypeScript/tsc/internal/locale"
1012
"github.com/microsoft/TypeScript/tsc/internal/testutil/contentmappertest"
13+
"github.com/microsoft/TypeScript/tsc/internal/testutil/harnessutil"
1114
"github.com/microsoft/TypeScript/tsc/internal/testutil/stringtestutil"
1215
"github.com/microsoft/TypeScript/tsc/internal/vfs/vfstest"
16+
"gotest.tools/v3/assert"
1317
)
1418

19+
func TestOutputSanitizerVersionPadding(t *testing.T) {
20+
t.Parallel()
21+
for name, language := range map[string]locale.Locale{"en": locale.Default, "cs": czech} {
22+
t.Run(name, func(t *testing.T) {
23+
t.Parallel()
24+
version := diagnostics.Version_0.Localize(language, core.Version())
25+
fakeVersion := diagnostics.Version_0.Localize(language, harnessutil.FakeTSVersion)
26+
header := diagnostics.X_tsc_Colon_The_TypeScript_Compiler.Localize(language) + " - "
27+
for _, test := range []struct {
28+
name string
29+
input string
30+
want string
31+
}{
32+
{name: "version", input: version, want: fakeVersion},
33+
{name: "version in prose", input: version + " is installed", want: fakeVersion + " is installed"},
34+
{name: "repeated versions", input: version + ", " + version, want: fakeVersion + ", " + fakeVersion},
35+
{name: "header without logo", input: header + version, want: header + fakeVersion},
36+
{
37+
name: "header with logo",
38+
input: fmt.Sprintf("%-115s\x1b[44m \x1b[39;49m", header+version),
39+
want: fmt.Sprintf("%-115s\x1b[44m \x1b[39;49m", header+fakeVersion),
40+
},
41+
{
42+
name: "narrow header with logo",
43+
input: fmt.Sprintf("%-75s\x1b[44m \x1b[39;49m", header+version),
44+
want: fmt.Sprintf("%-75s\x1b[44m \x1b[39;49m", header+fakeVersion),
45+
},
46+
} {
47+
t.Run(test.name, func(t *testing.T) {
48+
t.Parallel()
49+
sanitizer := &outputSanitizer{}
50+
sanitizer.addOutputLine(test.input)
51+
assert.Equal(t, strings.Join(sanitizer.outputLines, "\n"), test.want)
52+
})
53+
}
54+
})
55+
}
56+
}
57+
1558
func TestTscCommandline(t *testing.T) {
1659
t.Parallel()
1760
colorTest := func(subScenario string, env map[string]string, outputIsTTY bool) *tscInput {

‎tsc/testdata/baselines/reference/tsc/commandLine/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tsgo
66
ExitStatus:: DiagnosticsPresent_OutputsSkipped
77
Output::
88
Version FakeTSVersion
9-
tsc: The TypeScript Compiler - Version FakeTSVersion [44m [39;49m
9+
tsc: The TypeScript Compiler - Version FakeTSVersion [44m [39;49m
1010
 TS 
1111
COMMON COMMANDS
1212

0 commit comments

Comments
 (0)