Skip to content

Commit

Permalink
Fixes to run on LambdaTest (#1752)
Browse files Browse the repository at this point in the history
Mukesh changes:

* Fixing the tests to run on LambdaTest via Github actions

* adding env

* browser update

* modify command with exit

* kill the tunnel process after tests

* try with chrome

* updating addons

* integration test

dfahlander's changes:

* Trying without max-parallel

* Replacing date with github.run_number for unique tunnel

* Debug log LT_TUNNEL_NAME

* Trying with run_id

* Trying with $RANDOM

* Trying with $(($RANDOM))

* Trying with $GITHUB_ENV

* Random worked perfectly - but now testing with a
better approach if possible.

* Moving down SET LT_TUNNEL_NAME to where it needed

* Refactored tests

* Running safari test on browserstack to see if it
also fails there

* Trying again with browserstack safari

* Setting max-parallel: 1

* See if idbtrans.commit() is the safari problem

* Testing if cache is the safari problem

* Revert this! Test if order is the safari problem

* Revert "Revert this! Test if order is the safari problem"

This reverts commit 880eee7.

* Revert "Testing if cache is the safari problem"

This reverts commit e2241a7.

* Revert "See if idbtrans.commit() is the safari problem"

This reverts commit 2eed798.

* Testing with Monterey instead

* Enabling LAMBDATEST

* Testing with Safari 15

* Trying with browserstack on Safari 15

* Workaround unit tests for Safari Private Mode

* Enabling Lambdatests again

* Remove browserstack vars (should not be needed)

* Allow 2 parallell tests (see if it works)

* Try run all 5 tests in parallell to speed up CI

* Removing all deps of browserstack

* Upgrading browsers to test on

* Trying with MacOS Ventura as platformName

---------

Co-authored-by: dfahlander <[email protected]>
  • Loading branch information
mukesh-lt and dfahlander authored Dec 11, 2023
1 parent 3e79816 commit 82f3a99
Show file tree
Hide file tree
Showing 32 changed files with 183 additions and 431 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ name: Build and Test
on: [push, workflow_dispatch]

env:
#LAMBDATEST: "true" # Uncomment this line to run tests on LambdaTest instead of Browserstack
LAMBDATEST: "true"
GH_ACTIONS: "true"
LT_USERNAME: ${{ secrets.LT_USERNAME }}
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}

jobs:
test:
Expand All @@ -22,7 +20,7 @@ jobs:
- addons/dexie-export-import/test
- libs/dexie-react-hooks/test
fail-fast: true # If one test fails, abort the rest of the tests
max-parallel: 1 # At least for browserstack, this seems to be needed to avoid timeouts
max-parallel: 5 # At least for browserstack, this seems to be needed to avoid timeouts
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -39,6 +37,8 @@ jobs:
run: pnpm install --no-frozen-lockfile
- name: Build
run: pnpm run build
- name: Set LT_TUNNEL_NAME
run: echo "LT_TUNNEL_NAME=${{ matrix.TF }}-${{ github.run_id }}-${{ github.run_attempt }}" >> $GITHUB_ENV
- name: Run headless test
uses: coactions/setup-xvfb@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,7 @@ samples/typescript/utils.js.map
/.ntvs_analysis.dat
/*.njsproj
libs/dexie-cloud-common/tsconfig.tsbuildinfo

#lambdatest tunnel binary
.lambdatest
tunnel.pid
5 changes: 4 additions & 1 deletion addons/Dexie.Observable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
"test:integration": "karma start test/integration/karma.conf.js --single-run",
"test:typings": "just-build test-typings",
"test:unit:debug": "karma start test/unit/karma.conf.js --log-level debug",
"test:integration:debug": "karma start test/integrations/karma.conf.js --log-level debug"
"test:integration:debug": "karma start test/integrations/karma.conf.js --log-level debug",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test:unit; UNIT_STATUS=$?; exit $UNIT_STATUS",
"test:ltTunnel": "node ../../test/lt-local",
"test:ltcloud:integration": "cross-env LAMBDATEST=true pnpm run test:integration; UNIT_STATUS=$?; kill $(cat tunnel.pid); exit $UNIT_STATUS"
},
"just-build": {
"default": [
Expand Down
4 changes: 2 additions & 2 deletions addons/Dexie.Observable/test/gh-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ echo "Installing dependencies for dexie-observable"
pnpm install >/dev/null
pnpm run build
pnpm run test:typings
pnpm run test:unit
pnpm run test:integration
pnpm run test:ltcloud
pnpm run test:ltcloud:integration
4 changes: 2 additions & 2 deletions addons/Dexie.Observable/test/integration/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../..
module.exports = function (config) {
const browserMatrixOverrides = {
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["remote_chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"remote_chrome",
]
};

Expand Down
4 changes: 2 additions & 2 deletions addons/Dexie.Observable/test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../..
module.exports = function (config) {
const browserMatrixOverrides = {
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["remote_chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"remote_chrome",
]
};

Expand Down
5 changes: 4 additions & 1 deletion addons/Dexie.Syncable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"test:integration": "karma start test/integration/karma.conf.js --single-run",
"test:typings": "tsc -p test/test-typings/",
"test:unit:debug": "karma start test/unit/karma.conf.js --log-level debug",
"test:integration:debug": "karma start test/integrations/karma.conf.js --log-level debug"
"test:integration:debug": "karma start test/integrations/karma.conf.js --log-level debug",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test:unit; UNIT_STATUS=$?; exit $UNIT_STATUS",
"test:ltTunnel": "node ../../test/lt-local",
"test:ltcloud:integration": "cross-env LAMBDATEST=true pnpm run test:integration; UNIT_STATUS=$?; kill $(cat tunnel.pid); exit $UNIT_STATUS"
},
"just-build": {
"default": [
Expand Down
4 changes: 2 additions & 2 deletions addons/Dexie.Syncable/test/gh-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ echo "Building dexie-syncable"
pnpm run build

pnpm run test:typings
pnpm run test:unit
pnpm run test:integration
pnpm run test:ltcloud
pnpm run test:ltcloud:integration
4 changes: 2 additions & 2 deletions addons/Dexie.Syncable/test/integration/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../..
module.exports = function (config) {
const browserMatrixOverrides = {
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["remote_chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"remote_chrome",
]
};

Expand Down
4 changes: 2 additions & 2 deletions addons/Dexie.Syncable/test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../..
module.exports = function (config) {
const browserMatrixOverrides = {
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["remote_chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"remote_chrome",
]
};

Expand Down
1 change: 0 additions & 1 deletion addons/dexie-cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"dreambase-library": "^1.0.21",
"just-build": "*",
"karma": "*",
"karma-browserstack-launcher": "*",
"karma-chrome-launcher": "*",
"karma-firefox-launcher": "*",
"karma-qunit": "*",
Expand Down
4 changes: 2 additions & 2 deletions addons/dexie-cloud/test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../..
module.exports = function (config) {
const browserMatrixOverrides = {
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["Chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"Chrome",
]
};

Expand Down
4 changes: 3 additions & 1 deletion addons/dexie-export-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"test": "just-build test && npx karma start test/karma.conf.js --single-run",
"build": "just-build",
"watch": "just-build --watch",
"clean": "rm -rf tools/tmp dist/*.js dist/*.mjs dist/*.map dist/*.d.ts test/bundle.*"
"clean": "rm -rf tools/tmp dist/*.js dist/*.mjs dist/*.map dist/*.d.ts test/bundle.*",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test; UNIT_STATUS=$?; kill $(cat tunnel.pid); exit $UNIT_STATUS",
"test:ltTunnel": "node ../../test/lt-local"
},
"just-build": {
"default": [
Expand Down
2 changes: 1 addition & 1 deletion addons/dexie-export-import/test/gh-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ n=1
until [ $n -ge 4 ]
do
echo "Retry $n of 3"
pnpm test && exit 0
pnpm test:ltcloud && exit 0
n=$[$n+1]
done
exit 1
4 changes: 2 additions & 2 deletions addons/dexie-export-import/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../te
module.exports = function (config) {
const cfg = getKarmaConfig({
// Be fine with testing on local travis firefox + browserstack chrome, latest supported.
ci: ["bs_chrome_latest_supported"],
ci: ["Chrome"],
// Safari fails to reply on browserstack. Need to not have it here.
// Just complement with old chrome browser that is not part of CI test suite.
pre_npm_publish: [
"bs_chrome_latest_supported",
"Chrome",
]
}, {
// Base path should point at the root
Expand Down
4 changes: 3 additions & 1 deletion libs/dexie-react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"typings": "dist/dexie-react-hooks.d.ts",
"scripts": {
"test": "just-build build-tests && just-build run-tests",
"build": "just-build"
"build": "just-build",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test; UNIT_STATUS=$?; kill $(cat tunnel.pid); exit $UNIT_STATUS",
"test:ltTunnel": "node ../../test/lt-local"
},
"exports": {
"import": "./dist/dexie-react-hooks.mjs",
Expand Down
2 changes: 1 addition & 1 deletion libs/dexie-react-hooks/test/gh-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
echo "Installing dependencies for dexie-react-hooks"
pnpm install >/dev/null
echo "Building and running the tests"
pnpm test
pnpm test:ltcloud

6 changes: 1 addition & 5 deletions libs/dexie-react-hooks/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
const {karmaCommon, getKarmaConfig, defaultBrowserMatrix} = require('../../../test/karma.common');

module.exports = function (config) {
const cfg = getKarmaConfig({
// Be fine with testing on local Firefox only (no browserstack). This lib is not sensitive to browser differences.
ci: ["Firefox"],
pre_npm_publish: ["Firefox"]
}, {
const cfg = getKarmaConfig({}, {
basePath: '..',
files: [
'test/dist/bundle.js'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"test:unit": "karma start test/karma.conf.js --single-run",
"test:typings": "tsc -p test/typings-test/",
"test:debug": "karma start test/karma.conf.js --log-level debug",
"test:ltcloud": "cross-env LAMBDATEST=true npm run test:ltTunnel & sleep 10 && npm run test:unit",
"test:ltcloud": "cross-env LAMBDATEST=true pnpm run test:ltTunnel & sleep 10 && pnpm run test:unit; UNIT_STATUS=$?; kill $(cat tunnel.pid); exit $UNIT_STATUS",
"test:ltTunnel": "node test/lt-local"
},
"just-build": {
Expand Down Expand Up @@ -116,10 +116,10 @@
"homepage": "https://dexie.org",
"devDependencies": {
"@lambdatest/node-tunnel": "^4.0.1",
"cross-env": "^7.0.3",
"dts-bundle-generator": "^5.9.0",
"just-build": "^0.9.24",
"karma": "^6.1.1",
"karma-browserstack-launcher": "^1.5.2",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^2.1.0",
"karma-mocha-reporter": "^2.2.5",
Expand Down
Loading

0 comments on commit 82f3a99

Please sign in to comment.