Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use GitHub Actions #207

Open
wants to merge 11 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

15 changes: 10 additions & 5 deletions test/browser-on-saucelabs.spec.coffee
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand All @@ -72,6 +75,7 @@ commonDesired = {
build: testMetadata.getBuildInfo()
tags: testMetadata.getTags()
'idle-timeout': timeouts.sauceIdle
extendedDebugging: true
}
log("commonDesired =", commonDesired)

Expand Down Expand Up @@ -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?
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -217,7 +222,7 @@ runTests = (desiredBrowsers) ->

main = ->
desiredBrowsers = await getDesiredBrowsers()
#console.log('desiredBrowsers =', desiredBrowsers)
log('desiredBrowsers =', desiredBrowsers)
runTests(desiredBrowsers)

main()
Expand Down