Skip to content

[PM-5756] Comment on originating PR with BIT results #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions .github/workflows/test-all-custom-flags.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Test-all-custom-flags
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH }} by @${{ github.actor }}
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH || github.event.client_payload.origin_branch }} by @${{ github.actor }}
on:
push:
branches:
- "main"
repository_dispatch:
types: [trigger-bit-tests]
pull_request:
workflow_dispatch:
inputs:
Expand All @@ -25,9 +27,38 @@ jobs:
id-token: write
contents: read
packages: read
pull-requests: write
steps:
- name: Log in to Azure
uses: bitwarden/gh-actions/azure-login@main
with:
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
client_id: ${{ secrets.AZURE_CLIENT_ID }}

- name: Get Azure Key Vault secrets
id: get-kv-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: gh-org-bitwarden
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"

- name: Log out from Azure
uses: bitwarden/gh-actions/azure-logout@main

- name: Generate GH App token
uses: actions/create-github-app-token@30bf6253fa41bdc8d1501d202ad15287582246b4 # v2.0.3
id: app-token
with:
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
owner: bitwarden
repositories: clients
permission-actions: write

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
Expand Down Expand Up @@ -68,7 +99,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-browser.yml
workflow_conclusion: ""
branch: ${{ inputs.CLIENTS_BRANCH || 'main' }}
branch: ${{ github.event.client_payload.origin_branch || inputs.CLIENTS_BRANCH || 'main' }}
name: ^dist-chrome-MV3-\w{7}\.zip$
name_is_regexp: true
repo: bitwarden/clients
Expand Down Expand Up @@ -144,3 +175,32 @@ jobs:
./test-summary
./tests-out/videos
./tests-out/screenshots

# Only post back to the PR if there was a failure since test-all has the
# typical config case covered for success feedback
Comment on lines +179 to +180
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasoning here being, we don't need to be overly noisy if everything looks good, but we still want to alert if these cases fail.

- name: Communicate BIT failure on originating issue
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: failure() && github.event.client_payload.origin_issue && vars.ENABLE_PR_FEEDBACK == 'true'
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const owner = 'bitwarden';
const featureFlags = "${{ inputs.FEATURE_FLAGS || '{}' }}";
const featureFlagsMessage = featureFlags === '{}' ? 'all feature flags disabled.': `\n\n<details><summary><div>The following flags enabled:</div></summary>\`\`\`json\n${featureFlags}\`\`\``;
const runURL = `https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId}`;
const message = `โš ๏ธ **Files have been modified in this PR that impact the Autofill experience** โš ๏ธ

[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}

โŒ Unfortunately, one or more of these BIT tests failed. ๐Ÿ˜ž

Please resolve the failure before merging; reach out to \`@bitwarden/team-autofill-dev\` if you'd like help.

You can view the detailed results of the tests [here](${runURL}).`;

github.rest.issues.createComment({
issue_number: context.payload.client_payload.origin_issue,
owner: owner,
repo: 'clients',
body: message
});
81 changes: 79 additions & 2 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Test-all
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH }} by @${{ github.actor }}
run-name: All tests with extension build ${{ inputs.CLIENTS_BRANCH || github.event.client_payload.origin_branch }} by @${{ github.actor }}
on:
push:
branches:
- "main"
repository_dispatch:
types: [trigger-bit-tests]
pull_request:
workflow_dispatch:
inputs:
Expand All @@ -24,9 +26,38 @@ jobs:
id-token: write
contents: read
packages: read
pull-requests: write
steps:
- name: Log in to Azure
uses: bitwarden/gh-actions/azure-login@main
with:
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
client_id: ${{ secrets.AZURE_CLIENT_ID }}

- name: Get Azure Key Vault secrets
id: get-kv-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: gh-org-bitwarden
secrets: "BW-GHAPP-ID,BW-GHAPP-KEY"

- name: Log out from Azure
uses: bitwarden/gh-actions/azure-logout@main

- name: Generate GH App token
uses: actions/create-github-app-token@30bf6253fa41bdc8d1501d202ad15287582246b4 # v2.0.3
id: app-token
with:
app-id: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-ID }}
private-key: ${{ steps.get-kv-secrets.outputs.BW-GHAPP-KEY }}
owner: bitwarden
repositories: clients
permission-actions: write

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
Expand Down Expand Up @@ -65,7 +96,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-browser.yml
workflow_conclusion: ""
branch: ${{ inputs.CLIENTS_BRANCH || 'main' }}
branch: ${{ github.event.client_payload.origin_branch || inputs.CLIENTS_BRANCH || 'main' }}
name: ^dist-chrome-MV3-\w{7}\.zip$
name_is_regexp: true
repo: bitwarden/clients
Expand Down Expand Up @@ -146,3 +177,49 @@ jobs:
./test-summary
./tests-out/videos
./tests-out/screenshots

- name: Communicate BIT failure on originating issue
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: failure() && github.event.client_payload.origin_issue && vars.ENABLE_PR_FEEDBACK == 'true'
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const owner = 'bitwarden';
const runURL = `https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId}`;
const configURL = new URL('${{ vars.BW_REMOTE_VAULT_CONFIG_MATCH }}');
const message = `โš ๏ธ **Files have been modified in this PR that impact the Autofill experience** โš ๏ธ

[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}\`

โŒ Unfortunately, one or more of these BIT tests failed. ๐Ÿ˜ž

Please resolve the failure before merging; reach out to \`@bitwarden/team-autofill-dev\` if you'd like help.

You can view the detailed results of the tests [here](${runURL}).`;

github.rest.issues.createComment({
issue_number: context.payload.client_payload.origin_issue,
owner: owner,
repo: 'clients',
body: message
});

- name: Communicate BIT success on originating issue
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: success() && github.event.client_payload.origin_issue && vars.ENABLE_PR_FEEDBACK == 'true'
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const owner = 'bitwarden';
const message = `โš ๏ธ **Files have been modified in this PR that impact the Autofill experience** โš ๏ธ

[BIT](https://github.com/${owner}/browser-interactions-testing) was run to verify no regressions have been introduced to the core Autofill experience.

โœ… Fortunately, [these BIT tests have passed](https://github.com/${owner}/browser-interactions-testing/actions/runs/${context.runId})! ๐ŸŽ‰`;

github.rest.issues.createComment({
issue_number: context.payload.client_payload.origin_issue,
owner: owner,
repo: 'clients',
body: message
});
Loading