Skip to content

Commit

Permalink
chore: Move tests from Travis to GitHub Actions (material-components#…
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiomkar authored Jan 10, 2020
1 parent 981ec9b commit 910c375
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 409 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: MDC Test

on:
pull_request:
push:
branches:
- master
- develop
- feature/**
pull_request:

jobs:
lint:
Expand All @@ -18,3 +16,38 @@ jobs:
node-version: 10
- run: npm install
- run: npm run lint
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
- run: npm install
- run: npm run dist
site-generator-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
# Node v8 is required.
node-version: 8
- run: npm install
- run: npm run test:site
unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
- run: npm install
- name: Run unit tests
run: |
export SAUCE_BUILD_ID=mdc-tests-${GITHUB_EVENT_NAME}-${GITHUB_ACTION}-${GITHUB_SHA}
export SAUCE_TUNNEL_ID=${SAUCE_BUILD_ID}-tunnel
npm run test:unit
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
23 changes: 0 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ after_script:

matrix:
include:

- node_js: 10
env:
- TEST_SUITE=build
script:
- if has_testable_files; then npm run dist; else log_untestable_files; fi

- node_js: 10
env:
- TEST_SUITE=unit
addons:
sauce_connect: true
script:
- if has_testable_files; then npm run test:unit; else log_untestable_files; fi
after_success:
- codecov

- node_js: 8
env:
- TEST_SUITE=site-generator
script:
- if has_testable_files; then npm run test:site; else log_untestable_files; fi

- node_js: 10
env:
- TEST_SUITE=screenshot
Expand Down
26 changes: 9 additions & 17 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
const path = require('path');
const webpackConfig = require('./webpack.config')[1];

const USING_TRAVISCI = Boolean(process.env.TRAVIS);
const USING_SL = Boolean(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY);
const USE_SAUCE = Boolean(process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY);
// If true, runs new suite of Jasmine foundation unit tests.
// Otherwise, runs old Mocha unit tests.
const USE_JASMINE = Boolean(process.env.USE_JASMINE);
Expand All @@ -38,7 +37,6 @@ const FILES_TO_USE = [
];

const HEADLESS_LAUNCHERS = {
/** See https://github.com/travis-ci/travis-ci/issues/8836#issuecomment-348248951 */
'ChromeHeadlessNoSandbox': {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
Expand All @@ -58,8 +56,8 @@ const SAUCE_LAUNCHERS = {
},
};

const customLaunchers = Object.assign({}, USING_SL ? SAUCE_LAUNCHERS : {}, HEADLESS_LAUNCHERS);
const browsers = USING_TRAVISCI ? Object.keys(customLaunchers) : ['Chrome'];
const customLaunchers = Object.assign({}, USE_SAUCE ? SAUCE_LAUNCHERS : {}, HEADLESS_LAUNCHERS);
const browsers = USE_SAUCE ? Object.keys(customLaunchers) : ['Chrome'];
const istanbulInstrumenterLoader = {
use: [{
loader: 'istanbul-instrumenter-loader',
Expand Down Expand Up @@ -203,7 +201,7 @@ module.exports = function(config) {
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
concurrency: USE_SAUCE ? 10 : Infinity,
customLaunchers: customLaunchers,
}));

Expand All @@ -228,24 +226,18 @@ module.exports = function(config) {
});
}

if (USING_SL) {
if (USE_SAUCE) {
const sauceLabsConfig = {
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
testName: 'Material Components Web Unit Tests - CI',
build: process.env.SAUCE_BUILD_ID,
tunnelIdentifier: process.env.SAUCE_TUNNEL_ID,
};

if (USING_TRAVISCI) {
// See https://github.com/karma-runner/karma-sauce-launcher/issues/73
Object.assign(sauceLabsConfig, {
testName: 'Material Components Web Unit Tests - CI',
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER,
startConnect: false,
});
}

config.set({
sauceLabs: sauceLabsConfig,
// Attempt to de-flake Sauce Labs tests on TravisCI.
// Attempt to de-flake Sauce Labs tests.
transports: ['polling'],
browserDisconnectTolerance: 3,
});
Expand Down
Loading

0 comments on commit 910c375

Please sign in to comment.