Skip to content

Commit

Permalink
Merge pull request #112 from chaijs/fix-karma-job-number
Browse files Browse the repository at this point in the history
fix(karma): ensure job number reflects CI environment
  • Loading branch information
meeber authored Nov 8, 2017
2 parents 49b7062 + fe0a49e commit faad27b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ jobs:
- QUICKLY_TEST_BROWSERS_AVAILABLE_IN_CI=1 # kept here for easier reading of build log
- stage: test
addons:
sauce_connect: true
sauce_connect:
username: "chaijs-type-detect"
jwt:
secure: "GhkIK785QJbB1G5qwf51zpoJkHibS8wBhibID2jCL6TmQ8ZUHmihN2qnjuRvCI80uosHqkCBi3CeBYZIika5QFsg6LVVf5dnme7Qs0UkG+mw45yO6vcKycxbn1Bo5X8hqdtSjF/x+C91Wr4lelr5w/Sq2X7RokfE0fDVdklE5xQ="
script:
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -z "$SAUCE_USERNAME" ]; then echo "Cannot run tests without SAUCE_USERNAME"; exit 1; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then echo "SauceLabs tests do not run in builds of pull requests. This build will now exit"; exit 0; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -n "$SAUCE_USERNAME" ]; then npm run test:browser; fi'
- npm run test:browser
env:
- TEST_BROWSERS_IN_SAUCELABS=1 # kept here for easier reading of build log
- secure: AgiUWRCNP2z0oHCjdm3lk4YawBOQz8Q4DOrzOR3tDt2fSWo2t40cynfGJlQwpFmTvec5G04lO9bEC9/yoW7xAS0ysu5p7utngXaKtKDoq3Zr0aYLLLsCv/0PAv1YstMyo/mRbRetxob76wUFcrbB3r5alIF5YW1JCmj/O9bvdUQ=
- secure: TepAZmznoPWUX12snu2eb7Sni+31tiOO6ZeU3wovrhCpGzykBNr6xAvUklr88L+uKtvfsTq8sipX0jtZvL7lcIEzujirTpjaj4QV5mUFiV2N40o+C3LdNmfmU9dhUcXRu9vMSs9uc7YfPers4We8X99UxTHxljK7VyJe39ULpRk=
- SAUCE_USERNAME="chaijs-type-detect"
- SAUCE_CONNECT_READY_FILE=/tmp/sauce-connect-ready
- stage: test
node_js: 8 # to be removed 2019-12-01
Expand Down
28 changes: 17 additions & 11 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
const packageJson = require('./package.json');
/* eslint-disable no-process-env */
let job = process.env.JOB_NUMBER || Date.now();
let browsers = [ 'ChromeHeadless' ];
let build = 'localbuild';
let branch = 'local';
let job = Date.now();
let startConnect = false;
const reporters = [ 'progress', 'coverage' ];
const tags = [ `${ packageJson.name }@${ packageJson.version }` ];
const frameworks = [ 'mocha' ];

/* eslint-disable no-process-env */
const debug = Boolean(process.env.npm_config_debug);
if (process.env.SAUCE_ACCESS_KEY && process.env.SAUCE_USERNAME) {

if (process.env.SAUCE_USERNAME) {
browsers = [ 'SauceEdgeLatest', 'SauceInternetExplorerTen', 'SauceSafariLatest' ];
tags.push(`${ process.env.SAUCE_USERNAME }@${ branch }`);
reporters.push('saucelabs');
startConnect = true;
} else if (process.env.APPVEYOR) {
browsers = [ 'Firefox', 'ChromeHeadless', 'IE' ];
branch = process.env.APPVEYOR_REPO_BRANCH;
job = process.env.APPVEYOR_JOB_NUMBER;
build = `appveyor@${ process.env.APPVEYOR_JOB_NUMBER }`;
} else if (process.env.TRAVIS) {
browsers = [ 'FirefoxHeadless', 'ChromeHeadless' ];
branch = process.env.TRAVIS_BRANCH;
job = process.env.TRAVIS_JOB_NUMBER;
build = `travis@${ process.env.TRAVIS_JOB_NUMBER }`;
startConnect = true;
} else if (!process.env.KARMA_MANUAL) {
browsers = [];
frameworks.push('detectBrowsers');
}

if (process.env.APPVEYOR) {
branch = process.env.APPVEYOR_REPO_BRANCH;
build = `appveyor@${ process.env.APPVEYOR_JOB_NUMBER }`;
job = process.env.APPVEYOR_JOB_NUMBER;
} else if (process.env.TRAVIS) {
branch = process.env.TRAVIS_BRANCH;
build = `travis@${ process.env.TRAVIS_JOB_NUMBER }`;
job = process.env.TRAVIS_JOB_NUMBER;
// Travis has its own saucelabs connect process, so ensure karma won't run it
startConnect = false;
}
/* eslint-enable */

tags.push(build);
Expand Down

0 comments on commit faad27b

Please sign in to comment.