diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..cd90ebab --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,16 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npm install + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..aaa36736 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,19 @@ +name: Lint + +on: [push, pull_request] + +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npm install + - run: npm run lint + html: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npm install + - run: git ls-tree --name-only -r HEAD | grep -E "[.](html|css)$" | xargs ./utils/validate diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..5b03504f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test + +on: [push, pull_request] + +jobs: + test: + strategy: + matrix: + os: + - ubuntu-latest + - windows-latest + browser: + - ChromeHeadless + - FirefoxHeadless + include: + - os: macos-latest + browser: Safari + - os: windows-latest + browser: EdgeHeadless + - os: windows-latest + browser: IE + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + - run: npm install + - run: npm run test + env: + TEST_BROWSER_NAME: ${{ matrix.browser }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da51f677..00000000 --- a/.travis.yml +++ /dev/null @@ -1,59 +0,0 @@ -language: node_js -sudo: false -cache: - directories: - - node_modules -node_js: - - lts/* -env: - matrix: - - TEST_BROWSER_NAME=chrome TEST_BROWSER_OS='Windows 10' -# FIXME Skip tests in Linux since Sauce Labs browser versions are ancient. -# - TEST_BROWSER_NAME=chrome TEST_BROWSER_OS='Linux' - - TEST_BROWSER_NAME=chrome TEST_BROWSER_OS='OS X 10.11' - - TEST_BROWSER_NAME=firefox TEST_BROWSER_OS='Windows 10' -# - TEST_BROWSER_NAME=firefox TEST_BROWSER_OS='Linux' - - TEST_BROWSER_NAME=firefox TEST_BROWSER_OS='OS X 10.11' - - TEST_BROWSER_NAME='internet explorer' TEST_BROWSER_OS='Windows 10' - - TEST_BROWSER_NAME='internet explorer' TEST_BROWSER_OS='Windows 7' - - TEST_BROWSER_NAME=microsoftedge TEST_BROWSER_OS='Windows 10' - - TEST_BROWSER_NAME=safari TEST_BROWSER_OS='OS X 10.13' -before_script: npm install -g karma-cli -addons: - sauce_connect: - username: "directxman12" - jwt: - secure: "d3ekMYslpn6R4f0ajtRMt9SUFmNGDiItHpqaXC5T4KI0KMEsxgvEOfJot5PiFFJWg1DSpJZH6oaW2UxGZ3duJLZrXIEd/JePY8a6NtT35BNgiDPgcp+eu2Bu3rhrSNg7/HEsD1ma+JeUTnv18Ai5oMFfCCQJx2J6osIxyl/ZVxA=" -stages: -- lint -- test -- name: deploy - if: tag is PRESENT -jobs: - include: - - stage: lint - env: - addons: - before_script: - script: npm run lint - - - env: - addons: - before_script: - script: git ls-tree --name-only -r HEAD | grep -E "[.](html|css)$" | xargs ./utils/validate - - stage: deploy - env: - addons: - script: skip - before_script: skip - deploy: - provider: npm - skip_cleanup: true - email: ossman@cendio.se - api_key: - secure: "Qq2Mi9xQawO2zlAigzshzMu2QMHvu1IaN9l0ZIivE99wHJj7eS5f4miJ9wB+/mWRRgb3E8uj9ZRV24+Oc36drlBTU9sz+lHhH0uFMfAIseceK64wZV9sLAZm472fmPp2xdUeTCCqPaRy7g1XBqiJ0LyZvEFLsRijqcLjPBF+b8w=" - on: - tags: true - repo: novnc/noVNC - - diff --git a/karma.conf.js b/karma.conf.js index 0e316f1e..c295b1f9 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,48 +1,23 @@ // Karma configuration +// The Safari launcher is broken, so construct our own +function SafariBrowser(id, baseBrowserDecorator, args) { + baseBrowserDecorator(this); + + this._start = function(url) { + this._execCommand('/usr/bin/open', ['-W', '-n', '-a', 'Safari', url]); + } +} + +SafariBrowser.prototype = { + name: 'Safari' +} + module.exports = (config) => { - const customLaunchers = {}; let browsers = []; - let useSauce = false; - // use Sauce when running on Travis - if (process.env.TRAVIS_JOB_NUMBER) { - useSauce = true; - } - - if (useSauce && process.env.TEST_BROWSER_NAME && process.env.TEST_BROWSER_NAME != 'PhantomJS') { - const names = process.env.TEST_BROWSER_NAME.split(','); - const platforms = process.env.TEST_BROWSER_OS.split(','); - const versions = process.env.TEST_BROWSER_VERSION - ? process.env.TEST_BROWSER_VERSION.split(',') - : [null]; - - for (let i = 0; i < names.length; i++) { - for (let j = 0; j < platforms.length; j++) { - for (let k = 0; k < versions.length; k++) { - let launcher_name = 'sl_' + platforms[j].replace(/[^a-zA-Z0-9]/g, '') + '_' + names[i]; - if (versions[k]) { - launcher_name += '_' + versions[k]; - } - - customLaunchers[launcher_name] = { - base: 'SauceLabs', - browserName: names[i], - platform: platforms[j], - }; - - if (versions[i]) { - customLaunchers[launcher_name].version = versions[k]; - } - } - } - } - - browsers = Object.keys(customLaunchers); - } else { - useSauce = false; - //browsers = ['PhantomJS']; - browsers = []; + if (process.env.TEST_BROWSER_NAME) { + browsers = process.env.TEST_BROWSER_NAME.split(','); } const my_conf = { @@ -80,7 +55,11 @@ module.exports = (config) => { exclude: [ ], - customLaunchers: customLaunchers, + plugins: [ + 'karma-*', + '@chiragrupani/karma-chromium-edge-launcher', + { 'launcher:Safari': [ 'type', SafariBrowser ] }, + ], // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher @@ -103,24 +82,7 @@ module.exports = (config) => { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: true, - - // Increase timeout in case connection is slow/we run more browsers than possible - // (we currently get 3 for free, and we try to run 7, so it can take a while) - captureTimeout: 240000, - - // similarly to above - browserNoActivityTimeout: 100000, }; - if (useSauce) { - my_conf.reporters.push('saucelabs'); - my_conf.captureTimeout = 0; // use SL timeout - my_conf.sauceLabs = { - testName: 'noVNC Tests (all)', - startConnect: false, - tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER - }; - } - config.set(my_conf); }; diff --git a/package.json b/package.json index 8ef1ccf5..cf95942f 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,13 @@ "jsdom": "*", "karma": "*", "karma-mocha": "*", + "karma-chrome-launcher": "*", + "@chiragrupani/karma-chromium-edge-launcher": "*", + "karma-firefox-launcher": "*", + "karma-ie-launcher": "*", "karma-mocha-reporter": "*", - "karma-sauce-launcher": "*", + "karma-safari-launcher": "*", + "karma-script-launcher": "*", "karma-sinon-chai": "*", "mocha": "*", "node-getopt": "*",