Skip to content

Commit

Permalink
Fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
hieu-w committed Jan 24, 2025
1 parent 12d04bf commit 502da69
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 24 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
# This workflow contains a single job called "build"
base:
# The type of runner that the job will run on
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -53,11 +53,11 @@ jobs:
- name: check build size webpack
run: npm run size:webpack

- name: check build size browserify
run: npm run size:browserify
# - name: check build size browserify
# run: npm run size:browserify

- name: check build size rollup
run: npm run size:rollup
# - name: check build size rollup
# run: npm run size:rollup

- name: code format
run: npm run lint
Expand All @@ -82,7 +82,7 @@ jobs:


# run the node test in an own task, so we can use a node-version matrix.
test-node:
test:
runs-on: ubuntu-20.04
strategy:
matrix:
Expand Down Expand Up @@ -120,6 +120,12 @@ jobs:
- name: test node
run: npm run test:node

- name: Install playwright webkit
run: npx playwright install-deps webkit

- name: test browser
run: npx playwright install && npm run test:browser


# TODO this does not work atm. fix this.
# - name: test electron
Expand Down
5 changes: 4 additions & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable prettier/prettier */


const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
mode: 'production',
entry: './dist/lib/browserify.index.js',
entry: './dist/lib/browser.js',
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
Expand Down
8 changes: 7 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ export default [
// ignore files
ignores: [
// ignore eslint for testcafe, since relative plugin is not working
"test/e2e.test.js"
"test/e2e.test.js",

// disable eslint for config files
"config/**/*.js",

// dist
"dist/**/*.js",
],
},
];
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@
"test:electron": "(cd ./test-electron && npm run test)",
"size:prewebpack": "cross-env NODE_ENV=build webpack --config ./config/webpack.config.js",
"size:webpack": "npm run size:prewebpack && echo \"Build-Size Webpack (minified+gzip):\" && gzip-size --raw ./test_tmp/webpack.bundle.js",
"size:browserify": "rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browserify.index.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size browserify (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js",
"size:browserify": "rimraf test_tmp/browserify.js && browserify --no-builtins dist/lib/browser.js > test_tmp/browserify.js && uglifyjs --compress --mangle --output test_tmp/browserify.min.js -- test_tmp/browserify.js && echo \"Build-Size browserify (minified+gzip):\" && gzip-size --raw test_tmp/browserify.min.js",
"size:rollup": "rollup --config ./config/rollup.config.js && echo \"Build-Size Rollup (minified+gzip):\" && gzip-size --raw ./test_tmp/rollup.bundle.js",
"lint": "eslint src test --cache",
"clear": "rimraf -rf ./dist && rimraf -rf ./gen",
"build:es6node": "rimraf -rf dist/esnode && cross-env NODE_ENV=es6 babel src --out-dir dist/esnode",
"build:es6browser": "rimraf -rf dist/esbrowser && cross-env NODE_ENV=es6 babel src --out-dir dist/esbrowser && grep -rl NodeMethod dist/esbrowser/ | xargs sed -i '' 's/.*NodeMethod.*//'",
"build:es6browser": "rimraf -rf dist/esbrowser && cross-env NODE_ENV=es6 babel src --out-dir dist/esbrowser",
"build:es5node": "cross-env NODE_ENV=es5 babel src --out-dir dist/es5node",
"build:es5browser": "cross-env NODE_ENV=es5 babel src --out-dir dist/lib && grep -rl NodeMethod dist/lib/ | xargs sed -i '' 's/.*NodeMethod.*//'",
"build:es5browser": "cross-env NODE_ENV=es5 babel src --out-dir dist/lib",
"build:test": "cross-env NODE_ENV=es5 babel test --out-dir test_tmp",
"build:index": "browserify test_tmp/scripts/index.js > docs/index.js",
"build:browser": "browserify test_tmp/scripts/e2e.js > docs/e2e.js",
Expand All @@ -60,7 +60,7 @@
"build:lib-browser": "browserify dist/lib/index.js -p esmify > dist/lib/browser.js",
"build:lib-browser:min": "uglifyjs --compress --mangle --output dist/lib/browser.min.js -- dist/lib/browser.js",
"build": "npm run clear && npm run build:publish && concurrently \"npm run build:es6node\" \"npm run build:es6browser\" \"npm run build:es5browser\" \"npm run build:test\" && concurrently \"npm run build:index\" \"npm run build:browser\" \"npm run build:worker\" \"npm run build:iframe\" && npm run build:lib-browser && npm run build:lib-browser:min",
"build:min": "uglifyjs --compress --mangle --output dist/lib/browserify.min.js -- dist/lib/browserify.index.js",
"build:min": "uglifyjs --compress --mangle --output dist/lib/browserify.min.js -- dist/lib/browser.js",
"docs:only": "http-server ./docs --silent",
"docs:serve": "npm run build && echo \"Open http://localhost:8080/\" && npm run docs:only",
"build:publish": "torus-scripts build"
Expand Down
24 changes: 14 additions & 10 deletions src/methods/indexed-db.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,21 @@ export function getMessagesHigherThan(db, lastCursorId) {
}

export function removeMessagesById(db, ids) {
const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS);
const objectStore = tx.objectStore(OBJECT_STORE_ID);
try {
const tx = db.transaction([OBJECT_STORE_ID], "readwrite", TRANSACTION_SETTINGS);
const objectStore = tx.objectStore(OBJECT_STORE_ID);

return Promise.all(
ids.map((id) => {
const deleteRequest = objectStore.delete(id);
return new Promise((resolve) => {
deleteRequest.onsuccess = () => resolve();
});
})
);
return Promise.all(
ids.map((id) => {
const deleteRequest = objectStore.delete(id);
return new Promise((resolve) => {
deleteRequest.onsuccess = () => resolve();
});
})
);
} catch (e) {
console.error(e);
}
}

export function getOldMessages(db, ttl) {
Expand Down
6 changes: 5 additions & 1 deletion test/scripts/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ function run() {
};

if (autoStart && autoStart !== '') {
window[autoStart]();
if (window !== undefined && window.hasOwnProperty(autoStart)) {
window[autoStart]();
} else {
console.log('window is undefined');
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://stackoverflow.com/a/901144/3443137
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
name = name.replace(/[\\[\]]/g, "\\$&");
const regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
const results = regex.exec(url);
if (!results) return null;
Expand Down

0 comments on commit 502da69

Please sign in to comment.