Skip to content

Commit

Permalink
build: add browserstack test environments (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation authored Jul 15, 2019
1 parent 1c231fd commit 16010ad
Show file tree
Hide file tree
Showing 16 changed files with 301 additions and 355 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cache: npm

script:
- npm run build:libs
- if [ "$TRAVIS_TAG" == "" ]; then npm run test; fi
- if [ "$TRAVIS_TAG" == "" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then npm run test; fi
- if [ "$TRAVIS_TAG" == "" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then npm run test:pr; fi
- if [ "$TRAVIS_TAG" == "" ]; then npm run lint; fi
- if [ "$TRAVIS_TAG" == "" ]; then npm run sonar; fi
- npm run build:angular-showcase
Expand Down
63 changes: 40 additions & 23 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@
]
},
"configurations": {
"pr": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless,FirefoxHeadless",
"sourceMap": false,
"preserveSymlinks": false
},
"ci": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless",
"browsers": "ChromeHeadless,FirefoxHeadless,BsChrome,BsFirefox",
"sourceMap": false,
"preserveSymlinks": false
}
Expand Down Expand Up @@ -181,21 +188,19 @@
}
},
"configurations": {
"ci": {
"pr": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless",
"browsers": "ChromeHeadless,FirefoxHeadless",
"sourceMap": false,
"progress": false
},
"local": {
"codeCoverage": true
},
"datepicker": {
"main": "projects/sbb-esta/angular-public/src/lib/datepicker/test.ts"
},
"toggle": {
"main": "projects/sbb-esta/angular-public/src/lib/datepicker/test.ts"
"ci": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless,FirefoxHeadless,BsChrome,BsFirefox",
"sourceMap": false,
"progress": false
}
}
},
Expand Down Expand Up @@ -244,15 +249,19 @@
}
},
"configurations": {
"ci": {
"pr": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless",
"browsers": "ChromeHeadless,FirefoxHeadless",
"sourceMap": false,
"progress": false
},
"local": {
"codeCoverage": true
"ci": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless,FirefoxHeadless,BsChrome,BsFirefox",
"sourceMap": false,
"progress": false
}
}
},
Expand Down Expand Up @@ -296,15 +305,19 @@
"karmaConfig": "projects/sbb-esta/angular-icons/karma.conf.js"
},
"configurations": {
"ci": {
"pr": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless",
"browsers": "ChromeHeadless,FirefoxHeadless",
"sourceMap": false,
"progress": false
},
"local": {
"codeCoverage": true
"ci": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless,FirefoxHeadless,BsChrome,BsFirefox",
"sourceMap": false,
"progress": false
}
}
},
Expand Down Expand Up @@ -349,15 +362,19 @@
"karmaConfig": "projects/sbb-esta/angular-keycloak/karma.conf.js"
},
"configurations": {
"ci": {
"pr": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless",
"browsers": "ChromeHeadless,FirefoxHeadless",
"sourceMap": false,
"progress": false
},
"local": {
"codeCoverage": true
"ci": {
"watch": false,
"codeCoverage": true,
"browsers": "ChromeHeadless,FirefoxHeadless,BsChrome,BsFirefox",
"sourceMap": false,
"progress": false
}
}
},
Expand Down
14 changes: 14 additions & 0 deletions browsers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"BsChrome": {
"base": "BrowserStack",
"os": "Windows",
"os_version": "10",
"browser": "Chrome"
},
"BsFirefox": {
"base": "BrowserStack",
"os": "Windows",
"os_version": "10",
"browser": "Firefox"
}
}
33 changes: 12 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
"build:angular-showcase:ng": "ng build angular-showcase --prod",
"build:angular-showcase:license": "copyfiles LICENSE ./dist/angular-showcase/",
"build:angular-showcase:packagejson": "cd projects/angular-showcase && copyfiles package.json ../../dist/angular-showcase",
"test": "run-s test:angular-public",
"test": "run-s test:angular-business test:angular-public test:angular-keycloak",
"test:angular-business": "ng test @sbb-esta/angular-business -c ci",
"test:angular-public": "ng test @sbb-esta/angular-public -c ci",
"test:angular-keycloak": "ng test @sbb-esta/angular-keycloak -c ci",
"test:angular-showcase": "ng test angular-showcase -c ci",
"test:pr": "run-s test:pr:angular-business test:pr:angular-public test:pr:angular-keycloak",
"test:pr:angular-business": "ng test @sbb-esta/angular-business -c pr",
"test:pr:angular-public": "ng test @sbb-esta/angular-public -c pr",
"test:pr:angular-keycloak": "ng test @sbb-esta/angular-keycloak -c pr",
"test:pr:angular-showcase": "ng test angular-showcase -c pr",
"sonar": "node ./scripts/sonar.js",
"changelog": "standard-version --tag-prefix=\"\"",
"publish:staging": "node ./scripts/publish.js",
Expand Down Expand Up @@ -134,7 +139,7 @@
"karma-jasmine-html-reporter": "^0.2.2",
"karma-junit-reporter": "^1.2.0",
"karma-parallel": "^0.3.1",
"karma-sonarqube-reporter": "^1.2.3",
"karma-sonarqube-reporter": "^1.2.4",
"karma-sourcemap-loader": "^0.3.7",
"lint-staged": "^8.2.1",
"lodash": "^4.17.11",
Expand Down
20 changes: 5 additions & 15 deletions projects/sbb-esta/angular-business/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,7 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
BsChrome: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'Chrome'
},
BsFirefox: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'Firefox'
}
},
customLaunchers: require('../../../browsers.json'),
singleRun: false,
// Try Websocket for a faster transmission first. Fallback to polling if necessary.
transports: ['websocket', 'polling'],
Expand All @@ -67,6 +54,10 @@ module.exports = function(config) {
});

if (process.env.TRAVIS) {
config.reporters = config.reporters
.filter(r => r !== 'progress' && r !== 'kjhtml')
.concat('dots');

// This defines how often a given browser should be launched in the same Travis
// container. This is helpful if we want to shard tests across the same browser.
const parallelBrowserInstances = Number(process.env.KARMA_PARALLEL_BROWSERS) || 1;
Expand All @@ -83,7 +74,6 @@ module.exports = function(config) {
}

if (process.env.BROWSERSTACK_USERNAME && process.env.BROWSERSTACK_ACCESS_KEY) {
config.browsers.push('BsCrhome', 'BsFirefox');
config.browserDisconnectTimeout = 180000;
config.browserDisconnectTolerance = 3;
config.captureTimeout = 180000;
Expand Down
Loading

0 comments on commit 16010ad

Please sign in to comment.