Skip to content

Commit

Permalink
chore: Moved unit test to Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiomkar committed Jan 10, 2020
1 parent 4cbbe93 commit 3a04dcb
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 406 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,20 @@ jobs:
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 USE_SAUCE=true
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 }}
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ after_script:

matrix:
include:
- 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: 10
env:
- TEST_SUITE=screenshot
Expand Down
28 changes: 10 additions & 18 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.USE_SAUCE);
// 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 @@ -195,14 +193,14 @@ const jasmineConfig = {
module.exports = function(config) {
config.set(Object.assign(USE_JASMINE ? jasmineConfig : mochaConfig, {
logLevel: config.LOG_INFO,
port: 9876,
colors: true,
browsers: browsers,
browserDisconnectTimeout: 40000,
browserNoActivityTimeout: 120000,
captureTimeout: 240000,
concurrency: USING_SL ? 4 : Infinity,
concurrency: USE_SAUCE ? 10 : Infinity,
customLaunchers: customLaunchers,
port: 9876,
}));

if (!USE_JASMINE) {
Expand All @@ -226,24 +224,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 3a04dcb

Please sign in to comment.