Skip to content

ci: Add Firefox testing for host #1242

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

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
cd71b12
ci: Add Firefox testing for host
backspace May 10, 2024
672f630
Add browser to concurrency id
backspace May 10, 2024
6f160ee
Fix environment variable name for browser
backspace May 10, 2024
9dc4171
Add Firefox tests for in-memory index
backspace May 10, 2024
0d8f712
Fix browser flag
backspace May 10, 2024
cbacaf8
Merge branch 'main' into ci/firefox-cs-6823
backspace May 13, 2024
3b49c5c
Add storage of JUnit reports
backspace May 13, 2024
8da577b
Remove invalid filename portion
backspace May 13, 2024
aaef40c
Merge branch 'main' into ci/firefox-cs-6823
backspace May 15, 2024
6e16f3c
Restore CI changes
backspace May 15, 2024
0cade06
Remove unnecessary conversion
backspace May 15, 2024
bb3a698
Fix test result comment names
backspace May 15, 2024
63cc6ea
Add report uploads again
backspace May 15, 2024
5738eba
Remove unnecessary artifact suffix
backspace May 15, 2024
69e1a78
Change to only run Percy on Chrome
backspace May 15, 2024
ad63918
Add preliminary attempt at instrumentation
backspace May 22, 2024
260895d
Merge from main
backspace May 22, 2024
7a0eaf8
Add transpile timer
backspace May 23, 2024
7a93f61
Change logging of times
backspace May 23, 2024
b909f5e
Change to never use Percy for now
backspace May 23, 2024
a0bda0d
Change time logging to be error
backspace May 23, 2024
207e9a0
Add more logging
backspace May 23, 2024
cffc280
Merge branch 'main' into ci/firefox-cs-6823
backspace May 23, 2024
151cb85
Add a separate attempt at logging
backspace May 23, 2024
083e935
Remove concurrency cancellation for now
backspace May 23, 2024
7b05f6d
Add more timers
backspace May 23, 2024
dfffe1b
Remove nonexistent function call
backspace May 23, 2024
0a42cd4
Add yet more logging
backspace May 23, 2024
749cf37
Fix logging of module name
backspace May 23, 2024
11d71a3
Merge branch 'main' into ci/firefox-cs-6823
backspace May 23, 2024
d66483c
Remove transpile timer for now
backspace May 23, 2024
1644ef8
Add instrumentation around visitOperatorMode
backspace May 24, 2024
1257556
Add timer around Matrix service load
backspace May 24, 2024
c86c82c
Remove failed patch attempt
backspace May 27, 2024
5ff060d
Add timing around fetchModule
backspace May 27, 2024
8a758c5
Add JSON output
backspace May 27, 2024
69525c3
Remove some metrics
backspace May 27, 2024
ceba455
Add more granular metrics in loadModule
backspace May 27, 2024
7a2ca87
Merge branch 'main' into ci/firefox-cs-6823
backspace May 27, 2024
96af3a4
Add another metric
backspace May 27, 2024
84b2992
Add timing around fetch parts
backspace May 28, 2024
2cdc32e
Add timings around mapRequest
backspace May 28, 2024
bdaca97
Merge branch 'main' into ci/firefox-cs-6823
backspace Jun 5, 2024
967442f
Update lockfile
backspace Jun 5, 2024
042627f
Add browser namespacing
backspace Jun 5, 2024
78604df
Change shard count
backspace Jun 5, 2024
f94430e
Change to twelve shards
backspace Jun 5, 2024
7902a31
Merge branch 'main' into ci/firefox-cs-6823
backspace Jun 7, 2024
c9dd269
Merge branch 'main' into ci/firefox-cs-6823
backspace Jul 11, 2024
f6e4696
Fix lockfile
backspace Jul 11, 2024
a642bb8
Fix report download
backspace Jul 11, 2024
7a8749c
Change to 10 shards again
backspace Jul 12, 2024
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
41 changes: 25 additions & 16 deletions .github/workflows/ci-host.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ jobs:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6]
shardTotal: [6]
browser: ["Chrome", "Firefox"]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]
env:
TESTEM_BROWSER: ${{ matrix.browser }}
concurrency:
group: boxel-host-test${{ github.head_ref || github.run_id }}-shard${{ matrix.shardIndex }}
group: boxel-host-test-${{ matrix.browser }}-${{ github.head_ref || github.run_id }}-shard${{ matrix.shardIndex }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
Expand All @@ -43,19 +46,20 @@ jobs:
- name: create realm users
run: pnpm register-realm-users
working-directory: packages/matrix
# FIXME restore PErcy
- name: host test suite (shard ${{ matrix.shardIndex }})
run: pnpm test-with-percy
run: pnpm test
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_HOST }}
PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_attempt }}
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_HOST }}
# PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_attempt }}
HOST_TEST_PARTITION: ${{ matrix.shardIndex }}
HOST_TEST_PARTITION_COUNT: ${{ matrix.shardTotal }}
working-directory: packages/host
- name: Upload junit report to GitHub Actions Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: host-test-report-${{ matrix.shardIndex }}
name: host-test-report-${{ matrix.browser }}-${{ matrix.shardIndex }}
path: junit/host-${{ matrix.shardIndex }}.xml
retention-days: 30

Expand All @@ -64,23 +68,28 @@ jobs:
if: always()
needs: host-test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: ["Chrome", "Firefox"]

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/init

- name: Finalise Percy
run: npx percy build:finalize
working-directory: packages/host
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_HOST }}
PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_attempt }}
# FIXME restore Percy
# - name: Finalise Percy
# run: npx percy build:finalize
# working-directory: packages/host
# env:
# PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_HOST }}
# PERCY_PARALLEL_NONCE: ${{ github.run_id }}-${{ github.run_attempt }}

- name: Download JUnit reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-host-reports
pattern: host-test-report-*
pattern: host-test-report-${{ matrix.browser }}-*
merge-multiple: true

- run: ls
Expand All @@ -93,7 +102,7 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: host-test-report-merged
name: host-test-report-merged-${{ matrix.browser }}
path: host.xml
retention-days: 30

Expand All @@ -102,4 +111,4 @@ jobs:
if: always()
with:
junit_files: host.xml
check_name: Host Test Results
check_name: Host Test Results (${{ matrix.browser }})
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"style-loader@2.0.0": "patches/style-loader@2.0.0.patch",
"ember-css-url@1.0.0": "patches/ember-css-url@1.0.0.patch",
"matrix-js-sdk@31.0.0": "patches/matrix-js-sdk@31.0.0.patch",
"ember-basic-dropdown@8.0.4": "patches/ember-basic-dropdown@8.0.4.patch",
"ember-source@5.4.1": "patches/ember-source@5.4.1.patch"
"ember-basic-dropdown@8.0.4": "patches/ember-basic-dropdown@8.0.4.patch"
}
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion packages/host/app/lib/sqlite-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
Deferred,
} from '@cardstack/runtime-common';

import { time } from '@cardstack/runtime-common/helpers/time';

export default class SQLiteAdapter implements DBAdapter {
private _sqlite: typeof SQLiteWorker | undefined;
private _dbId: string | undefined;
Expand Down Expand Up @@ -98,7 +100,8 @@ export default class SQLiteAdapter implements DBAdapter {

private async internalExecute(sql: string, opts?: ExecuteOptions) {
sql = this.adjustSQL(sql);
return await this.query(sql, opts);

return await time('sql', this.query(sql, opts));
}

async close() {
Expand Down
1 change: 1 addition & 0 deletions packages/host/config/fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function () {
Request: globalThis.Request,
fetch: globalThis.fetch,
btoa,
performance: globalThis.performance,
});
},
};
Expand Down
3 changes: 2 additions & 1 deletion packages/host/testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fs = require('fs');
const config = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: ['Chrome'],
launch_in_ci: [process.env.TESTEM_BROWSER || 'Chrome'],
launch_in_dev: ['Chrome'],
browser_start_timeout: 120,
browser_args: {
Expand All @@ -24,6 +24,7 @@ const config = {
'--window-size=1440,900',
].filter(Boolean),
},
Firefox: ['--headless', '--width=1440', '--height=900'],
},
};

Expand Down
19 changes: 13 additions & 6 deletions packages/host/tests/helpers/visit-operator-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { visit, waitFor } from '@ember/test-helpers';

import stringify from 'safe-stable-stringify';

import { time } from '@cardstack/runtime-common/helpers/time';

import { SerializedState } from '@cardstack/host/services/operator-mode-state-service';

export default async function visitOperatorMode({
Expand All @@ -21,12 +23,17 @@ export default async function visitOperatorMode({

let operatorModeStateParam = stringify(operatorModeState)!;

await visit(
`/?operatorModeEnabled=true&operatorModeState=${encodeURIComponent(
operatorModeStateParam,
)}`,
);
await time('visitOperatorMode:visit', async () => {
return await visit(
`/?operatorModeEnabled=true&operatorModeState=${encodeURIComponent(
operatorModeStateParam,
)}`,
);
});

if (stacks && stacks.length > 0 && (!submode || submode === 'interact')) {
await waitFor('[data-test-operator-mode-stack]');
await time('visitOperatorMode:waitFor', async () => {
return await waitFor('[data-test-operator-mode-stack]');
});
}
}
59 changes: 59 additions & 0 deletions packages/host/tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,69 @@ import Application from '@cardstack/host/app';
import config from '@cardstack/host/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { logger } from '@cardstack/runtime-common';
import { setup } from 'qunit-dom';
import { getTimes } from '@cardstack/runtime-common/helpers/time';

import setupOperatorModeParametersMatchAssertion from '@cardstack/host/tests/helpers/operator-mode-parameters-match';
import start from 'ember-exam/test-support/start';

const log = logger('current-run');

console.log('Setting Qunit hooks?');

log.error('Setting Qunit hooks?');

QUnit.on('runStart', () => {
log.error('Starting tests abcdefghijklmnopqrstuvwxyz');
});

QUnit.on('suiteEnd', (suiteEnd) => {
console.log(`Done tests for ${suiteEnd.name}`);

let times = getTimes();

[...times.keys()].forEach((key) => {
log.error(`${key}: ${times.get(key)}`);
});
log.error(JSON.stringify(Array.from(times.entries())));

log.error('that is all');
});

QUnit.on('runEnd', () => {
console.log('Done all tests');

let times = getTimes();

[...times.keys()].forEach((key) => {
log.error(`${key}: ${times.get(key)}`);
});
log.error(JSON.stringify(Array.from(times.entries())));

log.error('that is all');
});

QUnit.done(async () => {
console.log('Done all tests?? again');

let times = getTimes();

[...times.keys()].forEach((key) => {
log.error(`${key}: ${times.get(key)}`);
});

log.error('that is all…?');

return new Promise((resolve) => {
log.error('waiting for logs to flush');
setTimeout(() => {
log.error('logs flushed?');
resolve();
}, 5000);
});
});

setApplication(Application.create(config.APP));

setup(QUnit.assert);
Expand Down
49 changes: 49 additions & 0 deletions packages/runtime-common/helpers/time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
let labelToTime = new Map<string, number>();
let labelToStartTime = new Map<string, number>();

export async function time(
label: string,
promiseOrFunction: Promise<any> | (() => Promise<any>) | (() => any),
) {
let now = performance.now();

let result;
try {
if (typeof promiseOrFunction === 'function') {
result = await promiseOrFunction();
} else {
result = await promiseOrFunction;
}
} finally {
let diff = performance.now() - now;
let lastTime = labelToTime.get(label) || 0;
labelToTime.set(label, lastTime + diff);

return result;
}
}

export async function timeStart(label: string) {
labelToStartTime.set(label, performance.now());
}

export async function timeEnd(label: string) {
let now = performance.now();
let startTime = labelToStartTime.get(label);
if (startTime === undefined) {
console.error(`No start time found for label ${label}`);
return NaN;
}

let diff = now - startTime;
let lastTime = labelToTime.get(label) || 0;
labelToTime.set(label, lastTime + diff);

labelToStartTime.delete(label);

return diff;
}

export function getTimes() {
return labelToTime;
}
9 changes: 7 additions & 2 deletions packages/runtime-common/virtual-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { simulateNetworkBehaviors } from './fetcher';
export interface ResponseWithNodeStream extends Response {
nodeStream?: Readable;
}
import { time } from './helpers/time';

export type Handler = (req: Request) => Promise<ResponseWithNodeStream | null>;

Expand Down Expand Up @@ -134,10 +135,14 @@ export class VirtualNetwork {
request: Request,
direction: 'virtual-to-real' | 'real-to-virtual',
) {
let remappedUrl = this.resolveURLMapping(request.url, direction);
let remappedUrl = await time('mapRequest:resolveURLMapping', () =>
this.resolveURLMapping(request.url, direction),
);

if (remappedUrl) {
return await buildRequest(remappedUrl, request);
return await time('mapRequest:buildRequest', () =>
buildRequest(remappedUrl, request),
);
} else {
return request;
}
Expand Down
Loading
Loading