mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-03-30 15:08:32 +00:00
Merge pull request #1794
This commit is contained in:
commit
d7f5736d67
36
.github/workflows/tests.yml
vendored
36
.github/workflows/tests.yml
vendored
@ -57,8 +57,15 @@ jobs:
|
||||
|
||||
test-browsers-latest:
|
||||
name: Browsers (latest)
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false # if tests for one version fail, continue with the rest
|
||||
matrix:
|
||||
# run on all main platforms to test platform-specific code, if present
|
||||
# (e.g. webkit's WebCrypto API implementation is different in macOS vs Linux)
|
||||
# TODO: windows-latest fails to fetch resources from the wtr server; investigate if the problem is with path declaration or permissions
|
||||
runner: ['ubuntu-latest', 'macos-latest']
|
||||
runs-on: ${{ matrix.runner }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -79,17 +86,19 @@ jobs:
|
||||
npm pkg delete scripts.prepare
|
||||
npm ci
|
||||
|
||||
- name: Get Playwright version
|
||||
- name: Get Playwright version and cache location
|
||||
id: playwright-version
|
||||
run: |
|
||||
PLAYWRIGHT_VERSION=$(npm ls playwright | grep playwright | sed 's/.*@//')
|
||||
PLAYWRIGHT_VERSION=$(npm ls playwright --depth=0 | grep playwright | sed 's/.*@//')
|
||||
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
|
||||
PLAYWRIGHT_CACHE=${{ fromJSON('{"ubuntu-latest": "~/.cache/ms-playwright", "macos-latest": "~/Library/Caches/ms-playwright"}')[matrix.runner] }}
|
||||
echo "playwright_cache=$PLAYWRIGHT_CACHE" >> $GITHUB_OUTPUT
|
||||
- name: Check for cached browsers
|
||||
id: cache-playwright-browsers
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: playwright-browsers-${{ steps.playwright-version.outputs.version }}
|
||||
path: ${{ steps.playwright-version.outputs.playwright_cache }}
|
||||
key: playwright-browsers-${{ matrix.runner }}-${{ steps.playwright-version.outputs.version }}
|
||||
- name: Install browsers
|
||||
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
@ -100,12 +109,12 @@ jobs:
|
||||
run: npx playwright install --with-deps webkit
|
||||
|
||||
- name: Run browser tests
|
||||
run: npm run test-browser
|
||||
run: npm run test-browser:ci -- --static-logging
|
||||
|
||||
- name: Run browser tests (lightweight) # overwrite test/lib
|
||||
run: |
|
||||
npm run build-test --lightweight
|
||||
npm run test-browser
|
||||
npm run test-browser:ci -- --static-logging
|
||||
|
||||
test-browsers-compatibility:
|
||||
name: Browsers (older, on Browserstack)
|
||||
@ -119,6 +128,15 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
|
||||
- name: Generate self-signed HTTPS certificates for web-test-runner server
|
||||
uses: kofemann/action-create-certificate@v0.0.4
|
||||
with:
|
||||
hostcert: '127.0.0.1.pem'
|
||||
hostkey: '127.0.0.1-key.pem'
|
||||
cachain: 'ca-chain.pem'
|
||||
- name: Adjust HTTPS certificates permissions
|
||||
run: sudo chown runner:docker *.pem
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --ignore-scripts
|
||||
|
||||
@ -139,12 +157,12 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run browserstack tests
|
||||
run: npm run test-browserstack
|
||||
run: npm run test-browserstack -- --static-logging
|
||||
|
||||
- name: Run browserstack tests (lightweight) # overwrite test/lib
|
||||
run: |
|
||||
npm run build-test --lightweight
|
||||
npm run test-browserstack
|
||||
npm run test-browserstack -- --static-logging
|
||||
env:
|
||||
LIGHTWEIGHT: true
|
||||
|
||||
|
@ -667,7 +667,7 @@ To create your own build of the library, just run the following command after cl
|
||||
|
||||
npm install && npm test
|
||||
|
||||
For debugging browser errors, you can run `npm start` and open [`http://localhost:8080/test/unittests.html`](http://localhost:8080/test/unittests.html) in a browser, or run the following command:
|
||||
For debugging browser errors, run the following command:
|
||||
|
||||
npm run browsertest
|
||||
|
||||
|
5702
package-lock.json
generated
5702
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@ -49,11 +49,11 @@
|
||||
"test-type-definitions": "tsx test/typescript/definitions.ts",
|
||||
"benchmark-time": "node test/benchmarks/time.js",
|
||||
"benchmark-memory-usage": "node test/benchmarks/memory_usage.js",
|
||||
"start": "http-server",
|
||||
"prebrowsertest": "npm run build-test",
|
||||
"browsertest": "npm start -- -o test/unittests.html",
|
||||
"test-browser": "karma start test/karma.conf.cjs",
|
||||
"test-browserstack": "karma start test/karma.conf.cjs --browsers bs_safari_latest,bs_ios_14,bs_safari_14",
|
||||
"browsertest": "web-test-runner --config test/web-test-runner.config.js --group local --manual --open",
|
||||
"test-browser": "web-test-runner --config test/web-test-runner.config.js --group local --playwright --browsers chromium firefox webkit",
|
||||
"test-browser:ci": "web-test-runner --config test/web-test-runner.config.js --group headless:ci",
|
||||
"test-browserstack": "web-test-runner --config test/web-test-runner.browserstack.config.js",
|
||||
"coverage": "c8 npm test",
|
||||
"lint": "eslint .",
|
||||
"docs": "jsdoc --configure .jsdocrc.cjs --destination docs --recurse README.md src && printf '%s' 'docs.openpgpjs.org' > docs/CNAME",
|
||||
@ -79,6 +79,10 @@
|
||||
"@types/chai": "^4.3.19",
|
||||
"@types/sinon": "^17.0.3",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@web/test-runner": "^0.19.0",
|
||||
"@web/test-runner-browserstack": "^0.7.2",
|
||||
"@web/test-runner-mocha": "^0.9.0",
|
||||
"@web/test-runner-playwright": "^0.11.0",
|
||||
"argon2id": "^1.0.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"bn.js": "^5.2.1",
|
||||
@ -95,14 +99,6 @@
|
||||
"eslint-plugin-import": "^2.30.0",
|
||||
"eslint-plugin-unicorn": "^48.0.1",
|
||||
"fflate": "^0.7.4",
|
||||
"http-server": "^14.1.1",
|
||||
"karma": "^6.4.4",
|
||||
"karma-browserstack-launcher": "^1.6.0",
|
||||
"karma-chrome-launcher": "^3.2.0",
|
||||
"karma-firefox-launcher": "^2.1.3",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-mocha-reporter": "^2.2.5",
|
||||
"karma-webkit-launcher": "^2.6.0",
|
||||
"mocha": "^10.7.3",
|
||||
"playwright": "^1.47.0",
|
||||
"rollup": "^4.21.2",
|
||||
@ -113,6 +109,9 @@
|
||||
"typescript": "^5.5.4",
|
||||
"web-streams-polyfill": "^4.0.0"
|
||||
},
|
||||
"overrides": {
|
||||
"@web/dev-server-core": "npm:@openpgp/wtr-dev-server-core@0.7.3-patch.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/openpgpjs/openpgpjs"
|
||||
|
@ -1,136 +0,0 @@
|
||||
/* 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({
|
||||
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: '..',
|
||||
|
||||
// hostname for local
|
||||
hostname: '127.0.0.1',
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ['mocha'],
|
||||
|
||||
// plugins
|
||||
plugins: [
|
||||
'karma-mocha',
|
||||
'karma-chrome-launcher',
|
||||
'karma-firefox-launcher',
|
||||
'karma-webkit-launcher',
|
||||
'karma-mocha-reporter',
|
||||
'karma-browserstack-launcher'
|
||||
],
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
timeout: 30000,
|
||||
grep: process.env.LIGHTWEIGHT ? '@lightweight' : undefined
|
||||
}
|
||||
},
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: [
|
||||
{
|
||||
pattern: 'test/lib/unittests-bundle.js',
|
||||
type: 'module'
|
||||
},
|
||||
{
|
||||
pattern: 'dist/**/*',
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: 'test/**/*',
|
||||
included: false
|
||||
}
|
||||
],
|
||||
|
||||
proxies: {
|
||||
'/lib': '/base/test/lib',
|
||||
'/worker': '/base/test/worker',
|
||||
'/dist': '/base/dist'
|
||||
},
|
||||
|
||||
// list of files to exclude
|
||||
exclude: [
|
||||
],
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
},
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ['mocha', 'BrowserStack'],
|
||||
|
||||
// web server host and port
|
||||
port: 9876,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
browserStack: {
|
||||
username: process.env.BROWSERSTACK_USERNAME,
|
||||
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' : ''}`,
|
||||
timeout: 450
|
||||
},
|
||||
|
||||
// define browsers
|
||||
customLaunchers: {
|
||||
bs_safari_latest: { // Webkit and Safari can differ in behavior
|
||||
base: 'BrowserStack',
|
||||
browser: 'Safari',
|
||||
browser_version: 'latest',
|
||||
os: 'OS X',
|
||||
os_version: 'Ventura'
|
||||
},
|
||||
bs_safari_14: {
|
||||
base: 'BrowserStack',
|
||||
browser: 'Safari',
|
||||
browser_version: '14',
|
||||
os: 'OS X',
|
||||
os_version: 'Big Sur'
|
||||
},
|
||||
bs_ios_14: {
|
||||
base: 'BrowserStack',
|
||||
device: 'iPhone 12',
|
||||
real_mobile: true,
|
||||
os: 'ios',
|
||||
os_version: '14'
|
||||
}
|
||||
},
|
||||
|
||||
captureTimeout: 6e5,
|
||||
browserDisconnectTolerance: 0,
|
||||
browserDisconnectTimeout: 6e5,
|
||||
browserSocketTimeout: 3e5,
|
||||
browserNoActivityTimeout: 6e5,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
browsers: ['ChromeHeadless', 'FirefoxHeadless', 'WebkitHeadless'],
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true
|
||||
|
||||
});
|
||||
};
|
@ -3,38 +3,38 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>OpenPGPJS Unit Tests</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
|
||||
<!-- libs -->
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
mocha.timeout(240000);
|
||||
</script>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<script type="module">
|
||||
import './lib/unittests-bundle.js';
|
||||
if (typeof openpgp !== 'undefined') {
|
||||
const runner = mocha.run();
|
||||
var wasScrolledDown = true;
|
||||
function beforeTestReport() {
|
||||
wasScrolledDown = document.documentElement.scrollHeight - document.documentElement.scrollTop - document.documentElement.clientHeight < 50;
|
||||
}
|
||||
function afterTestReport() {
|
||||
if (wasScrolledDown || openpgp.config.ci) {
|
||||
window.scrollTo(0, document.documentElement.scrollHeight);
|
||||
}
|
||||
}
|
||||
runner._events['suite'].unshift(beforeTestReport);
|
||||
runner._events['pass'].unshift(beforeTestReport);
|
||||
runner._events['fail'].unshift(beforeTestReport);
|
||||
runner._events['pending'].unshift(beforeTestReport);
|
||||
document.addEventListener('scroll', beforeTestReport);
|
||||
runner.on('suite', afterTestReport);
|
||||
runner.on('test end', afterTestReport);
|
||||
import { mocha, sessionFinished, sessionFailed } from '@web/test-runner-mocha';
|
||||
|
||||
try {
|
||||
// setup mocha
|
||||
mocha.setup({
|
||||
ui: 'bdd',
|
||||
timeout: 45000
|
||||
});
|
||||
|
||||
// Safari 14 does not support top-level await
|
||||
import('./lib/unittests-bundle.js')
|
||||
.then(() => {
|
||||
// run the tests, and notify the test runner after finishing
|
||||
mocha.run(() => {
|
||||
sessionFinished();
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
// notify the test runner about errors
|
||||
sessionFailed(err);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
// notify the test runner about errors
|
||||
sessionFailed(error);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
49
test/web-test-runner.browserstack.config.js
Normal file
49
test/web-test-runner.browserstack.config.js
Normal file
@ -0,0 +1,49 @@
|
||||
import { browserstackLauncher } from '@web/test-runner-browserstack';
|
||||
import wtrConfig from './web-test-runner.config.js';
|
||||
|
||||
const sharedBrowserstackCapabilities = {
|
||||
'browserstack.user': process.env.BROWSERSTACK_USERNAME,
|
||||
'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
|
||||
project: `openpgpjs/${process.env.GITHUB_EVENT_NAME || 'push'}${process.env.LIGHTWEIGHT ? '/lightweight' : ''}`,
|
||||
name: process.env.GITHUB_WORKFLOW || 'local',
|
||||
build: process.env.GITHUB_SHA || 'local',
|
||||
'browserstack.acceptInsecureCerts': true
|
||||
};
|
||||
|
||||
export default {
|
||||
...wtrConfig,
|
||||
protocol: 'https:',
|
||||
http2: true,
|
||||
sslKey: './127.0.0.1-key.pem',
|
||||
sslCert: './127.0.0.1.pem',
|
||||
testsStartTimeout: 45000,
|
||||
browserStartTimeout: 120000,
|
||||
testsFinishTimeout: 450000,
|
||||
concurrentBrowsers: 3,
|
||||
concurrency: 1, // see https://github.com/modernweb-dev/web/issues/2706
|
||||
coverage: false,
|
||||
groups: [], // overwrite the field coming from `wrtConfig`
|
||||
browsers: [
|
||||
browserstackLauncher({
|
||||
capabilities: {
|
||||
...sharedBrowserstackCapabilities,
|
||||
browserName: 'Safari iOS 14',
|
||||
device: 'iPhone 12',
|
||||
real_mobile: true,
|
||||
os: 'ios',
|
||||
os_version: '14' // min supported version (iOS/Safari < 14 does not support native BigInts)
|
||||
}
|
||||
}),
|
||||
browserstackLauncher({
|
||||
capabilities: {
|
||||
...sharedBrowserstackCapabilities,
|
||||
browserName: 'Safari iOS latest',
|
||||
device: 'iPhone 16',
|
||||
real_mobile: true,
|
||||
os: 'ios',
|
||||
os_version: 'latest'
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
39
test/web-test-runner.config.js
Normal file
39
test/web-test-runner.config.js
Normal file
@ -0,0 +1,39 @@
|
||||
import { playwrightLauncher } from '@web/test-runner-playwright';
|
||||
|
||||
const sharedPlaywrightCIOptions = {
|
||||
// createBrowserContext: ({ browser }) => browser.newContext({ ignoreHTTPSErrors: true }),
|
||||
headless: true
|
||||
};
|
||||
|
||||
export default {
|
||||
nodeResolve: true, // to resolve npm module imports in `unittests.html`
|
||||
files: './test/unittests.html',
|
||||
protocol: 'http:',
|
||||
hostname: '127.0.0.1',
|
||||
testsStartTimeout: 45000,
|
||||
browserStartTimeout: 120000,
|
||||
testsFinishTimeout: 450000,
|
||||
concurrentBrowsers: 3,
|
||||
concurrency: 1, // see https://github.com/modernweb-dev/web/issues/2706
|
||||
coverage: false,
|
||||
groups: [
|
||||
{ name: 'local' }, // group meant to be used with either --browser or --manual options via CLI
|
||||
{
|
||||
name: 'headless:ci',
|
||||
browsers: [
|
||||
playwrightLauncher({
|
||||
...sharedPlaywrightCIOptions,
|
||||
product: 'chromium'
|
||||
}),
|
||||
playwrightLauncher({
|
||||
...sharedPlaywrightCIOptions,
|
||||
product: 'firefox'
|
||||
}),
|
||||
playwrightLauncher({
|
||||
...sharedPlaywrightCIOptions,
|
||||
product: 'webkit'
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user