Commit 188136d9 authored by Eric Eastwood's avatar Eric Eastwood

Merge branch 'migrate-to-gitlab-ci' into 'master'

Migrate to GitLab CI

See merge request !73
parents c3e88e0b b4ec9415
Pipeline #29405803 passed with stages
in 7 minutes and 28 seconds
stages:
- build
- test
- deploy
variables:
# AWS_KEY: See https://console.aws.amazon.com/iam/home?#/users/sidecar-ci?section=security_credentials
# AWS_SECRET: See https://console.aws.amazon.com/iam/home?#/users/sidecar-ci?section=security_credentials
cache:
paths:
- node_modules/
- dist/
build:
stage: build
image: node:8
script:
- npm install
- npm run build
artifacts:
expire_in: 1 week
paths:
- node_modules/
- dist/
test:
stage: test
image: node:8
script:
- npm test
variables:
SELENIUM_REMOTE_URL: http://selenium-server:4444/wd/hub
services:
- name: selenium/standalone-chrome:3.14.0
alias: selenium-server
deploy_prod_microsite_manual:
stage: deploy
image: node:8
only:
- master
# Production is only manual
when: manual
script:
# This handles building, uploading, deploying
- npm run deploy-microsite
environment:
name: microsite-prod
url: https://sidecar.gitter.im/
deploy_prod_script_manual:
stage: deploy
image: node:8
only:
- tags
# Production is only manual
when: manual
script:
# This handles building, uploading, deploying
- npm run deploy-sidecar
environment:
name: script-prod
url: https://sidecar.gitter.im/dist/sidecar.v1.js
# v1.4.0 - 2018-9-4
- Use `rel="noopener"` on external links to isolate Gitter from referrers JavaScript
- Thanks to [@wmhilton](https://gitlab.com/wmhilton) for the contribution, https://gitlab.com/gitlab-org/gitter/sidecar/merge_requests/72
- Migrate project over to GitLab
# v1.3.3 - 2018-2-12
- Only shim `Array.from` when it isn't available natively
......
......@@ -79,6 +79,4 @@ You'll need AWS credentials exported as `AWS_KEY` and `AWS_SECRET`. This command
# Testing
You'll need a BrowserStack username and key, exported as `BS_USER` and `BS_KEY` respectively.
`npm test`
#!/bin/bash
if [[ "$1" == "stop" ]]
then
echo "Stopping browserstack tunnel..."
killall BrowserStackLocal
exit
fi
if [[ ! -e browserstack ]]
then
echo "Downloading browserstack tunnel..."
mkdir -p browserstack
curl https://www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip > browserstack/BrowserStackLocal-linux-x64.zip
cd browserstack && unzip BrowserStackLocal-linux-x64.zip && chmod a+x BrowserStackLocal
cd ..
fi
echo "Browserstack tunnel ready..."
dependencies:
cache_directories:
- browserstack
test:
override:
- npm run build
#- ci/browserstack_tunnel.sh
#- browserstack/BrowserStackLocal -f $BS_KEY $PWD/test/fixtures:
# background: true
#- npm test
#- ci/browserstack_tunnel.sh stop
deployment:
master:
branch: master
owner: gitterHQ
commands:
- npm run deploy-microsite
release:
tag: /v[0-9]+(\.[0-9]+)*/
owner: gitterHQ
commands:
- npm run deploy-sidecar
machine:
node:
version: 4.8.6
This diff is collapsed.
......@@ -9,8 +9,8 @@
},
"scripts": {
"prepublish": "npm run build-module && npm run build",
"test": "gulp move-sidecar-dist-to-fixtures && npm run test-unformatted | tap-spec",
"test-unformatted": "babel-tape-runner test/button_present_test.js",
"test": "gulp move-sidecar-dist-to-fixtures && npm run test-base | tap-spec",
"test-base": "babel-tape-runner test/button_present_test.js",
"devbuild": "webpack --watch --progress",
"build": "webpack -p",
"build-module": "webpack -p --config ./webpack.sidecar-module.config.js",
......@@ -29,7 +29,7 @@
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-tape-runner": "^2.0.0",
"babel-tape-runner": "^2.0.1",
"bluebird": "^3.2.2",
"classnames": "^2.2.3",
"css-loader": "^0.23.1",
......@@ -44,7 +44,6 @@
"gulp-util": "^3.0.6",
"json-loader": "^0.5.4",
"mocha": "^2.4.5",
"npm": "^3.7.2",
"postcss": "^5.0.14",
"postcss-browser-reporter": "^0.4.0",
"postcss-calc": "^5.2.0",
......@@ -63,7 +62,7 @@
"run-sequence": "^1.1.5",
"s3": "^4.4.0",
"safe-tape-runner": "^0.1.3",
"selenium-webdriver": "^2.48.2",
"selenium-webdriver": "^4.0.0-alpha.1",
"serve-static": "^1.10.2",
"style-loader": "^0.13.0",
"tap-spec": "^4.1.1",
......
// See: https://www.browserstack.com/automate/node
// API: http://selenium.googlecode.com/git/docs/api/javascript/index.html
// Capabilities
// - https://www.browserstack.com/automate/capabilities
// - Capability platform/os configurator: https://docs.saucelabs.com/reference/platforms-configurator/#/
//
// How can I use selenium-webdriver package with SauceLabs?: http://stackoverflow.com/q/21170734/796832
// # Setup
//
// ### Set environment variables with your browserstack credentials
// See: http://stackoverflow.com/a/13333312/796832
//
// Windows:
// ```
// set BS_USER=xxx
// set BS_KEY=xxx
// ```
import Promise from 'bluebird';
import assert from 'assert';
import path from 'path';
import objectAssign from 'object-assign';
//var webdriver = require('browserstack-webdriver');
import webdriver from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome';
import test from 'tape';
//var test = require('browserstack-webdriver/testing');
import testingEnvironments from './utility/testing-environments.js';
const options = new chrome.Options();
options.addArguments('headless');
options.addArguments('disable-gpu');
options.addArguments('disable-extensions');
options.addArguments('no-sandbox');
const capabilities = webdriver.Capabilities.chrome();
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.withCapabilities(capabilities)
.build();
let createWebDriver = function({
server = 'http://hub.browserstack.com/wd/hub',
capabilities = {}
}) {
let driver = new webdriver.Builder()
.usingServer(server)
.withCapabilities(capabilities)
.build();
return driver;
};
test('Open Chat Button should be present', function (t) {
t.plan(1);
const getPage = driver.get(`file://${path.join(__dirname, './fixtures/example.html')}`);
const buttonTextExpected = 'open chat';
testingEnvironments.forEach(function(testingEnvironment) {
const testName = `Open Chat Button should be present. in ${testingEnvironment.browserName} on ${testingEnvironment.platform}`;
test(testName, function (t) {
t.plan(1);
let driver = createWebDriver({
capabilities: testingEnvironment
});
const buttonLocator = webdriver.By.css('.gitter-open-chat-button');
let getPage = driver.get(`http://${testingEnvironment['browserstack.user']}.browserstack.com/example.html`);
let buttonLocator = webdriver.By.css('.gitter-open-chat-button');
const openChatButtonExists = getPage.then(function() {
return driver.wait(
webdriver.until.elementLocated(buttonLocator),
20000
);
});
let openChatButtonExists = getPage.then(function() {
return driver.wait(function() {
return driver.isElementPresent(buttonLocator);
}, 10000);
openChatButtonExists
.then(function() {
return driver.findElement(buttonLocator);
})
.then(function(item) {
return Promise.resolve(item.getText());
})
.then(function(text) {
const actualText = text.toLowerCase();
const buttonTextExpected = 'open chat';
assert(actualText, buttonTextExpected, `Expected text to look like ${buttonTextExpected} but actually was ${actualText}`);
})
.then(function() {
t.pass('Successfully ran through selenium tasks');
})
.finally(() => {
driver.quit();
});
openChatButtonExists
.then(function() {
return driver.findElement(buttonLocator);
})
.then(function(item) {
return Promise.resolve(item.getText());
})
.then(function(text) {
let actual = text.toLowerCase();
if(actual !== buttonTextExpected) {
throw new Error(`Failed, expected text to look like ${buttonTextExpected} but actually was ${actual}`);
}
})
.then(function() {
//console.log('driver.quit called');
driver.quit();
t.pass('Successfully ran through selenium tasks');
});
});
});
This diff is collapsed.
import objectAssign from 'object-assign';
let calculatePlatformFromBS = function(capabilities) {
const os = (capabilities.os || '').toLowerCase();
const osVersion = (capabilities.os_version || '').toLowerCase();
if(os === 'windows') {
if(osVersion === '8' || osVersion === '8.1') {
return 'WIN8';
}
else if(osVersion === 'xp') {
return 'XP';
}
return 'WINDOWS';
}
else if(os === 'os x') {
return 'MAC';
}
return 'ANY';
};
const USER = process.env.BS_USER;
const KEY = process.env.BS_KEY;
// See: https://www.browserstack.com/automate/capabilities
const defaultEnvironmentCapabilities = {
// Browser you want to test.
// firefox, chrome, internet explorer, safari, opera, iPad, iPhone, android
browserName: 'chrome',
// Browser version you want to test.
version: 45.0,
// OS you want to test.
// ANY, WINDOWS, WIN8, MAC, and XP.
platform: 'ANY',
// OS you want to test. (BrowserStack-specific)
// WINDOWS, OS X
os: 'Windows',
// OS version you want to test. (BrowserStack-specific)
// Windows: XP, 7, 8 and 8.1
// OS X: Snow Leopard, Lion, Mountain Lion, Mavericks, Yosemite
os_version: '8.1',
screenResolution: '1024x768',
'browserstack.local': true,
'browserstack.debug': true,
'browserstack.user': USER,
'browserstack.key': KEY
};
const testingEnvironments = [
{
browserName: 'chrome',
version: 45.0,
os: 'Windows',
os_version: '8.1'
},
{
browserName: 'chrome',
version: 45.0,
os: 'OS X',
os_version: 'Yosemite'
}
];
export default testingEnvironments.map((envCaps) => {
let capabilities = objectAssign({}, defaultEnvironmentCapabilities, envCaps);
capabilities.platform = calculatePlatformFromBS(capabilities);
return capabilities;
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment