chore(screenshotter): support Browserstack and test on Safari 13.1 (#2306)
* Support Browserstack in screenshotter * Support Browserstack in CircleCI * Test screenshots on Safari 13.1 * Don't run Safari screenshotter on forked PRs * Update a screenshot * Ignore *.log in .gitignore
@@ -1,6 +1,9 @@
|
||||
version: 2.1
|
||||
|
||||
executors:
|
||||
node:
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
firefox:
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
@@ -44,10 +47,19 @@ commands:
|
||||
- .yarn
|
||||
- .pnp.js
|
||||
|
||||
screenshot:
|
||||
parameters:
|
||||
flags:
|
||||
type: string
|
||||
default: ""
|
||||
steps:
|
||||
- run:
|
||||
name: Verify screenshots and generate diffs and new screenshots
|
||||
command: yarn node dockers/screenshotter/screenshotter.js -b $CIRCLE_JOB --verify --diff --new << parameters.flags >>
|
||||
|
||||
jobs:
|
||||
test:
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
executor: node
|
||||
steps:
|
||||
- run:
|
||||
name: Check whether the build is running on the main repository
|
||||
@@ -80,6 +92,9 @@ jobs:
|
||||
parameters:
|
||||
browser:
|
||||
type: executor
|
||||
browserstack:
|
||||
type: string
|
||||
default: ""
|
||||
executor: << parameters.browser >>
|
||||
steps:
|
||||
- checkout_repo
|
||||
@@ -87,9 +102,17 @@ jobs:
|
||||
filter: '^docs/|^static/|^website/|^LICENSE|\.md$'
|
||||
- install_dependencies
|
||||
|
||||
- run:
|
||||
name: Verify screenshots and generate diffs and new screenshots
|
||||
command: yarn node dockers/screenshotter/screenshotter.js --selenium-ip localhost -b $CIRCLE_JOB --verify --diff --new
|
||||
- when:
|
||||
condition: << parameters.browserstack >>
|
||||
steps:
|
||||
- screenshot:
|
||||
flags: --browserstack --selenium-capabilities '<< parameters.browserstack >>'
|
||||
- unless:
|
||||
condition: << parameters.browserstack >>
|
||||
steps:
|
||||
- screenshot:
|
||||
flags: --selenium-ip localhost
|
||||
|
||||
- store_artifacts:
|
||||
path: test/screenshotter/new
|
||||
destination: new
|
||||
@@ -107,3 +130,17 @@ workflows:
|
||||
- screenshotter:
|
||||
name: chrome
|
||||
browser: chrome
|
||||
- screenshotter:
|
||||
name: safari
|
||||
browser: node
|
||||
browserstack: |
|
||||
{
|
||||
"browserName": "Safari",
|
||||
"browser_version": "13.1",
|
||||
"os": "OS X",
|
||||
"os_version": "Catalina"
|
||||
}
|
||||
filters:
|
||||
branches:
|
||||
# Forked pull requests don't have access to Browserstack credentials
|
||||
ignore: /pull\/[0-9]+/
|
||||
|
3
.gitignore
vendored
@@ -1,8 +1,7 @@
|
||||
katex.tar.gz
|
||||
katex.zip
|
||||
node_modules
|
||||
npm-debug.log
|
||||
debug.log
|
||||
*.log
|
||||
last.png
|
||||
diff.png
|
||||
/.npm-install.stamp
|
||||
|
@@ -15,6 +15,8 @@ const istanbulLibCoverage = require('istanbul-lib-coverage');
|
||||
const istanbulLibReport = require('istanbul-lib-report');
|
||||
const istanbulReports = require('istanbul-reports');
|
||||
|
||||
const browserstack = require('browserstack-local');
|
||||
|
||||
const webpack = require('webpack');
|
||||
const WebpackDevServer = require("webpack-dev-server");
|
||||
const webpackConfig = require("../../webpack.dev")[0];
|
||||
@@ -59,6 +61,9 @@ const opts = require("commander")
|
||||
"Retry this many times before reporting failure", 5, parseInt)
|
||||
.option("--wait <secs>",
|
||||
"Wait this many seconds between page load and screenshot", parseFloat)
|
||||
.option("--browserstack", "Use Browserstack. The username and access key"
|
||||
+ " should be set as enviroment variable BROWSERSTACK_USER and"
|
||||
+ " BROWSERSTACK_ACCESS_KEY")
|
||||
.parse(process.argv);
|
||||
|
||||
let listOfCases;
|
||||
@@ -81,6 +86,24 @@ let katexURL = opts.katexUrl;
|
||||
let katexIP = opts.katexIp;
|
||||
let katexPort = opts.katexPort;
|
||||
|
||||
let bsLocal;
|
||||
if (opts.browserstack) {
|
||||
// https://www.browserstack.com/automate/node
|
||||
if (!seleniumURL) {
|
||||
seleniumURL = "http://hub-cloud.browserstack.com/wd/hub";
|
||||
}
|
||||
// https://www.browserstack.com/local-testing/automate#test-localhost-websites
|
||||
if (!katexIP && opts.browser === "safari") {
|
||||
katexIP = "bs-local.com";
|
||||
}
|
||||
opts.seleniumCapabilities = Object.assign({
|
||||
resolution: "1280x1024",
|
||||
"browserstack.user": process.env.BROWSERSTACK_USER,
|
||||
"browserstack.key": process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
"browserstack.local": true,
|
||||
}, opts.seleniumCapabilities);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Work out connection to selenium docker container
|
||||
|
||||
@@ -188,7 +211,7 @@ function startServer() {
|
||||
devServer = wds;
|
||||
katexPort = port;
|
||||
attempts = 0;
|
||||
process.nextTick(tryConnect);
|
||||
process.nextTick(opts.browserstack ? startBrowserstackLocal : tryConnect);
|
||||
});
|
||||
server.on("error", function(err) {
|
||||
if (devServer !== null) { // error after we started listening
|
||||
@@ -201,6 +224,21 @@ function startServer() {
|
||||
});
|
||||
}
|
||||
|
||||
// Start Browserstack Local connection
|
||||
function startBrowserstackLocal() {
|
||||
// unique identifier for the session
|
||||
const localIdentifier = process.env.CIRCLE_BUILD_NUM || "p" + katexPort;
|
||||
opts.seleniumCapabilities["browserstack.localIdentifier"] = localIdentifier;
|
||||
|
||||
bsLocal = new browserstack.Local();
|
||||
bsLocal.start({localIdentifier}, function(err) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
process.nextTick(tryConnect);
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Wait for container to become ready
|
||||
|
||||
@@ -546,7 +584,13 @@ function takeScreenshot(key) {
|
||||
function done() {
|
||||
// devServer.close(cb) will take too long.
|
||||
driver.quit().then(() => {
|
||||
process.exit(exitStatus);
|
||||
if (bsLocal) {
|
||||
bsLocal.stop(() => {
|
||||
process.exit(exitStatus);
|
||||
});
|
||||
} else {
|
||||
process.exit(exitStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ cleanup() {
|
||||
container=
|
||||
trap cleanup EXIT
|
||||
status=0
|
||||
for browserTag in firefox:2.48.2 chrome:2.48.2; do
|
||||
for browserTag in firefox:3.141.59-20200525 chrome:3.141.59-20200525; do
|
||||
browser=${browserTag%:*}
|
||||
image=selenium/standalone-${browserTag}
|
||||
echo "Starting container for ${image}"
|
||||
@@ -34,4 +34,22 @@ for browserTag in firefox:2.48.2 chrome:2.48.2; do
|
||||
echo "${res} taking screenshots, stopping and removing ${container:0:12}"
|
||||
cleanup
|
||||
done
|
||||
|
||||
if [[ $BROWSERSTACK_USER ]]; then
|
||||
echo "Creating screenshots for Safari..."
|
||||
if yarn node "$(dirname "$0")"/screenshotter.js \
|
||||
--browser=safari --browserstack --selenium-capabilities '{
|
||||
"browserName": "Safari",
|
||||
"browser_version": "13.1",
|
||||
"os": "OS X",
|
||||
"os_version": "Catalina"
|
||||
}' "$@"; then
|
||||
res=Done
|
||||
else
|
||||
res=Failed
|
||||
status=1
|
||||
fi
|
||||
echo "${res} taking screenshots"
|
||||
fi
|
||||
|
||||
exit ${status}
|
||||
|
@@ -34,6 +34,7 @@
|
||||
"babel-plugin-version-inline": "^1.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"browserslist": "^4.13.0",
|
||||
"browserstack-local": "^1.4.5",
|
||||
"caniuse-lite": "^1.0.30001102",
|
||||
"codecov": "^3.7.1",
|
||||
"css-loader": "^4.0.0",
|
||||
|
BIN
test/screenshotter/images/Accents-safari.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
test/screenshotter/images/AccentsText-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/Align-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/Aligned-safari.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
test/screenshotter/images/Alignedat-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/ArrayMode-safari.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
test/screenshotter/images/ArrayRemoveEmptyLine-safari.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
test/screenshotter/images/ArrayType-safari.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
test/screenshotter/images/Arrays-safari.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
test/screenshotter/images/Baseline-safari.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
test/screenshotter/images/BasicTest-safari.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
test/screenshotter/images/BinCancellation-safari.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
test/screenshotter/images/BinomTest-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/BoldSpacing-safari.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
test/screenshotter/images/BoldSymbol-safari.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
test/screenshotter/images/Boxed-safari.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
test/screenshotter/images/Cases-safari.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
test/screenshotter/images/ColorImplicit-safari.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
test/screenshotter/images/ColorSpacing-safari.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
test/screenshotter/images/Colorbox-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/Colors-safari.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
test/screenshotter/images/DashesAndQuotes-safari.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/screenshotter/images/DeepFontSizing-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/DelimiterSizing-safari.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
test/screenshotter/images/DisplayMode-safari.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
test/screenshotter/images/DisplayStyle-safari.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
test/screenshotter/images/Dots-safari.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
test/screenshotter/images/Equation-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/Exponents-safari.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
test/screenshotter/images/ExtensibleArrows-safari.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/screenshotter/images/FractionTest-safari.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/screenshotter/images/Functions-safari.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
test/screenshotter/images/Gather-safari.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
test/screenshotter/images/Gathered-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/GreekLetters-safari.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
test/screenshotter/images/GreekUnicode-safari.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
test/screenshotter/images/GroupMacros-safari.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
test/screenshotter/images/HTML-safari.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
test/screenshotter/images/HorizontalBraces-safari.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
test/screenshotter/images/Includegraphics-safari.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
test/screenshotter/images/Integrands-safari.png
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
test/screenshotter/images/KaTeX-safari.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
test/screenshotter/images/Kern-safari.png
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
test/screenshotter/images/LaTeX-safari.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
test/screenshotter/images/Lap-safari.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
test/screenshotter/images/LargeRuleNumerator-safari.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
test/screenshotter/images/LeftRight-safari.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
test/screenshotter/images/LeftRightListStyling-safari.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
test/screenshotter/images/LeftRightMiddle-safari.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
test/screenshotter/images/LeftRightStyleSizing-safari.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
test/screenshotter/images/LimitControls-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/LineBreak-safari.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
test/screenshotter/images/LowerAccent-safari.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
test/screenshotter/images/MathAtom-safari.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
test/screenshotter/images/MathAtom2-safari.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
test/screenshotter/images/MathBb-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/MathBf-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathCal-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/MathChoice-safari.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
test/screenshotter/images/MathDefaultFonts-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathFrak-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathIt-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/MathNormal-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathOp-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathRm-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/MathScr-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/MathSf-safari.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
test/screenshotter/images/MathTt-safari.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
test/screenshotter/images/Mod-safari.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
test/screenshotter/images/ModScript-safari.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
test/screenshotter/images/ModSpacing-safari.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
test/screenshotter/images/NegativeSpace-safari.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
test/screenshotter/images/NegativeSpaceBetweenRel-safari.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
test/screenshotter/images/NestedFractions-safari.png
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
test/screenshotter/images/NewLine-safari.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
test/screenshotter/images/Not-safari.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
test/screenshotter/images/NullDelimiterInteraction-safari.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
test/screenshotter/images/OldFont-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/OpLimits-safari.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
test/screenshotter/images/OperatorName-safari.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/screenshotter/images/OverUnderline-safari.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
test/screenshotter/images/OverUnderset-safari.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
test/screenshotter/images/Phantom-safari.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
test/screenshotter/images/Pmb-safari.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
test/screenshotter/images/PrimeSpacing-safari.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
test/screenshotter/images/PrimeSuper-safari.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
test/screenshotter/images/Raisebox-safari.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
test/screenshotter/images/ReactionArrows-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/RelativeUnits-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
test/screenshotter/images/RlapBug-safari.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
test/screenshotter/images/Rule-safari.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
test/screenshotter/images/Sizing-safari.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
BIN
test/screenshotter/images/SizingBaseline-safari.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
test/screenshotter/images/Smash-safari.png
Normal file
After Width: | Height: | Size: 7.0 KiB |
BIN
test/screenshotter/images/Spacing-safari.png
Normal file
After Width: | Height: | Size: 14 KiB |