Skip to content

Commit 8548701

Browse files
committed
Merge branch 'main' into feat/add-vscode-extension-ci
2 parents bfee832 + b29209c commit 8548701

13 files changed

Lines changed: 690 additions & 82 deletions

File tree

.cursor/rules/yaml-checklist.mdc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
globs: *.yml
3+
alwaysApply: false
4+
---
5+
6+
Moving stuff to Environment Variables for safer scripting
7+
ex: there is an input named `githubTag`. Add an `ENV:` to it like `INPUTS_GITHUB_TAG: ${{ inputs.githubTag }}`
8+
9+
### shell scripts
10+
11+
In github worklows that run shell scripts refer to inputs and outputs via the environment variable convention.
12+
BAD: `RESPONSE=$(npm view .@${{ inputs.githubTag }} version --json --silent || echo "Not published")`
13+
GOOD: `RESPONSE=$(npm view .@$INPUTS_GITHUB_TAG version --json --silent || echo "Not published")`
14+
15+
### script tag
16+
17+
when using `script` from actions/github-script
18+
BAD: `script: core.setFailed("The version '$INPUTS_GITHUB_TAG' has already been published to npm")`
19+
GOOD: `script: core.setFailed(`The version '${process.env.INPUTS_GITHUB_TAG}' has already been published to npm`)`
20+
21+
It's OK to use ${{ foo }} outside of shell script (`run:`) blocks and outside of `script` (example if: statements on a job)

.github/actions/ctcOpen/action.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ inputs:
1414
SVC_CLI_BOT_GITHUB_TOKEN:
1515
description: Github token
1616
required: true
17+
githubTag:
18+
description: 'The semver tag of the GitHub Release'
19+
required: false
1720

1821
outputs:
1922
changeCaseId:
@@ -35,27 +38,35 @@ runs:
3538

3639
- name: Open CTC case
3740
id: ctc
38-
uses: salesforcecli/github-workflows/.github/actions/retry@main
39-
with:
40-
max_attempts: 5
41-
command: |
42-
CTC_RESULT=$(sfchangecase create --location ${{ github.repositoryUrl }} --release ${{ github.repository }}.$(date +%F) --json)
43-
44-
STATUS=$(printf '%s' "$CTC_RESULT" | jq -r '.status')
45-
CTC_ID=$(printf '%s' "$CTC_RESULT" | jq -r '.result.id')
46-
47-
if [[ "$STATUS" == "0" && "$CTC_ID" != "null" ]]; then
48-
echo "Successfully created case with ID: $CTC_ID"
49-
echo "ctcId=$CTC_ID" >> "$GITHUB_OUTPUT"
50-
else
51-
echo "CTC failed to open a case. Result:"
52-
echo "$CTC_RESULT"
53-
exit 1
54-
fi
41+
shell: bash
42+
run: |
43+
# Temp disable exit on error
44+
set +e
45+
if [ -n "$GITHUB_TAG" ]; then
46+
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases/tag/$GITHUB_TAG"
47+
else
48+
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases"
49+
fi
50+
CTC_RESULT=$(sfchangecase create --location ${{github.repositoryUrl}} --test-environment $RELEASE_URL --service platform-cli --release ${{github.repository}}.$(date +%F) --json)
51+
# Re-enable exit on error
52+
set -e
53+
54+
STATUS=$(printf '%s' "$CTC_RESULT" | jq -r '.status')
55+
CTC_ID=$(printf '%s' "$CTC_RESULT" | jq -r '.result.id')
56+
57+
if [[ "$STATUS" == "0" && "$CTC_ID" != "null" ]]; then
58+
echo "Successfully created case with ID: $CTC_ID"
59+
echo "ctcId=$CTC_ID" >> "$GITHUB_OUTPUT"
60+
else
61+
echo "CTC failed to open a case. Result:"
62+
echo "$CTC_RESULT"
63+
exit 1
64+
fi
5565
env:
5666
SF_CHANGE_CASE_SFDX_AUTH_URL: ${{ inputs.SF_CHANGE_CASE_SFDX_AUTH_URL}}
5767
SF_CHANGE_CASE_TEMPLATE_ID: ${{ inputs.SF_CHANGE_CASE_TEMPLATE_ID}}
5868
SF_CHANGE_CASE_CONFIGURATION_ITEM: ${{ inputs.SF_CHANGE_CASE_CONFIGURATION_ITEM}}
69+
GITHUB_TAG: ${{ inputs.githubTag }}
5970

6071
- run: echo "[INFO] Change Case ID is:\ $STEPS_CTC_CTCID"
6172
shell: bash
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: npm-install-with-retries
2+
description: 'wraps npm install with retries/timeout to handle network failures'
3+
inputs:
4+
ignore-scripts:
5+
default: 'false'
6+
description: 'Skip pre/post install scripts'
7+
runs:
8+
using: composite
9+
steps:
10+
- name: timeout config
11+
run: npm config set fetch-timeout 600000
12+
shell: bash
13+
- name: npm ci
14+
uses: salesforcecli/github-workflows/.github/actions/retry@main
15+
with:
16+
command: npm ci --no-audit --no-fund ${{ inputs.ignore-scripts == 'true' && '--ignore-scripts' || '' }}

.github/actions/yarnInstallWithRetries/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: yarn-install-with-retries
2-
description: "wraps yarn install with retries/timeout to handle network failures"
2+
description: 'wraps yarn install with retries/timeout to handle network failures'
33
inputs:
44
ignore-scripts:
55
default: 'false'
6-
description: "Skip pre/post install scripts"
6+
description: 'Skip pre/post install scripts'
77
runs:
88
using: composite
99
steps:

.github/workflows/create-github-release.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
SVC_CLI_BOT_GITHUB_TOKEN:
66
description: A Github PAT with repo write access.
77
required: true
8-
8+
CLI_ALERTS_SLACK_WEBHOOK:
9+
description: Slack webhook for alerts.
10+
required: false
911
inputs:
1012
prerelease:
1113
type: string
@@ -103,3 +105,58 @@ jobs:
103105
prerelease: ${{ steps.prereleaseTag.outputs.tag && 'true' || 'false' }}
104106
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
105107
skipIfReleaseExists: true
108+
109+
# Determine if we should alert Slack that the release was skipped.
110+
# Skip the alert if: no webhook is configured, or the commit is from a Dependabot merge.
111+
- name: Should we post to Slack that release was skipped
112+
id: should-post-slack
113+
if: steps.changelog.outputs.skipped == 'true'
114+
run: |
115+
if [ -z "$SLACK_WEBHOOK" ]; then
116+
echo "[INFO] No Slack webhook configured, skipping alert"
117+
exit 0
118+
fi
119+
120+
PR_AUTHOR=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" --jq '.[0].user.login // empty')
121+
echo "[INFO] PR author: $PR_AUTHOR"
122+
123+
if [ "$PR_AUTHOR" = "dependabot[bot]" ]; then
124+
echo "[INFO] Dependabot merge, skipping alert"
125+
exit 0
126+
fi
127+
128+
echo "post_skipped_release_to_slack=true" >> "$GITHUB_OUTPUT"
129+
env:
130+
SLACK_WEBHOOK: ${{ secrets.CLI_ALERTS_SLACK_WEBHOOK }}
131+
GH_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
132+
133+
- name: Announce if Github Release was skipped
134+
id: slack
135+
if: steps.should-post-slack.outputs.post_skipped_release_to_slack == 'true'
136+
uses: slackapi/slack-github-action@v1.26.0
137+
env:
138+
# for non-CLI-team-owned plugins, you can send this anywhere you like
139+
SLACK_WEBHOOK_URL: ${{ secrets.CLI_ALERTS_SLACK_WEBHOOK }}
140+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
141+
with:
142+
# Payload can be visually tested here: https://app.slack.com/block-kit-builder/T01GST6QY0G#%7B%22blocks%22:%5B%5D%7D
143+
# Only copy over the "blocks" array to the Block Kit Builder
144+
payload: |
145+
{
146+
"blocks": [
147+
{
148+
"type": "header",
149+
"text": {
150+
"type": "plain_text",
151+
"text": ":uno-skip-red: Github Release was skipped in ${{ github.repository }}! :uno-skip-red:"
152+
}
153+
},
154+
{
155+
"type": "section",
156+
"text": {
157+
"type": "mrkdwn",
158+
"text": "*Repo:* ${{ github.server_url }}/${{ github.repository }}\n*Workflow name:* `${{ github.workflow }}`\n*Run url:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
159+
}
160+
}
161+
]
162+
}

.github/workflows/ctcClose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: lts/*
23-
cache: npm
23+
# No `cache: npm`: it requires an npm lockfile and so hard-fails on
24+
# pnpm/yarn consumer repos; the CTC CLI below is a one-off global install.
2425
- run: npm install -g @salesforce/change-case-management --omit=dev
2526
- id: ctc
2627
run: |

.github/workflows/ctcOpen.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: lts/*
23-
cache: npm
23+
# No `cache: npm`: it requires an npm lockfile and so hard-fails on
24+
# pnpm/yarn consumer repos; the CTC CLI below is a one-off global install.
2425

2526
- run: npm install -g @salesforce/change-case-management --omit=dev
2627

@@ -35,7 +36,7 @@ jobs:
3536
else
3637
RELEASE_URL="${{ github.server_url }}/${{ github.repository }}/releases"
3738
fi
38-
CTC_RESULT=$(sfchangecase create --location ${{github.repositoryUrl}} --test-environment $RELEASE_URL --release ${{github.repository}}.$(date +%F) --json)
39+
CTC_RESULT=$(sfchangecase create --location ${{github.repositoryUrl}} --test-environment $RELEASE_URL --service platform-cli --release ${{github.repository}}.$(date +%F) --json)
3940
# Re-enable exit on error
4041
set -e
4142

.github/workflows/externalNut.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,50 @@ on:
1515
inputs:
1616
# could we get this from pjson?
1717
packageName:
18-
description: "The npm package that this repository publishes. ex: @salesforce/core"
18+
description: 'The npm package that this repository publishes. ex: @salesforce/core'
1919
required: true
2020
type: string
2121
externalProjectGitUrl:
22-
description: "The url that will be cloned. This contains the NUTs you want to run. Ex: https://github.com/salesforcecli/plugin-user"
22+
description: 'The url that will be cloned. This contains the NUTs you want to run. Ex: https://github.com/salesforcecli/plugin-user'
2323
type: string
2424
required: true
2525
command:
2626
required: false
2727
type: string
2828
default: yarn test:nuts
29-
description: "command to execute (ex: yarn test:nuts)"
29+
description: 'command to execute (ex: yarn test:nuts)'
3030
nodeVersion:
3131
required: false
3232
description: version of node to run tests against. Use things like [lts/-1, lts/*, latest] to avoid hardcoding versions
3333
type: string
3434
default: lts/*
3535
os:
3636
required: false
37-
description: "runs-on property, ex: ubuntu-latest, windows-latest"
37+
description: 'runs-on property, ex: ubuntu-latest, windows-latest'
3838
type: string
39-
default: "ubuntu-latest"
39+
default: 'ubuntu-latest'
4040
sfdxExecutablePath:
4141
required: false
4242
description: "Path to sfdx executable to be used by NUTs, defaults to ''"
4343
type: string
4444
preBuildCommands:
4545
required: false
46-
description: "commands to run before the build...for example, to delete known module conflicts"
46+
description: 'commands to run before the build...for example, to delete known module conflicts'
4747
type: string
4848
default: 'echo "no preBuildCommands passed"'
4949
postBuildCommands:
5050
required: false
51-
description: "script to run after the build"
51+
description: 'script to run after the build'
5252
type: string
5353
default: 'echo "no postBuildCommands passed"'
5454
preExternalBuildCommands:
5555
required: false
56-
description: "commands to run before the build of the external repo...for example, to delete known module conflicts"
56+
description: 'commands to run before the build of the external repo...for example, to delete known module conflicts'
5757
type: string
5858
default: 'echo "no preExternalBuildCommands passed"'
5959
preSwapCommands:
6060
required: false
61-
description: "commands to run before ANY modifications happen. For example, changes that modify the lockfile like yarn add or remove need to happen before the action manually swaps the dependency under test"
61+
description: 'commands to run before ANY modifications happen. For example, changes that modify the lockfile like yarn add or remove need to happen before the action manually swaps the dependency under test'
6262
type: string
6363
default: 'echo "no preSwapCommands passed"'
6464
useCache:
@@ -73,10 +73,10 @@ on:
7373
required: false
7474
description: "branch to clone from the repo. Defaults to 'main'"
7575
type: string
76-
default: "main"
76+
default: 'main'
7777
ignoreScripts:
7878
required: false
79-
description: "if true, will run yarn install --ignore-scripts when building package in node_modules"
79+
description: 'if true, will run yarn install --ignore-scripts when building package in node_modules'
8080
type: boolean
8181
default: false
8282

@@ -126,6 +126,7 @@ jobs:
126126

127127
- name: Swap this dependency for the version on this branch
128128
if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }}
129+
shell: bash
129130
run: |
130131
yarn remove "$INPUTS_PACKAGE_NAME"
131132
yarn add ${{ github.repository }}#${{ github.sha }}

0 commit comments

Comments
 (0)