Skip to content

Commit

Permalink
Always Upload Screenshot Artifacts for Nightly Tests (#8171)
Browse files Browse the repository at this point in the history
* always run artifact upload for nightly tests

* add browserstack session ID to every test run

* upgrade uplad-artifact action to v4
  • Loading branch information
hotzenklotz authored Nov 6, 2024
1 parent 5988865 commit 8f8a1d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ jobs:
BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

- name: Upload screenshots as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: screenshots
path: frontend/javascripts/test/screenshots
3 changes: 2 additions & 1 deletion .github/workflows/wkorg-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

- name: Upload screenshots as artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: screenshots
path: frontend/javascripts/test/screenshots-wkorg
Expand Down
16 changes: 15 additions & 1 deletion frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,19 @@ export function setupBeforeEachAndAfterEach() {
browser_version: "latest",
os: "os x",
os_version: "mojave",
name: t.title, // add test name to BrowserStack session
"browserstack.username": process.env.BROWSERSTACK_USERNAME,
"browserstack.accessKey": process.env.BROWSERSTACK_ACCESS_KEY,
};
t.context.browser = await puppeteer.connect({
const browser = await puppeteer.connect({
browserWSEndpoint: `ws://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent(
JSON.stringify(caps),
)}`,
});
t.context.browser = browser;

console.log(`\nRunning chrome version ${await t.context.browser.version()}\n`);
console.log(`\nBrowserStack Session Id ${await getBrowserstackSessionId(browser)}\n`);
global.Headers = Headers;
global.fetch = fetch;
global.Request = Request;
Expand All @@ -397,6 +400,17 @@ export function setupBeforeEachAndAfterEach() {
});
}

async function getBrowserstackSessionId(browser: Browser) {
const page = await browser.newPage();
const response = (await page.evaluate(
(_) => {},
`browserstack_executor: ${JSON.stringify({ action: "getSessionDetails" })}`,
)) as unknown as string;

const sessionDetails = await JSON.parse(response);
return sessionDetails.hashed_id;
}

export function checkBrowserstackCredentials() {
if (process.env.BROWSERSTACK_USERNAME == null || process.env.BROWSERSTACK_ACCESS_KEY == null) {
throw new Error(
Expand Down

0 comments on commit 8f8a1d2

Please sign in to comment.