Skip to content

E2E Phase 1: close desktop coverage gaps (batch 1 of 5) #394

E2E Phase 1: close desktop coverage gaps (batch 1 of 5)

E2E Phase 1: close desktop coverage gaps (batch 1 of 5) #394

Workflow file for this run

name: E2E PR Trigger
# Automatically adds the E2E/Run label to non-draft PRs targeting master.
# Adding the label signals Matterwick to provision cloud servers and dispatch
# the Electron Playwright Tests (e2e-functional.yml) workflow.
# After tests complete, e2e-functional.yml / e2e-label-cleanup.yml remove the label.
#
# E2E/Override (same contract as mattermost-mobile): when present on a PR,
# opened/synchronize events do not add E2E/Run, and applying the override label
# strips E2E/Run and cancels in-flight E2E runs.
#
# On synchronize: in-progress Electron Playwright Tests runs for this PR are
# cancelled before re-adding the label so stale runs for the old commit do not
# block the new one. Runs on other PR branches are left running.
#
# The concurrency group ensures rapid pushes to the same PR don't queue multiple
# label operations: only the most recent push proceeds.
on:
pull_request:
types:
- opened
- reopened
- ready_for_review
- synchronize
- labeled
- unlabeled
branches:
- master
concurrency:
group: e2e-pr-trigger-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
add-e2e-label:
name: Add E2E/Run label
runs-on: ubuntu-22.04
permissions:
issues: write
pull-requests: write
actions: write
statuses: write
if: >-
!github.event.pull_request.draft
&& contains(fromJSON('["opened", "reopened", "ready_for_review", "synchronize"]'), github.event.action)
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
if: github.event.pull_request.head.repo.full_name == github.repository
with:
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: |
e2e/utils/github-actions.js
sparse-checkout-cone-mode: false
- name: Cancel running E2E tests and re-trigger
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ github.token }}
script: |
const {cancelActiveE2ERuns, markE2EStatusesCancelled} = require('./e2e/utils/github-actions.js');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const pr = context.payload.pull_request;
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number,
});
const labelNames = labels.map((label) => label.name);
if (labelNames.includes('E2E/Override')) {
core.info(`PR #${issue_number} has E2E/Override — skipping E2E/Run refresh.`);
if (labelNames.includes('E2E/Run')) {
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number,
name: 'E2E/Run',
});
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
}
await cancelActiveE2ERuns({
github,
context,
prNumber: issue_number,
headBranch: pr.head.ref,
});
await markE2EStatusesCancelled({
github,
context,
sha: pr.head.sha,
reason: 'E2E skipped (E2E/Override label active)',
});
return;
}
await cancelActiveE2ERuns({
github,
context,
prNumber: issue_number,
headBranch: pr.head.ref,
});
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number,
name: 'E2E/Run',
});
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
await github.rest.issues.addLabels({
owner,
repo,
issue_number,
labels: ['E2E/Run'],
});
honor-e2e-override:
name: Honor E2E/Override
runs-on: ubuntu-22.04
permissions:
issues: write
pull-requests: write
actions: write
statuses: write
if: >-
github.event.action == 'labeled'
&& github.event.label.name == 'E2E/Override'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
if: github.event.pull_request.head.repo.full_name == github.repository
with:
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: |
e2e/utils/github-actions.js
sparse-checkout-cone-mode: false
- name: Strip E2E/Run and cancel in-flight E2E
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ github.token }}
script: |
const {cancelActiveE2ERuns, markE2EStatusesCancelled} = require('./e2e/utils/github-actions.js');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const pr = context.payload.pull_request;
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number,
name: 'E2E/Run',
});
} catch (error) {
if (error.status !== 404) {
throw error;
}
}
await cancelActiveE2ERuns({
github,
context,
prNumber: issue_number,
headBranch: pr.head.ref,
});
await markE2EStatusesCancelled({
github,
context,
sha: pr.head.sha,
reason: 'E2E cancelled (E2E/Override label applied)',
});
cancel-on-manual-unlabel:
name: Cancel E2E on manual label removal
runs-on: ubuntu-22.04
permissions:
actions: write
statuses: write
pull-requests: read
if: >-
github.event.action == 'unlabeled'
&& github.event.label.name == 'E2E/Run'
&& github.event.sender.login != 'github-actions[bot]'
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.base.ref }}
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
if: github.event.pull_request.head.repo.full_name == github.repository
with:
ref: ${{ github.event.pull_request.head.sha }}
sparse-checkout: |
e2e/utils/github-actions.js
sparse-checkout-cone-mode: false
- name: Cancel E2E runs and mark statuses skipped
uses: ./.github/actions/cancel-e2e-runs
with:
pr_number: ${{ github.event.pull_request.number }}
reason: E2E cancelled (E2E/Run label removed)