From b083e1d06711c57d6133e503cafa9d5c555b5df0 Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Wed, 3 Aug 2022 11:33:14 +0200 Subject: [PATCH 1/4] Update Karma --- package-lock.json | 18 +++++++++--------- package.json | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d739de4d..dd0ab7b10 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "esm": "^3.2.25", "hash.js": "^1.1.3", "http-server": "^0.12.3", - "karma": "^6.3.17", + "karma": "^6.4.0", "karma-browserstack-launcher": "^1.6.0", "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", @@ -4213,9 +4213,9 @@ } }, "node_modules/karma": { - "version": "6.3.17", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.17.tgz", - "integrity": "sha512-2TfjHwrRExC8yHoWlPBULyaLwAFmXmxQrcuFImt/JsAsSZu1uOWTZ1ZsWjqQtWpHLiatJOHL5jFjXSJIgCd01g==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", + "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", "dev": true, "dependencies": { "@colors/colors": "1.5.0", @@ -4237,7 +4237,7 @@ "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", - "socket.io": "^4.2.0", + "socket.io": "^4.4.1", "source-map": "^0.6.1", "tmp": "^0.2.1", "ua-parser-js": "^0.7.30", @@ -11434,9 +11434,9 @@ } }, "karma": { - "version": "6.3.17", - "resolved": "https://registry.npmjs.org/karma/-/karma-6.3.17.tgz", - "integrity": "sha512-2TfjHwrRExC8yHoWlPBULyaLwAFmXmxQrcuFImt/JsAsSZu1uOWTZ1ZsWjqQtWpHLiatJOHL5jFjXSJIgCd01g==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.1.tgz", + "integrity": "sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA==", "dev": true, "requires": { "@colors/colors": "1.5.0", @@ -11458,7 +11458,7 @@ "qjobs": "^1.2.0", "range-parser": "^1.2.1", "rimraf": "^3.0.2", - "socket.io": "^4.2.0", + "socket.io": "^4.4.1", "source-map": "^0.6.1", "tmp": "^0.2.1", "ua-parser-js": "^0.7.30", diff --git a/package.json b/package.json index 7af118edf..db72400c8 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "esm": "^3.2.25", "hash.js": "^1.1.3", "http-server": "^0.12.3", - "karma": "^6.3.17", + "karma": "^6.4.0", "karma-browserstack-launcher": "^1.6.0", "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", From 18333999a26a095e5eb856304d87e390a59322d4 Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Thu, 16 Feb 2023 17:25:10 +0100 Subject: [PATCH 2/4] CI: test latest browsers without Browserstack, cache build step across jobs --- .github/workflows/benchmark.yml | 2 +- .github/workflows/browserstack.yml | 52 ----- .github/workflows/docs.yml | 4 +- .github/workflows/lint.yml | 19 -- .github/workflows/node.js.yml | 29 --- .github/workflows/test-type-definitions.yml | 19 -- .github/workflows/tests.yml | 186 +++++++++++++++ package-lock.json | 237 ++++++++++++++++++++ package.json | 7 +- test/karma.conf.js | 50 ++--- 10 files changed, 452 insertions(+), 153 deletions(-) delete mode 100644 .github/workflows/browserstack.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/node.js.yml delete mode 100644 .github/workflows/test-type-definitions.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 86e2586e6..8f537a60f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -19,7 +19,7 @@ jobs: with: ref: main path: main - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 - name: Run pull request time benchmark run: cd pr && npm install && npm run --silent benchmark-time > benchmarks.txt && cat benchmarks.txt diff --git a/.github/workflows/browserstack.yml b/.github/workflows/browserstack.yml deleted file mode 100644 index 4313635dd..000000000 --- a/.github/workflows/browserstack.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Test on Browserstack - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - full: - name: Full Build - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: softprops/turnstyle@v1 - with: - poll-interval-seconds: 30 - abort-after-seconds: 900 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-node@v2 - - run: npm ci - - run: npm run build-test - - run: npm run browserstack - - lightweight: - name: Lightweight Build - - needs: full - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: softprops/turnstyle@v1 - with: - poll-interval-seconds: 30 - abort-after-seconds: 900 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/setup-node@v2 - - run: npm ci - - run: npm run build-test --lightweight - - run: npm run browserstack - env: - LIGHTWEIGHT: true - -env: - BROWSERSTACK_USERNAME: danielhuigens2 - BROWSERSTACK_KEY: aW2q1ms393QRorwBnfmW diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8f95ad67f..0a9e8c96a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,6 +14,6 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - - run: npm ci + - uses: actions/setup-node@v3 + - run: npm ci --ignore-scripts - run: npm run docs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 401e0495e..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Lint - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - lint: - name: ESLint - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - - run: npm ci - - run: npm run lint diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index d615b05ef..000000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,29 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Test on Node.js - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build: - name: ${{ matrix.node-version }} - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [14.x, 16.x, 18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test diff --git a/.github/workflows/test-type-definitions.yml b/.github/workflows/test-type-definitions.yml deleted file mode 100644 index a5b0f8513..000000000 --- a/.github/workflows/test-type-definitions.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Types - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - lint: - name: Test type definitions - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 - - run: npm ci - - run: npm run test-type-definitions diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..5feaa21a5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,186 @@ +name: Code Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: # cache both dist and tests (non-lightweight only), based on commit hash + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - name: Check for cached folders + id: cache-full + uses: actions/cache@v3 + with: + path: | + dist + test/lib + key: cache-${{ github.sha }} + - name: Build dist and tests + if: steps.cache-full.outputs.cache-hit != 'true' + run: | + npm ci + npm run build-test + + node: + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + name: Node ${{ matrix.node-version }} + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci --ignore-scripts # for mocha + - name: Retrieve cached folders + uses: actions/cache/restore@v3 + id: cache-full + with: + # test/lib is not needed, but the path must be specified fully for a cache-hit + path: | + dist + test/lib + key: cache-${{ github.sha }} + # ignore cache miss, since it was taken care of the `build` step and it should never occur here + - run: npm test + + test-browsers-latest: + name: Browsers (latest) + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + + - name: Retrieve cached built folders + uses: actions/cache/restore@v3 + id: cache-full + with: + path: | + dist + test/lib + key: cache-${{ github.sha }} + + - name: Install dependencies + # cannot use `--ignore-scripts` since playwright seems to use it to set ENV vars + run: | + npm pkg delete scripts.prepare + npm ci + + - name: Get Playwright version + id: playwright-version + run: | + PLAYWRIGHT_VERSION=$(npm ls playwright | grep playwright | sed 's/.*@//') + echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT + - name: Check for cached browsers + id: cache-playwright-browsers + uses: actions/cache@v3 + with: + path: ~/.cache/ms-playwright + key: playwright-browsers-${{ steps.playwright-version.outputs.version }} + - name: Install browsers + if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' + run: | + npx playwright install-deps chrome + npx playwright install-deps firefox + + - name: Install WebKit # caching not possible, external shared libraries required + run: npx playwright install-deps webkit + + - name: Run browser tests + run: npm run test-browser + + - name: Run browser tests (lightweight) # overwrite test/lib + run: | + npm run build-test --lightweight + npm run test-browser + + test-browsers-compatibility: + name: Browsers (older, on Browserstack) + runs-on: ubuntu-latest + needs: test-browsers-latest + env: # credentials need hardcoding for now since Github secrets aren't accessible on pull requests from forks + BROWSERSTACK_USERNAME: openpgpjs_PlY4Uq885CQ + BROWSERSTACK_ACCESS_KEY: VjgBVRMxNVBj7SjJFiau + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + + - name: Install dependencies + run: npm ci --ignore-scripts + + - name: Retrieve cached dist folder + uses: actions/cache/restore@v3 + id: cache-full + with: + path: | + dist + test/lib + key: cache-${{ github.sha }} + + - name: Wait for other Browserstack tests to finish + uses: softprops/turnstyle@v1 + with: + poll-interval-seconds: 30 + abort-after-seconds: 900 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Run browserstack tests + run: npm run test-browserstack + + - name: Run browserstack tests (lightweight) # overwrite test/lib + run: | + npm run build-test --lightweight + npm run test-browserstack + env: + LIGHTWEIGHT: true + + types: + name: Type definitions + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - run: npm ci --ignore-scripts # TS + - name: Retrieve cached folders + uses: actions/cache/restore@v3 + id: cache-full + with: + path: | + dist + test/lib + key: cache-${{ github.sha }} + - run: npm run test-type-definitions + + lint: + name: ESLint + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + - run: npm ci --ignore-scripts # linter + - name: Retrieve cached folders + uses: actions/cache/restore@v3 + id: cache-full + with: + path: | + dist + test/lib + key: cache-${{ github.sha }} + - run: npm run lint diff --git a/package-lock.json b/package-lock.json index dd0ab7b10..333f6b14d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,10 +39,14 @@ "http-server": "^0.12.3", "karma": "^6.4.0", "karma-browserstack-launcher": "^1.6.0", + "karma-chrome-launcher": "^3.1.1", + "karma-firefox-launcher": "^2.1.2", "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", + "karma-webkit-launcher": "^2.1.0", "mocha": "^8.4.0", "nyc": "^14.1.1", + "playwright": "^1.30.0", "rollup": "^2.38.5", "rollup-plugin-terser": "^7.0.2", "sinon": "^4.3.0", @@ -1323,6 +1327,21 @@ "fsevents": "~2.3.1" } }, + "node_modules/ci-info": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, "node_modules/circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -3654,6 +3673,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-ci": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", + "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", + "dev": true, + "dependencies": { + "ci-info": "^3.2.0" + }, + "bin": { + "is-ci": "bin.js" + } + }, "node_modules/is-core-module": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", @@ -3683,6 +3714,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -3910,6 +3956,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -4264,6 +4322,40 @@ "karma": ">=0.9" } }, + "node_modules/karma-chrome-launcher": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", + "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", + "dev": true, + "dependencies": { + "which": "^1.2.1" + } + }, + "node_modules/karma-firefox-launcher": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", + "dev": true, + "dependencies": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + } + }, + "node_modules/karma-firefox-launcher/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/karma-mocha": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz", @@ -4352,6 +4444,30 @@ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, + "node_modules/karma-webkit-launcher": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/karma-webkit-launcher/-/karma-webkit-launcher-2.1.0.tgz", + "integrity": "sha512-S5eqhH0DIcuJFi27nC6eBxZ3MTrPnYybPthDU2Q8dfG0yFrXx8FqNDKSbRZsFFvAKJ55QVtYH1bbArd3ddI5Sg==", + "dev": true, + "dependencies": { + "is-ci": "^3.0.1", + "uuid": "^9.0.0" + }, + "peerDependenciesMeta": { + "playwright": { + "optional": true + } + } + }, + "node_modules/karma-webkit-launcher/node_modules/uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/karma/node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -6093,6 +6209,34 @@ "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==", "dev": true }, + "node_modules/playwright": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.30.0.tgz", + "integrity": "sha512-ENbW5o75HYB3YhnMTKJLTErIBExrSlX2ZZ1C/FzmHjUYIfxj/UnI+DWpQr992m+OQVSg0rCExAOlRwB+x+yyIg==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "playwright-core": "1.30.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/playwright-core": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.30.0.tgz", + "integrity": "sha512-7AnRmTCf+GVYhHbLJsGUtskWTE33SwMZkybJ0v6rqR1boxq2x36U7p1vDRV7HO2IwTZgmycracLxPEJI49wu4g==", + "dev": true, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", @@ -9134,6 +9278,12 @@ "readdirp": "~3.5.0" } }, + "ci-info": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "dev": true + }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", @@ -11005,6 +11155,15 @@ "dev": true, "peer": true }, + "is-ci": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-3.0.1.tgz", + "integrity": "sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==", + "dev": true, + "requires": { + "ci-info": "^3.2.0" + } + }, "is-core-module": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", @@ -11025,6 +11184,12 @@ "has-tostringtag": "^1.0.0" } }, + "is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true + }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -11189,6 +11354,15 @@ "call-bind": "^1.0.2" } }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -11633,6 +11807,36 @@ "q": "~1.5.0" } }, + "karma-chrome-launcher": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz", + "integrity": "sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ==", + "dev": true, + "requires": { + "which": "^1.2.1" + } + }, + "karma-firefox-launcher": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz", + "integrity": "sha512-VV9xDQU1QIboTrjtGVD4NCfzIH7n01ZXqy/qpBhnOeGVOkG5JYPEm8kuSd7psHE6WouZaQ9Ool92g8LFweSNMA==", + "dev": true, + "requires": { + "is-wsl": "^2.2.0", + "which": "^2.0.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "karma-mocha": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz", @@ -11707,6 +11911,24 @@ } } }, + "karma-webkit-launcher": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/karma-webkit-launcher/-/karma-webkit-launcher-2.1.0.tgz", + "integrity": "sha512-S5eqhH0DIcuJFi27nC6eBxZ3MTrPnYybPthDU2Q8dfG0yFrXx8FqNDKSbRZsFFvAKJ55QVtYH1bbArd3ddI5Sg==", + "dev": true, + "requires": { + "is-ci": "^3.0.1", + "uuid": "^9.0.0" + }, + "dependencies": { + "uuid": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", + "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==", + "dev": true + } + } + }, "klaw": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", @@ -12895,6 +13117,21 @@ "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==", "dev": true }, + "playwright": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.30.0.tgz", + "integrity": "sha512-ENbW5o75HYB3YhnMTKJLTErIBExrSlX2ZZ1C/FzmHjUYIfxj/UnI+DWpQr992m+OQVSg0rCExAOlRwB+x+yyIg==", + "dev": true, + "requires": { + "playwright-core": "1.30.0" + } + }, + "playwright-core": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.30.0.tgz", + "integrity": "sha512-7AnRmTCf+GVYhHbLJsGUtskWTE33SwMZkybJ0v6rqR1boxq2x36U7p1vDRV7HO2IwTZgmycracLxPEJI49wu4g==", + "dev": true + }, "pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", diff --git a/package.json b/package.json index db72400c8..52f0347a1 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "start": "http-server", "prebrowsertest": "npm run build-test", "browsertest": "npm start -- -o test/unittests.html", - "browserstack": "karma start test/karma.conf.js", + "test-browser": "karma start test/karma.conf.js", + "test-browserstack": "karma start test/karma.conf.js --browsers bs_safari_15,bs_ios_15,bs_safari_13_1", "coverage": "nyc npm test", "lint": "eslint .", "docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME", @@ -80,10 +81,14 @@ "http-server": "^0.12.3", "karma": "^6.4.0", "karma-browserstack-launcher": "^1.6.0", + "karma-chrome-launcher": "^3.1.1", + "karma-firefox-launcher": "^2.1.2", "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", + "karma-webkit-launcher": "^2.1.0", "mocha": "^8.4.0", "nyc": "^14.1.1", + "playwright": "^1.30.0", "rollup": "^2.38.5", "rollup-plugin-terser": "^7.0.2", "sinon": "^4.3.0", diff --git a/test/karma.conf.js b/test/karma.conf.js index de6e80aa5..9b9214ca7 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,4 +1,9 @@ /* eslint-disable no-process-env */ +const { chromium, firefox, webkit } = require('playwright'); + +process.env.CHROME_BIN = chromium.executablePath(); +process.env.FIREFOX_BIN = firefox.executablePath(); +process.env.WEBKIT_HEADLESS_BIN = webkit.executablePath(); module.exports = function(config) { config.set({ @@ -14,12 +19,17 @@ module.exports = function(config) { frameworks: ['mocha'], // plugins - plugins: ['karma-mocha', 'karma-mocha-reporter', 'karma-browserstack-launcher'], + plugins: [ + 'karma-mocha', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-webkit-launcher', + 'karma-mocha-reporter', + 'karma-browserstack-launcher' + ], client: { mocha: { - reporter: 'html', - ui: 'bdd', timeout: 30000, grep: process.env.LIGHTWEIGHT ? '@lightweight' : undefined } @@ -76,7 +86,7 @@ module.exports = function(config) { browserStack: { username: process.env.BROWSERSTACK_USERNAME, - accessKey: process.env.BROWSERSTACK_KEY, + accessKey: process.env.BROWSERSTACK_ACCESS_KEY, build: process.env.GITHUB_SHA, name: process.env.GITHUB_WORKFLOW, project: `openpgpjs/${process.env.GITHUB_EVENT_NAME || 'push'}${process.env.LIGHTWEIGHT ? '/lightweight' : ''}`, @@ -85,24 +95,10 @@ module.exports = function(config) { // define browsers customLaunchers: { - bs_firefox_85: { - base: 'BrowserStack', - browser: 'Firefox', - browser_version: '85.0', - os: 'OS X', - os_version: 'Big Sur' - }, - bs_chrome_88: { - base: 'BrowserStack', - browser: 'Chrome', - browser_version: '88.0', - os: 'OS X', - os_version: 'Big Sur' - }, - bs_safari_14: { + bs_safari_15: { // Webkit and Safari can differ in behavior base: 'BrowserStack', browser: 'Safari', - browser_version: '14.0', + browser_version: '15', os: 'OS X', os_version: 'Big Sur' }, @@ -113,12 +109,12 @@ module.exports = function(config) { os: 'OS X', os_version: 'Catalina' }, - bs_ios_14: { + bs_ios_15: { base: 'BrowserStack', - device: 'iPhone 12', + device: 'iPhone 13', real_mobile: true, os: 'ios', - os_version: '14' + os_version: '15' } }, @@ -130,13 +126,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: [ - 'bs_firefox_85', - 'bs_chrome_88', - 'bs_safari_13_1', - 'bs_safari_14', - 'bs_ios_14' - ], + browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits From dcd28fadc6f39a679c6ba012237b5a13a39b72ab Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Mon, 20 Feb 2023 15:26:15 +0100 Subject: [PATCH 3/4] CI: test latest Safari --- package.json | 2 +- test/karma.conf.js | 6 +++--- test/unittests.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 52f0347a1..cfea2fe34 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "prebrowsertest": "npm run build-test", "browsertest": "npm start -- -o test/unittests.html", "test-browser": "karma start test/karma.conf.js", - "test-browserstack": "karma start test/karma.conf.js --browsers bs_safari_15,bs_ios_15,bs_safari_13_1", + "test-browserstack": "karma start test/karma.conf.js --browsers bs_safari_latest,bs_ios_15,bs_safari_13_1", "coverage": "nyc npm test", "lint": "eslint .", "docs": "jsdoc --configure .jsdocrc.js --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME", diff --git a/test/karma.conf.js b/test/karma.conf.js index 9b9214ca7..a9dd4907a 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -95,12 +95,12 @@ module.exports = function(config) { // define browsers customLaunchers: { - bs_safari_15: { // Webkit and Safari can differ in behavior + bs_safari_latest: { // Webkit and Safari can differ in behavior base: 'BrowserStack', browser: 'Safari', - browser_version: '15', + browser_version: 'latest', os: 'OS X', - os_version: 'Big Sur' + os_version: 'Ventura' }, bs_safari_13_1: { // no BigInt support base: 'BrowserStack', diff --git a/test/unittests.js b/test/unittests.js index dc34eaf46..b8e43a1e1 100644 --- a/test/unittests.js +++ b/test/unittests.js @@ -31,9 +31,9 @@ describe('Unit Tests', function () { openpgp.config.s2kIterationCountByte = 0; if (typeof window !== 'undefined') { - // Safari 14.1.* seem to have issues handling rejections when their native TransformStream implementation is involved, + // Safari 14.1.*, 15.* and 16.* seem to have issues handling rejections when their native TransformStream implementation is involved, // so for now we ignore unhandled rejections for those browser versions. - if (!window.navigator.userAgent.match(/Version\/14\.1(\.\d)* Safari/)) { + if (!window.navigator.userAgent.match(/Version\/1(4|5|6)\.\d(\.\d)* Safari/)) { window.addEventListener('unhandledrejection', function (event) { throw event.reason; }); From 66844826c6eedc16c9f28063423e3ebeff316d81 Mon Sep 17 00:00:00 2001 From: larabr <7375870+larabr@users.noreply.github.com> Date: Fri, 17 Feb 2023 15:27:07 +0100 Subject: [PATCH 4/4] Skip native Crypto tests if native lib is not available --- test/crypto/eax.js | 6 ++++++ test/crypto/rsa.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test/crypto/eax.js b/test/crypto/eax.js index b7280b048..d46fa57a6 100644 --- a/test/crypto/eax.js +++ b/test/crypto/eax.js @@ -125,6 +125,7 @@ function testAESEAX() { }); } +/* eslint-disable no-invalid-this */ module.exports = () => describe('Symmetric AES-EAX', function() { let sinonSandbox; let getWebCryptoStub; @@ -142,6 +143,11 @@ module.exports = () => describe('Symmetric AES-EAX', function() { }; describe('Symmetric AES-EAX (native)', function() { + before(function () { + const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto()); + if (!detectNative()) { this.skip(); } + }); + beforeEach(function () { sinonSandbox = sandbox.create(); enableNative(); diff --git a/test/crypto/rsa.js b/test/crypto/rsa.js index bc2e81c9e..daae61a66 100644 --- a/test/crypto/rsa.js +++ b/test/crypto/rsa.js @@ -25,6 +25,8 @@ module.exports = () => describe('basic RSA cryptography', function () { sinonSandbox.restore(); }); + const detectNative = () => !!(util.getWebCrypto() || util.getNodeCrypto()); + const disableNative = () => { enableNative(); // stubbed functions return undefined @@ -105,6 +107,8 @@ module.exports = () => describe('basic RSA cryptography', function () { }); it('compare native crypto and bnSign', async function() { + if (!detectNative()) { this.skip(); } + const bits = 1024; const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const { n, e, d, p, q, u } = { ...publicParams, ...privateParams }; @@ -120,6 +124,8 @@ module.exports = () => describe('basic RSA cryptography', function () { }); it('compare native crypto and bnVerify', async function() { + if (!detectNative()) { this.skip(); } + const bits = 1024; const { publicParams, privateParams } = await crypto.generateParams(openpgp.enums.publicKey.rsaSign, bits); const { n, e, d, p, q, u } = { ...publicParams, ...privateParams };