Skip to content

Commit c69cf43

Browse files
committed
Simplify
1 parent dd95f93 commit c69cf43

7 files changed

Lines changed: 30 additions & 34 deletions

File tree

.github/workflows/build-and-test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ jobs:
178178

179179
# We skip tests tagged with @mergequeue when running on PRs, but run them in MQ and everywhere else
180180
- name: Run Playwright tests
181+
working-directory: apps/web
181182
run: |
182183
pnpm playwright test \
183-
--config apps/web/playwright.config.ts \
184184
--shard "$SHARD" \
185185
--project="${{ matrix.project }}" \
186186
${{ (github.event_name == 'pull_request' && matrix.runAllTests == false ) && '--grep-invert @mergequeue' || '' }}
@@ -289,7 +289,10 @@ jobs:
289289

290290
- name: Merge into HTML Report
291291
if: inputs.skip != true
292-
run: pnpm playwright merge-reports --config=playwright-merge.config.ts ./all-blob-reports
292+
run: |
293+
pnpm playwright merge-reports \
294+
--reporter=html,./packages/playwright-common/flaky-reporter.ts,@element-hq/element-web-playwright-common/lib/stale-screenshot-reporter.js \
295+
./all-blob-reports
293296
env:
294297
# Only pass creds to the flaky-reporter on main branch runs
295298
GITHUB_TOKEN: ${{ github.ref_name == 'develop' && secrets.ELEMENT_BOT_TOKEN || '' }}

.github/workflows/build_desktop_test.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ jobs:
5454
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
5555
with:
5656
name: ${{ inputs.artifact }}
57-
path: dist
57+
path: apps/desktop/dist
5858

5959
- name: Prepare for tests
60+
working-directory: apps/desktop
6061
# This is set by the caller of the reusable workflow, they have the ability to run the command they specify
6162
# directly without our help so this is fine.
6263
run: ${{ inputs.prepare_cmd }} # zizmor: ignore[template-injection]
6364
if: inputs.prepare_cmd
6465

6566
- name: Expand executable path
6667
id: executable
68+
working-directory: apps/desktop
6769
shell: bash
6870
env:
6971
EXECUTABLE: ${{ inputs.executable }}
@@ -75,6 +77,7 @@ jobs:
7577
# it to be enabled to test Electron apps, so turn it back on.
7678
- name: Set EnableNodeCliInspectArguments fuse enabled
7779
run: $RUN_AS npx @electron/fuses write --app "$EXECUTABLE" EnableNodeCliInspectArguments=on
80+
working-directory: apps/desktop
7881
shell: bash
7982
env:
8083
# We need sudo on Linux as it is installed in /opt/
@@ -85,7 +88,7 @@ jobs:
8588
uses: coactions/setup-xvfb@6b00cf1889f4e1d5a48635647013c0508128ee1a
8689
timeout-minutes: 20
8790
with:
88-
run: pnpm playwright test --config apps/desktop/playwright.config.ts ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }} ${{ inputs.blob_report == false && '--reporter=html' || '' }} ${{ inputs.args }}
91+
run: pnpm -C apps/desktop playwright test ${{ runner.os != 'Linux' && '--ignore-snapshots' || '' }} ${{ inputs.blob_report == false && '--reporter=html' || '' }} ${{ inputs.args }}
8992
env:
9093
PW_TAG: ${{ inputs.project }}
9194
ELEMENT_DESKTOP_EXECUTABLE: ${{ steps.executable.outputs.path }}

knip.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export default {
77
workspaces: {
88
"packages/shared-components": {},
99
"packages/playwright-common": {
10+
ignore: [
11+
// Used in build-and-test playwright merge-reports
12+
"flaky-reporter.ts",
13+
],
1014
ignoreDependencies: [
1115
// Used in playwright-screenshots.sh
1216
"wait-on",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@nx-tools/nx-container": "^7.2.1",
4646
"@nx/jest": "^22.5.0",
4747
"@types/node": "22",
48+
"@playwright/test": "catalog:",
4849
"cronstrue": "^3.0.0",
4950
"eslint-plugin-matrix-org": "^3.0.0",
5051
"husky": "^9.0.0",

playwright/flaky-reporter.ts renamed to packages/playwright-common/flaky-reporter.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type PaginationLinks = {
2626

2727
// We see quite a few test flakes which are caused by the app exploding
2828
// so we have some magic strings we check the logs for to better track the flake with its cause
29-
const SPECIAL_CASES = {
29+
const SPECIAL_CASES: Record<string, string> = {
3030
"ChunkLoadError": "ChunkLoadError",
3131
"Unreachable code should not be executed": "Rust crypto panic",
3232
"Out of bounds memory access": "Rust crypto memory error",
@@ -37,7 +37,7 @@ class FlakyReporter implements Reporter {
3737

3838
public onTestEnd(test: TestCase): void {
3939
// Ignores flakes on Dendrite and Pinecone as they have their own flakes we do not track
40-
if (["Dendrite", "Pinecone"].includes(test.parent.project()?.name)) return;
40+
if (["Dendrite", "Pinecone"].includes(test.parent.project()!.name!)) return;
4141
let failures = [`${test.location.file.split("playwright/e2e/")[1]}: ${test.title}`];
4242
if (test.outcome() === "flaky") {
4343
const timedOutRuns = test.results.filter((result) => result.status === "timedOut");
@@ -46,7 +46,7 @@ class FlakyReporter implements Reporter {
4646
);
4747
// If a test failed due to a systemic fault then the test is not flaky, the app is, record it as such.
4848
const specialCases = Object.keys(SPECIAL_CASES).filter((log) =>
49-
pageLogs.some((attachment) => attachment.name.startsWith("page-") && attachment.body.includes(log)),
49+
pageLogs.some((attachment) => attachment.name.startsWith("page-") && attachment.body?.includes(log)),
5050
);
5151
if (specialCases.length > 0) {
5252
failures = specialCases.map((specialCase) => SPECIAL_CASES[specialCase]);
@@ -56,7 +56,7 @@ class FlakyReporter implements Reporter {
5656
if (!this.flakes.has(title)) {
5757
this.flakes.set(title, []);
5858
}
59-
this.flakes.get(title).push(test);
59+
this.flakes.get(title)!.push(test);
6060
}
6161
}
6262
}
@@ -76,8 +76,8 @@ class FlakyReporter implements Reporter {
7676
if (!link) return map;
7777
const matches = link.matchAll(/(<(?<link>.+?)>; rel="(?<type>.+?)")/g);
7878
for (const match of matches) {
79-
const { link, type } = match.groups;
80-
map[type] = link;
79+
const { link, type } = match.groups!;
80+
map[type as keyof PaginationLinks] = link;
8181
}
8282
return map;
8383
}
@@ -102,9 +102,9 @@ class FlakyReporter implements Reporter {
102102
issues.push(...fetchedIssues);
103103

104104
// Get the next link for fetching more results
105-
const linkHeader = issuesResponse.headers.get("Link");
105+
const linkHeader = issuesResponse.headers.get("Link")!;
106106
const parsed = this.parseLinkHeader(linkHeader);
107-
url = parsed.next;
107+
url = parsed.next!;
108108
}
109109
return issues;
110110
}

playwright-merge.config.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

pnpm-lock.yaml

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)