Skip to content

Commit b240150

Browse files
authored
Eliminate interpolation from workflows (#63188)
1 parent 3472548 commit b240150

File tree

6 files changed

+44
-27
lines changed

6 files changed

+44
-27
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ jobs:
118118
- name: Tests
119119
id: test
120120
# run tests, but lint separately
121-
run: npm run test -- --no-lint --bundle=${{ matrix.config.bundle }}
121+
env:
122+
BUNDLE: ${{ matrix.config.bundle }}
123+
run: npm run test -- --no-lint --bundle="$BUNDLE"
122124

123125
- name: Print baseline diff on failure
124126
if: ${{ failure() && steps.test.conclusion == 'failure' }}
@@ -264,10 +266,12 @@ jobs:
264266
id: pack
265267
266268
- name: Smoke test
269+
env:
270+
PACKAGE: ${{ steps.pack.outputs.package }}
267271
run: |
268272
cd "$(mktemp -d)"
269273
npm init --yes
270-
npm install ${{ steps.pack.outputs.package }}
274+
npm install "$PACKAGE"
271275
272276
echo "Testing tsc..."
273277
npx tsc --version

.github/workflows/close-issues.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ jobs:
2626
- name: Close issues
2727
env:
2828
GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
29+
REPO: ${{ github.repository }}
2930
run: |
3031
DATE=$(date --date='2 days ago' --iso-8601)
3132
3233
close_issues() {
3334
echo "Closing issues marked as '$1'."
34-
for issue in $(gh issue list --limit 100 --label "$1" --repo ${{ github.repository }} --state open --search "updated:<$DATE" --json number --jq '.[].number'); do
35-
echo "Closing https://github.com/${{ github.repository }}/issues/$issue"
36-
gh issue close $issue --repo ${{ github.repository }} --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes."
35+
for issue in $(gh issue list --limit 100 --label "$1" --repo "$REPO" --state open --search "updated:<$DATE" --json number --jq '.[].number'); do
36+
echo "Closing https://github.com/$REPO/issues/$issue"
37+
gh issue close $issue --repo "$REPO" --reason "not planned" --comment "This issue has been marked as \"$1\" and has seen no recent activity. It has been automatically closed for house-keeping purposes."
3738
done
3839
}
3940

.github/workflows/lkg.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ jobs:
2121
build:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- run: |
25-
if [[ ! "${{ inputs.branch_name }}" =~ ^release- ]]; then
24+
- env:
25+
BRANCH_NAME: ${{ inputs.branch_name }}
26+
run: |
27+
if [[ ! "$BRANCH_NAME" =~ ^release- ]]; then
2628
echo "Branch name must start with 'release-'"
2729
exit 1
2830
fi

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ jobs:
6363
# corepack enable npm
6464
npm install -g $(jq -r '.packageManager' < package.json)
6565
npm --version
66-
- run: |
67-
git checkout -b ${{ inputs.branch_name }}
68-
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
69-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
70-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
71-
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
66+
- env:
67+
BRANCH_NAME: ${{ inputs.branch_name }}
68+
PACKAGE_VERSION: ${{ inputs.package_version }}
69+
CORE_MAJOR_MINOR: ${{ inputs.core_major_minor }}
70+
run: |
71+
git checkout -b "$BRANCH_NAME"
72+
sed -i -e 's/"version": ".*"/"version": "'"$PACKAGE_VERSION"'"/g' package.json
73+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' src/compiler/corePublic.ts
74+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' tests/baselines/reference/api/typescript.d.ts
75+
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "'"$PACKAGE_VERSION"'" as string;/g' src/compiler/corePublic.ts
7276
npm ci
7377
npm install # update package-lock.json to ensure the version bump is included
7478
npx hereby LKG
@@ -80,8 +84,8 @@ jobs:
8084
git add --force ./lib
8185
git config user.email "typescriptbot@microsoft.com"
8286
git config user.name "TypeScript Bot"
83-
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
84-
git push --set-upstream origin ${{ inputs.branch_name }}
87+
git commit -m "Bump version to $PACKAGE_VERSION and LKG"
88+
git push --set-upstream origin "$BRANCH_NAME"
8589
8690
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master
8791
if: ${{ !cancelled() && inputs.distinct_id }}

.github/workflows/pr-modified-files.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ jobs:
3333

3434
env:
3535
GH_TOKEN: ${{ secrets.TS_BOT_GITHUB_TOKEN }}
36+
PR_NUMBER: ${{ github.event.pull_request.number }}
37+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
38+
REPO: ${{ github.repository }}
3639

3740
steps:
3841
- name: Check if PR author is in pr_owners.txt
3942
id: pr_owner
4043
run: |
4144
curl -s https://raw.githubusercontent.com/microsoft/TypeScript/main/.github/pr_owners.txt > pr_owners.txt
42-
if grep -Fxq -m1 "${{ github.event.pull_request.user.login }}" pr_owners.txt; then
45+
if grep -Fxq -m1 "$PR_AUTHOR" pr_owners.txt; then
4346
echo "pr_owner=true" >> "$GITHUB_OUTPUT"
4447
else
4548
echo "pr_owner=false" >> "$GITHUB_OUTPUT"
@@ -57,7 +60,7 @@ jobs:
5760
gh api graphql -f query='
5861
query($endCursor: String) {
5962
repository(owner: "microsoft", name: "TypeScript") {
60-
pullRequest(number: ${{ github.event.pull_request.number }}) {
63+
pullRequest(number: '"$PR_NUMBER"') {
6164
files(first: 100, after: $endCursor) {
6265
pageInfo{ hasNextPage, endCursor }
6366
nodes {
@@ -79,7 +82,7 @@ jobs:
7982
#!/bin/bash
8083
FILENAME=bot_comments.txt
8184
if [ ! -f $FILENAME ]; then
82-
gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} \
85+
gh pr view $PR_NUMBER --repo $REPO \
8386
--json 'comments' --jq '.comments[] | select(.author.login == "typescript-bot") | .body' > $FILENAME
8487
fi
8588
exec grep -Fq -m1 "$1" $FILENAME
@@ -99,7 +102,7 @@ jobs:
99102
MESSAGE+=" You can [read more here](https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#contributing-libdts-fixes)."
100103
MESSAGE+=" For house-keeping purposes, this pull request will be closed."
101104
102-
gh pr close ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --comment "$MESSAGE"
105+
gh pr close "$PR_NUMBER" --repo "$REPO" --comment "$MESSAGE"
103106
exit 1 # Stop the pipeline; we just closed the PR.
104107
fi
105108
@@ -114,7 +117,7 @@ jobs:
114117
if ./already_commented.sh "It looks like you've changed the TSServer protocol in some way."; then
115118
echo "Already commented."
116119
else
117-
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE"
120+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$MESSAGE"
118121
fi
119122
fi
120123
@@ -130,6 +133,6 @@ jobs:
130133
if ./already_commented.sh "Looks like you're introducing a change to the public API surface area."; then
131134
echo "Already commented."
132135
else
133-
gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --body "$MESSAGE"
136+
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$MESSAGE"
134137
fi
135138
fi

.github/workflows/set-version.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ jobs:
6868
# branch_name - the target branch
6969
# package_version - the full version string (eg, `3.9.1-rc` or `3.9.2`)
7070
# core_major_minor - the major.minor pair associated with the desired package_version (eg, `3.9` for `3.9.3`)
71-
- run: |
72-
sed -i -e 's/"version": ".*"/"version": "${{ inputs.package_version }}"/g' package.json
73-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' src/compiler/corePublic.ts
74-
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ inputs.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
75-
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ inputs.package_version }}" as string;/g' src/compiler/corePublic.ts
71+
- env:
72+
PACKAGE_VERSION: ${{ inputs.package_version }}
73+
CORE_MAJOR_MINOR: ${{ inputs.core_major_minor }}
74+
run: |
75+
sed -i -e 's/"version": ".*"/"version": "'"$PACKAGE_VERSION"'"/g' package.json
76+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' src/compiler/corePublic.ts
77+
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "'"$CORE_MAJOR_MINOR"'"/g' tests/baselines/reference/api/typescript.d.ts
78+
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "'"$PACKAGE_VERSION"'" as string;/g' src/compiler/corePublic.ts
7679
npm ci
7780
npm install # update package-lock.json to ensure the version bump is included
7881
npx hereby LKG
@@ -84,7 +87,7 @@ jobs:
8487
git add --force ./lib
8588
git config user.email "typescriptbot@microsoft.com"
8689
git config user.name "TypeScript Bot"
87-
git commit -m 'Bump version to ${{ inputs.package_version }} and LKG'
90+
git commit -m "Bump version to $PACKAGE_VERSION and LKG"
8891
git push
8992
9093
- uses: microsoft/typescript-bot-test-triggerer/.github/actions/post-workflow-result@master

0 commit comments

Comments
 (0)