Use GitHub actions instead of Travis/Sauce Labs

The ability to use Sauce Labs for pull requests has now stopped working,
as Travis warned about several years ago. Instead run our tests directly
on GitHub on their various virtual machines.
This commit is contained in:
Pierre Ossman 2020-06-23 13:56:33 +02:00
parent 643442feac
commit 2835616b75
6 changed files with 91 additions and 118 deletions

16
.github/workflows/deploy.yml vendored Normal file
View File

@ -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}}

19
.github/workflows/lint.yml vendored Normal file
View File

@ -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

30
.github/workflows/test.yml vendored Normal file
View File

@ -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 }}

View File

@ -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

View File

@ -1,48 +1,23 @@
// Karma configuration // 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) => { module.exports = (config) => {
const customLaunchers = {};
let browsers = []; let browsers = [];
let useSauce = false;
// use Sauce when running on Travis if (process.env.TEST_BROWSER_NAME) {
if (process.env.TRAVIS_JOB_NUMBER) { browsers = process.env.TEST_BROWSER_NAME.split(',');
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 = [];
} }
const my_conf = { const my_conf = {
@ -80,7 +55,11 @@ module.exports = (config) => {
exclude: [ exclude: [
], ],
customLaunchers: customLaunchers, plugins: [
'karma-*',
'@chiragrupani/karma-chromium-edge-launcher',
{ 'launcher:Safari': [ 'type', SafariBrowser ] },
],
// start these browsers // start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
@ -103,24 +82,7 @@ module.exports = (config) => {
// Continuous Integration mode // Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits // if true, Karma captures browsers, runs the tests and exits
singleRun: true, 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); config.set(my_conf);
}; };

View File

@ -60,8 +60,13 @@
"jsdom": "*", "jsdom": "*",
"karma": "*", "karma": "*",
"karma-mocha": "*", "karma-mocha": "*",
"karma-chrome-launcher": "*",
"@chiragrupani/karma-chromium-edge-launcher": "*",
"karma-firefox-launcher": "*",
"karma-ie-launcher": "*",
"karma-mocha-reporter": "*", "karma-mocha-reporter": "*",
"karma-sauce-launcher": "*", "karma-safari-launcher": "*",
"karma-script-launcher": "*",
"karma-sinon-chai": "*", "karma-sinon-chai": "*",
"mocha": "*", "mocha": "*",
"node-getopt": "*", "node-getopt": "*",