From 27149133a04504a3374b246e86f7edbaa88accbb Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 15:24:56 +0100 Subject: [PATCH 01/10] try --- .github/workflows/test.yml | 46 ++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad3b23c8..5742e1e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,23 +10,19 @@ on: workflow_dispatch: jobs: - test: - name: Test + test-macos: + name: Test macOS runs-on: macos-latest env: GITHUB_ACTIONS_OUTPUT: "" strategy: fail-fast: false matrix: - browser: [chrome, firefox, jsc, safari, spidermonkey, v8] + browser: [safari] steps: - name: Extract Week Number run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - - name: Install Firefox - if: ${{ matrix.browser == 'firefox' }} - run: brew install --cask firefox - - name: Checkout Branch uses: actions/checkout@v5 @@ -50,6 +46,42 @@ jobs: echo "Running in $BROWSER" npm run test:${{ matrix.browser }} + test-linux: + name: Test Linux + runs-on: ubuntu-latest + env: + GITHUB_ACTIONS_OUTPUT: "" + strategy: + fail-fast: false + matrix: + browser: [chrome, firefox, jsc, spidermonkey, v8] + steps: + - name: Extract Week Number + run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV + + - name: Checkout Branch + uses: actions/checkout@v5 + + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version-file: package.json + cache: npm + + - name: Install Node Packages + run: npm ci + + - name: Cache jsvu Binaries + uses: actions/cache@v4 + with: + path: ~/.jsvu + key: ${{ runner.os }}-jsvu-${{ matrix.browser }}-week-${{ env.WEEK_NUMBER }} + + - name: Run Tests + run: | + echo "Running in $BROWSER" + npm run test:${{ matrix.browser }} + build: name: Build runs-on: ubuntu-latest From e02a45611a3e8356d5416baca5e01455f6bd7b90 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 15:26:50 +0100 Subject: [PATCH 02/10] wip --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12e5f35a..7cc74590 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,23 +10,49 @@ on: workflow_dispatch: jobs: - browser: - name: Test Browser + browser-macos: + name: Test Browser on macOS runs-on: macos-latest env: GITHUB_ACTIONS_OUTPUT: "" strategy: fail-fast: false matrix: - browser: [chrome, firefox, safari] + browser: [safari] suite: [default, disabled, main] steps: - name: Extract Week Number run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - - name: Install Firefox - if: ${{ matrix.browser == 'firefox' }} - run: brew install --cask firefox + - name: Checkout Branch + uses: actions/checkout@v5 + + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version-file: package.json + cache: npm + + - name: Install Node Packages + run: npm ci + + - name: Run Tests + run: | + echo "Running in $BROWSER" + npm run test:${{ matrix.browser }} -- ${{ matrix.suite }} + browser-linux: + name: Test Browser on Linux + runs-on: ubuntu-latest + env: + GITHUB_ACTIONS_OUTPUT: "" + strategy: + fail-fast: false + matrix: + browser: [chrome, firefox] + suite: [default, disabled, main] + steps: + - name: Extract Week Number + run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - name: Checkout Branch uses: actions/checkout@v5 From 180deb777710454498cf9e4d2994b13661bca955 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 15:40:05 +0100 Subject: [PATCH 03/10] headlessly --- tests/run-browser.mjs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/run-browser.mjs b/tests/run-browser.mjs index 92caadb0..2894ee87 100644 --- a/tests/run-browser.mjs +++ b/tests/run-browser.mjs @@ -25,7 +25,7 @@ // THE POSSIBILITY OF SUCH DAMAGE. import serve from "./server.mjs"; -import { Builder, Capabilities, logging } from "selenium-webdriver"; +import { Builder, Capabilities, logging, firefox, chrome } from "selenium-webdriver"; import commandLineArgs from "command-line-args"; import { promises as fs } from "fs"; import path from "path"; @@ -93,6 +93,7 @@ if (options.suite && !VALID_TAGS.includes(options.suite)) printHelp(`Invalid suite: ${options.suite}. Choices are: ${VALID_TAGS.join(", ")}`); const BROWSER = options?.browser; +const IS_HEADLESS = os.platform() === "linux" && !process.env.DISPLAY; if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser", optionDefinitions); @@ -104,11 +105,17 @@ switch (BROWSER) { break; case "firefox": { - capabilities = Capabilities.firefox(); + const options = new firefox.Options(); + if (IS_HEADLESS) + options.addArguments("-headless"); + capabilities = Capabilities.firefox().set("moz:firefoxOptions", options); break; } case "chrome": { - capabilities = Capabilities.chrome(); + const options = new chrome.Options(); + if (IS_HEADLESS) + options.addArguments("--headless"); + capabilities = Capabilities.chrome().set("goog:chromeOptions", options); break; } case "edge": { From db15b8854c91e6a67959ae0d3af2e23b01605243 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:03:35 +0100 Subject: [PATCH 04/10] more headless --- tests/run-browser.mjs | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tests/run-browser.mjs b/tests/run-browser.mjs index 2894ee87..c25146a7 100644 --- a/tests/run-browser.mjs +++ b/tests/run-browser.mjs @@ -25,7 +25,9 @@ // THE POSSIBILITY OF SUCH DAMAGE. import serve from "./server.mjs"; -import { Builder, Capabilities, logging, firefox, chrome } from "selenium-webdriver"; +import { Builder, Capabilities } from "selenium-webdriver"; +import chrome from "selenium-webdriver/chrome.js"; +import firefox from "selenium-webdriver/firefox.js"; import commandLineArgs from "command-line-args"; import { promises as fs } from "fs"; import path from "path"; @@ -98,6 +100,7 @@ if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser", optionDefinitions); let capabilities; +let browserOptions; switch (BROWSER) { case "safari": capabilities = Capabilities.safari(); @@ -105,17 +108,19 @@ switch (BROWSER) { break; case "firefox": { - const options = new firefox.Options(); - if (IS_HEADLESS) + capabilities = Capabilities.firefox() + if (IS_HEADLESS) { + browserOptions = new firefox.Options(); options.addArguments("-headless"); - capabilities = Capabilities.firefox().set("moz:firefoxOptions", options); + } break; } case "chrome": { - const options = new chrome.Options(); - if (IS_HEADLESS) - options.addArguments("--headless"); - capabilities = Capabilities.chrome().set("goog:chromeOptions", options); + capabilities = Capabilities.chrome() + if (IS_HEADLESS) { + options = new chrome.Options(); + options = options.headless(); + } break; } case "edge": { @@ -166,7 +171,20 @@ async function runEnd2EndTest(name, params) { } async function testEnd2End(params) { - const driver = await new Builder().withCapabilities(capabilities).build(); + const builder = new Builder().withCapabilities(capabilities); + if (browserOptions) { + switch(BROWSER) { + case "firefox": + builder.setFirefoxOptions(browserOptions); + break; + case "chrome": + builder.setChromeOptions(browserOptions); + break; + default: + break; + } + } + const driver = await builder.build(); const sessionId = (await driver.getSession()).getId(); const driverCapabilities = await driver.getCapabilities(); logInfo(`Browser: ${driverCapabilities.getBrowserName()} ${driverCapabilities.getBrowserVersion()}`); From 4aa8fba2c2a89b01623f6eb90d06c040a88885db Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:04:49 +0100 Subject: [PATCH 05/10] fix --- tests/run-browser.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run-browser.mjs b/tests/run-browser.mjs index c25146a7..2e415ef4 100644 --- a/tests/run-browser.mjs +++ b/tests/run-browser.mjs @@ -111,15 +111,15 @@ switch (BROWSER) { capabilities = Capabilities.firefox() if (IS_HEADLESS) { browserOptions = new firefox.Options(); - options.addArguments("-headless"); + browserOptions.addArguments("-headless"); } break; } case "chrome": { capabilities = Capabilities.chrome() if (IS_HEADLESS) { - options = new chrome.Options(); - options = options.headless(); + browserOptions = new chrome.Options(); + browserOptions = browserOptions.headless(); } break; } From bfecabc58d33fe1c1a0d32a93bdd481007ce733f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:06:57 +0100 Subject: [PATCH 06/10] use headless option directly --- tests/run-browser.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run-browser.mjs b/tests/run-browser.mjs index 2e415ef4..1feac9b3 100644 --- a/tests/run-browser.mjs +++ b/tests/run-browser.mjs @@ -111,7 +111,7 @@ switch (BROWSER) { capabilities = Capabilities.firefox() if (IS_HEADLESS) { browserOptions = new firefox.Options(); - browserOptions.addArguments("-headless"); + browserOptions = browserOptions.headless(); } break; } From dc6b184bacb5826605f8f5a4f2c25762051e8cc3 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:10:54 +0100 Subject: [PATCH 07/10] support headless or so --- tests/run-browser.mjs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/run-browser.mjs b/tests/run-browser.mjs index 1feac9b3..44cc825a 100644 --- a/tests/run-browser.mjs +++ b/tests/run-browser.mjs @@ -25,9 +25,9 @@ // THE POSSIBILITY OF SUCH DAMAGE. import serve from "./server.mjs"; -import { Builder, Capabilities } from "selenium-webdriver"; -import chrome from "selenium-webdriver/chrome.js"; -import firefox from "selenium-webdriver/firefox.js"; +import { Builder, Capabilities, logging } from "selenium-webdriver"; +import { Options as ChromeOptions } from "selenium-webdriver/chrome.js"; +import { Options as FirefoxOptions } from "selenium-webdriver/firefox.js"; import commandLineArgs from "command-line-args"; import { promises as fs } from "fs"; import path from "path"; @@ -95,9 +95,9 @@ if (options.suite && !VALID_TAGS.includes(options.suite)) printHelp(`Invalid suite: ${options.suite}. Choices are: ${VALID_TAGS.join(", ")}`); const BROWSER = options?.browser; -const IS_HEADLESS = os.platform() === "linux" && !process.env.DISPLAY; if (!BROWSER) printHelp("No browser specified, use $BROWSER or --browser", optionDefinitions); +const IS_HEADLESS = os.platform() === "linux" && !process.env.DISPLAY; let capabilities; let browserOptions; @@ -110,16 +110,16 @@ switch (BROWSER) { case "firefox": { capabilities = Capabilities.firefox() if (IS_HEADLESS) { - browserOptions = new firefox.Options(); - browserOptions = browserOptions.headless(); + browserOptions = new FirefoxOptions(); + browserOptions.addArguments("-headless"); } break; } case "chrome": { capabilities = Capabilities.chrome() if (IS_HEADLESS) { - browserOptions = new chrome.Options(); - browserOptions = browserOptions.headless(); + browserOptions = new ChromeOptions(); + browserOptions.addArguments("--headless"); } break; } From b6196ac47cd4320211e27fc7f26ffcd69112b281 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:16:01 +0100 Subject: [PATCH 08/10] cleanup --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7cc74590..9ab79692 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,7 @@ jobs: run: | echo "Running in $BROWSER" npm run test:${{ matrix.browser }} -- ${{ matrix.suite }} + browser-linux: name: Test Browser on Linux runs-on: ubuntu-latest From 1eaf8e89b55e7d207dead5a4288441a6d5216abe Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:24:43 +0100 Subject: [PATCH 09/10] use anchors --- .github/workflows/test.yml | 61 ++++++++++---------------------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ab79692..bdb31b1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,19 +21,20 @@ jobs: browser: [safari] suite: [default, disabled, main] steps: - - name: Extract Week Number - run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - - name: Checkout Branch + - &checkout-branch + name: Checkout Branch uses: actions/checkout@v5 - - name: Setup Node + - &setup-node + name: Setup Node uses: actions/setup-node@v5 with: node-version-file: package.json cache: npm - - name: Install Node Packages + - &install-node-packages + name: Install Node Packages run: npm ci - name: Run Tests @@ -52,21 +53,9 @@ jobs: browser: [chrome, firefox] suite: [default, disabled, main] steps: - - name: Extract Week Number - run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - - - name: Checkout Branch - uses: actions/checkout@v5 - - - name: Setup Node - uses: actions/setup-node@v5 - with: - node-version-file: package.json - cache: npm - - - name: Install Node Packages - run: npm ci - + - *checkout-branch + - *setup-node + - *install-node-packages - name: Run Tests run: | echo "Running in $BROWSER" @@ -82,21 +71,13 @@ jobs: shell: [jsc, spidermonkey, v8] suite: [default, disabled, main] steps: + - *checkout-branch + - *setup-node + - *install-node-packages + - name: Extract Week Number run: echo "WEEK_NUMBER=$(date +%W)" >> $GITHUB_ENV - - name: Checkout Branch - uses: actions/checkout@v5 - - - name: Setup Node - uses: actions/setup-node@v5 - with: - node-version-file: package.json - cache: npm - - - name: Install Node Packages - run: npm ci - - name: Cache jsvu Binaries uses: actions/cache@v4 with: @@ -111,19 +92,9 @@ jobs: name: Test Build runs-on: ubuntu-latest steps: - - name: Checkout Branch - uses: actions/checkout@v4 - with: - fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: package.json - cache: npm - - - name: Install Node Packages - run: npm ci + - *checkout-branch + - *setup-node + - *install-node-packages - name: Run Build run: | From a8df192839622eb40fdf630746692a1ca791630f Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 30 Oct 2025 16:29:08 +0100 Subject: [PATCH 10/10] fix build branch checkout --- .github/workflows/test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bdb31b1d..a3af087c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -92,7 +92,11 @@ jobs: name: Test Build runs-on: ubuntu-latest steps: - - *checkout-branch + - name: Checkout Branch + uses: actions/checkout@v4 + with: + fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + - *setup-node - *install-node-packages