From 41a2af7f2091c24e54bc1da15e211dff3b447fd0 Mon Sep 17 00:00:00 2001 From: Tom Herold Date: Wed, 6 Nov 2024 10:31:24 +0100 Subject: [PATCH 1/3] always run artifact upload for nightly tests --- .github/workflows/nightly.yml | 1 + .github/workflows/wkorg-nightly.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0bb5d08c45..c30d5594dc 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -56,6 +56,7 @@ jobs: - name: Upload screenshots as artifact uses: actions/upload-artifact@v3 + if: always() with: name: screenshots path: frontend/javascripts/test/screenshots diff --git a/.github/workflows/wkorg-nightly.yaml b/.github/workflows/wkorg-nightly.yaml index 532196e477..d854dc382d 100644 --- a/.github/workflows/wkorg-nightly.yaml +++ b/.github/workflows/wkorg-nightly.yaml @@ -34,6 +34,7 @@ jobs: - name: Upload screenshots as artifact uses: actions/upload-artifact@v3 + if: always() with: name: screenshots path: frontend/javascripts/test/screenshots-wkorg From 149b8bafa8d3587f160ca2b8cac7d01a66eb123b Mon Sep 17 00:00:00 2001 From: Tom Herold Date: Wed, 6 Nov 2024 10:31:44 +0100 Subject: [PATCH 2/3] add browserstack session ID to every test run --- .../test/puppeteer/dataset_rendering_helpers.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts b/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts index 2c8cdd456e..d10fbe67d9 100644 --- a/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts +++ b/frontend/javascripts/test/puppeteer/dataset_rendering_helpers.ts @@ -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; @@ -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( From cba30e43afdddc08a15be90d3c5f92a04baff226 Mon Sep 17 00:00:00 2001 From: Tom Herold Date: Wed, 6 Nov 2024 10:48:50 +0100 Subject: [PATCH 3/3] upgrade uplad-artifact action to v4 --- .github/workflows/nightly.yml | 2 +- .github/workflows/wkorg-nightly.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c30d5594dc..e2835b810f 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -55,7 +55,7 @@ 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 diff --git a/.github/workflows/wkorg-nightly.yaml b/.github/workflows/wkorg-nightly.yaml index d854dc382d..726be72e33 100644 --- a/.github/workflows/wkorg-nightly.yaml +++ b/.github/workflows/wkorg-nightly.yaml @@ -33,7 +33,7 @@ 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