diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..07442ed --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,32 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, 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: Node.js CI + +on: + # Test on multiple browsers is relatively heavy. + # Running both on push and PR usually results in running both things twice. + # Also PRs have other goodies e.g. Netlify Previews. + #push: + # branches: [ 'gh-pages' ] + pull_request: + branches: [ '*' ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm ci + - run: npm test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a127f12..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This controls automated builds at Travis & Shippable. - -# http://docs.travis-ci.com/user/migrating-from-legacy -sudo: false - -# By default travis blacklists `gh-pages` branch. We want it tested. -# http://docs.travis-ci.com/user/build-configuration/#Specify-branches-to-build -branches: - only: - - gh-pages - - /.*/ - -language: node_js -# Should test the Node version that runs in production. -# https://docs.travis-ci.com/user/languages/javascript-with-nodejs/#Specifying-Node.js-versions -# https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version -node_js: - - 10 - - 11 - -# http://blog.travis-ci.com/2013-12-05-speed-up-your-builds-cache-your-dependencies/ -cache: - directories: - - node_modules - -after_script: - - printenv - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/738a0684d6f3cc8e35ea - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: false # default: false diff --git a/test/browser-on-saucelabs.spec.coffee b/test/browser-on-saucelabs.spec.coffee index cccb9c5..4cc6ef3 100644 --- a/test/browser-on-saucelabs.spec.coffee +++ b/test/browser-on-saucelabs.spec.coffee @@ -1,6 +1,7 @@ # Usage: By default runs local server, tests it via tunnel; # if SITE_TO_TEST env var is set to a publicly accessible URL, tests that skipping server & tunnel. +util = require('util') SauceLabs = require('saucelabs').default wd = require('wd') # TODO: compare vs http://webdriver.io/ vs webdriverJS chalk = require('chalk') @@ -21,7 +22,8 @@ sauceKey = process.env.SAUCE_ACCESS_KEY || '23056294-abe8-4fe9-8140-df9a59c45c7d # Try to keep all logging indented deeper than Mocha test tree. indentation = ' ' log = (fmt, args...) -> - console.log(indentation + fmt, args...) + text = util.format(fmt, args...) + console.log(text.replace(/^/mg, indentation)) sec = 1000 min = 60*sec @@ -60,7 +62,8 @@ getDesiredBrowsers = -> {browserName: 'MicrosoftEdge'} # arbitrary somewhat old - but not ancient - FF and Chrome versions. {browserName: 'firefox', version: '30.0', platform: 'Linux'} - {browserName: 'chrome', version: '35.0', platform: 'Linux'} + {browserName: 'chrome', version: 'latest', platform: 'Linux'} + {browserName: 'chrome', version: 'latest', platform: 'Windows 10'} {browserName: 'Safari', version: '8.0', platform: 'OS X 10.10'} {browserName: 'Safari', version: 'latest', platform: 'macOS 10.13'} # Mobile (doesn't mean it's usable though): @@ -72,6 +75,7 @@ commonDesired = { build: testMetadata.getBuildInfo() tags: testMetadata.getTags() 'idle-timeout': timeouts.sauceIdle + extendedDebugging: true } log("commonDesired =", commonDesired) @@ -105,6 +109,7 @@ describeBrowserTest = (browserName, getDesired, getSite) -> afterEach -> if not eachPassed allPassed = false + log(if eachPassed then chalk.green('ok') else chalk.red('fail')) # TODO: should I reuse one browser instance for many tests? # From the wd docs reusing one should work but is it isolated enough? @@ -153,7 +158,7 @@ describeBrowserTest = (browserName, getDesired, getSite) -> this.timeout(60*sec) # 30s would be enough if not for mobile? browser.get getSite() + '?doc=_mathdown_test_smoke', (err) -> expect(err).to.be(null) - browser.waitFor wd.asserters.jsCondition('document.title.match(/smoke test/)'), 10*sec, (err, value) -> + browser.waitFor wd.asserters.jsCondition('document.title.match(/smoke test/)'), 30*sec, (err, value) -> expect(err).to.be(null) browser.waitForElementByCss '.MathJax_Display', 30*sec, (err, el) -> expect(err).to.be(null) @@ -195,7 +200,7 @@ runTests = (desiredBrowsers) -> log(chalk.magenta('Creating tunnel...')) actualTunnelId = uuid.v4() tunnel = await sauceLabs.startSauceConnect({ - logger: (stdout) => console.log(chalk.magenta(stdout.trimEnd())), + logger: (stdout) => log(chalk.magenta(stdout.trimEnd().replace(sauceKey, '[REDACTED]'))), tunnelIdentifier: actualTunnelId, }) done() @@ -217,7 +222,7 @@ runTests = (desiredBrowsers) -> main = -> desiredBrowsers = await getDesiredBrowsers() - #console.log('desiredBrowsers =', desiredBrowsers) + log('desiredBrowsers =', desiredBrowsers) runTests(desiredBrowsers) main()