Skip to content

Commit b4f909e

Browse files
authored
[PM-5756] Comment on originating PR with BIT results (#373)
* comment on originating PR with BIT results * update text with configuration info * add failure commenting to no-flags workflow and update both workflowsto use GITHUB_TOKEN * additional fixes * further additional tweaks * use actions/create-github-app-token and fix typos * remove unused step id * add ENABLE_PR_FEEDBACK var to enable turning off PR commenting * only get and use GH App token if needed for sending orignating PR feedback
1 parent 67f6df6 commit b4f909e

File tree

2 files changed

+163
-4
lines changed

2 files changed

+163
-4
lines changed

.github/workflows/test-all-custom-flags.yml

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Test-all-custom-flags
2-
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH }} by @${{ github.actor }}
2+
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH || github.event.client_payload.origin_branch }} by @${{ github.actor }}
33
on:
44
push:
55
branches:
66
- "main"
7+
repository_dispatch:
8+
types: [trigger-bit-tests]
79
pull_request:
810
workflow_dispatch:
911
inputs:
@@ -25,9 +27,49 @@ jobs:
2527
id-token: write
2628
contents: read
2729
packages: read
30+
pull-requests: write
31+
outputs:
32+
send_pr_feedback: false
2833
steps:
34+
- name: Send PR feedback check
35+
id: set-send-pr-feedback
36+
run: |
37+
echo "send_pr_feedback=github.event.client_payload.origin_issue && vars.ENABLE_PR_FEEDBACK == 'true'" >> "$GITHUB_OUTPUT"
38+
39+
- name: Log in to Azure
40+
uses: bitwarden/gh-actions/azure-login@main
41+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
42+
with:
43+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
44+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
45+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
46+
47+
- name: Get Azure Key Vault secrets
48+
id: get-kv-secrets
49+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
50+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
51+
with:
52+
keyvault: gh-org-bitwarden
53+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
54+
55+
- name: Log out from Azure
56+
uses: bitwarden/gh-actions/azure-logout@main
57+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
58+
59+
- name: Generate GH App token
60+
id: app-token
61+
uses: actions/create-github-app-token@30bf6253fa41bdc8d1501d202ad15287582246b4 # v2.0.3
62+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
63+
with:
64+
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
65+
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
66+
owner: bitwarden
67+
repositories: clients
68+
permission-actions: write
69+
2970
- name: Checkout
3071
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
72+
3173
- name: Setup Node
3274
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3375
with:
@@ -68,7 +110,7 @@ jobs:
68110
github_token: ${{ secrets.GITHUB_TOKEN }}
69111
workflow: build-browser.yml
70112
workflow_conclusion: ""
71-
branch: ${{ inputs.CLIENTS_BRANCH || 'main' }}
113+
branch: ${{ github.event.client_payload.origin_branch || inputs.CLIENTS_BRANCH || 'main' }}
72114
name: ^dist-chrome-MV3-\w{7}\.zip$
73115
name_is_regexp: true
74116
repo: bitwarden/clients
@@ -144,3 +186,32 @@ jobs:
144186
./test-summary
145187
./tests-out/videos
146188
./tests-out/screenshots
189+
190+
# Only post back to the PR if there was a failure since test-all has the
191+
# typical config case covered for success feedback
192+
- name: Communicate BIT failure on originating issue
193+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
194+
if: failure() && steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
195+
with:
196+
github-token: ${{ steps.app-token.outputs.token }}
197+
script: |
198+
const owner = 'bitwarden';
199+
const featureFlags = "${{ inputs.FEATURE_FLAGS || '{}' }}";
200+
const featureFlagsMessage = featureFlags === '{}' ? 'all feature flags disabled.': `\n\n<details><summary><div>The following flags enabled:</div></summary>\`\`\`json\n${featureFlags}\`\`\``;
201+
const runURL = `https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId}`;
202+
const message = `⚠️ **Files have been modified in this PR that impact the Autofill experience** ⚠️
203+
204+
[BIT](https://github.com/${owner}/browser-interactions-testing) was run to verify no regressions have been introduced to the core Autofill experience. The tests ran with ${featureFlagsMessage}
205+
206+
❌ Unfortunately, one or more of these BIT tests failed. 😞
207+
208+
Please resolve the failure before merging; reach out to \`@bitwarden/team-autofill-dev\` if you'd like help.
209+
210+
You can view the detailed results of the tests [here](${runURL}).`;
211+
212+
github.rest.issues.createComment({
213+
issue_number: context.payload.client_payload.origin_issue,
214+
owner: owner,
215+
repo: 'clients',
216+
body: message
217+
});

.github/workflows/test-all.yml

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Test-all
2-
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH }} by @${{ github.actor }}
2+
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH || github.event.client_payload.origin_branch }} by @${{ github.actor }}
33
on:
44
push:
55
branches:
66
- "main"
7+
repository_dispatch:
8+
types: [trigger-bit-tests]
79
pull_request:
810
workflow_dispatch:
911
inputs:
@@ -24,9 +26,49 @@ jobs:
2426
id-token: write
2527
contents: read
2628
packages: read
29+
pull-requests: write
30+
outputs:
31+
send_pr_feedback: false
2732
steps:
33+
- name: Send PR feedback check
34+
id: set-send-pr-feedback
35+
run: |
36+
echo "send_pr_feedback=github.event.client_payload.origin_issue && vars.ENABLE_PR_FEEDBACK == 'true'" >> "$GITHUB_OUTPUT"
37+
38+
- name: Log in to Azure
39+
uses: bitwarden/gh-actions/azure-login@main
40+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
41+
with:
42+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
43+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
44+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
45+
46+
- name: Get Azure Key Vault secrets
47+
id: get-kv-secrets
48+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
49+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
50+
with:
51+
keyvault: gh-org-bitwarden
52+
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"
53+
54+
- name: Log out from Azure
55+
uses: bitwarden/gh-actions/azure-logout@main
56+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
57+
58+
- name: Generate GH App token
59+
id: app-token
60+
uses: actions/create-github-app-token@30bf6253fa41bdc8d1501d202ad15287582246b4 # v2.0.3
61+
if: steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
62+
with:
63+
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
64+
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
65+
owner: bitwarden
66+
repositories: clients
67+
permission-actions: write
68+
2869
- name: Checkout
2970
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
3072
- name: Setup Node
3173
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
3274
with:
@@ -65,7 +107,7 @@ jobs:
65107
github_token: ${{ secrets.GITHUB_TOKEN }}
66108
workflow: build-browser.yml
67109
workflow_conclusion: ""
68-
branch: ${{ inputs.CLIENTS_BRANCH || 'main' }}
110+
branch: ${{ github.event.client_payload.origin_branch || inputs.CLIENTS_BRANCH || 'main' }}
69111
name: ^dist-chrome-MV3-\w{7}\.zip$
70112
name_is_regexp: true
71113
repo: bitwarden/clients
@@ -146,3 +188,49 @@ jobs:
146188
./test-summary
147189
./tests-out/videos
148190
./tests-out/screenshots
191+
192+
- name: Communicate BIT failure on originating issue
193+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
194+
if: failure() && steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
195+
with:
196+
github-token: ${{ steps.app-token.outputs.token }}
197+
script: |
198+
const owner = 'bitwarden';
199+
const runURL = `https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId}`;
200+
const configURL = new URL('${{ vars.BW_REMOTE_VAULT_CONFIG_MATCH }}');
201+
const message = `⚠️ **Files have been modified in this PR that impact the Autofill experience** ⚠️
202+
203+
[BIT](https://github.com/${owner}/browser-interactions-testing) was run to verify no regressions have been introduced to the core Autofill experience. The tests ran with the same feature flag configuration used by \`${configURL.hostname}\`
204+
205+
❌ Unfortunately, one or more of these BIT tests failed. 😞
206+
207+
Please resolve the failure before merging; reach out to \`@bitwarden/team-autofill-dev\` if you'd like help.
208+
209+
You can view the detailed results of the tests [here](${runURL}).`;
210+
211+
github.rest.issues.createComment({
212+
issue_number: context.payload.client_payload.origin_issue,
213+
owner: owner,
214+
repo: 'clients',
215+
body: message
216+
});
217+
218+
- name: Communicate BIT success on originating issue
219+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
220+
if: success() && steps.set-send-pr-feedback.outputs.send_pr_feedback == 'true'
221+
with:
222+
github-token: ${{ steps.app-token.outputs.token }}
223+
script: |
224+
const owner = 'bitwarden';
225+
const message = `⚠️ **Files have been modified in this PR that impact the Autofill experience** ⚠️
226+
227+
[BIT](https://github.com/${owner}/browser-interactions-testing) was run to verify no regressions have been introduced to the core Autofill experience.
228+
229+
✅ Fortunately, [these BIT tests have passed](https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId})! 🎉`;
230+
231+
github.rest.issues.createComment({
232+
issue_number: context.payload.client_payload.origin_issue,
233+
owner: owner,
234+
repo: 'clients',
235+
body: message
236+
});

0 commit comments

Comments
 (0)