mirror of
https://github.com/typeable/elm-ui.git
synced 2024-11-23 01:50:11 +03:00
publish to netlify when tests for sauce labs are run.
This commit is contained in:
parent
f80c1888a9
commit
ae18607868
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"test": "elm-test",
|
||||
"test-render": "node tests/automation/run.js --chrome",
|
||||
"test-render-sauce": "source source.env; node tests/automation/run.js",
|
||||
"test-render-sauce": "source sauce.env; node tests/automation/run.js --sauce",
|
||||
"bench": "node benchmarks/runtime/index.js"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -1,18 +1,21 @@
|
||||
These env variables need to be set before running this script
|
||||
# FILE="test.html"
|
||||
# BUILD="1.1.0"
|
||||
# NAME="development"
|
||||
DIRECTORY='./tmp/elm-ui-testing'
|
||||
|
||||
# Check to see if the repo is already cloned locally
|
||||
# if [ ! -d "$DIRECTORY" ]; then
|
||||
# cd tmp
|
||||
# git clone git@github.com:mdgriffith/elm-ui-testing.git
|
||||
# else
|
||||
# cd tmp
|
||||
# git pull
|
||||
# fi
|
||||
|
||||
cp test.html elm-ui-testing/public/tests/test.html
|
||||
cd tmp
|
||||
if [ ! -d "$DIRECTORY" ]; then
|
||||
git clone git@github.com:mdgriffith/elm-ui-testing.git
|
||||
else
|
||||
git pull
|
||||
fi
|
||||
mkdir -p "elm-ui-testing/public/tests/$BUILD/$NAME/"
|
||||
cp "$FILE" "elm-ui-testing/public/tests/$BUILD/$NAME/index.html"
|
||||
cd elm-ui-testing
|
||||
git add .
|
||||
git commit -m "Publish file from elm-ui suite"
|
||||
git commit -m "Elm UI test for $NAME on $BUILD"
|
||||
git push origin master
|
||||
|
||||
echo "done"
|
@ -6,14 +6,16 @@ const fs = require('fs');
|
||||
const program = require('commander');
|
||||
const path = require("path");
|
||||
const chalk = require('chalk');
|
||||
const childProcess = require('child_process')
|
||||
|
||||
program.option('-s, --sauce', 'run tests on sauce labs')
|
||||
.option('--chrome', 'run only chrome tests')
|
||||
.option('--firefox', 'run only firefox tests')
|
||||
.option('--build', 'Set build number for sauce labs')
|
||||
.option('--name', 'Set run name for sauce labs')
|
||||
.option('--build [value]', 'Set build number for sauce labs')
|
||||
.option('--name [value]', 'Set run name for sauce labs')
|
||||
.parse(process.argv)
|
||||
|
||||
|
||||
// 'Windows 10'
|
||||
const windows = [
|
||||
{
|
||||
@ -58,8 +60,31 @@ const osx = {
|
||||
}
|
||||
|
||||
|
||||
function prepare_envs() {
|
||||
return []
|
||||
function prepare_all_envs(config) {
|
||||
var envs = []
|
||||
|
||||
for (i = 0; i < windows.length; i++) {
|
||||
envs.push({
|
||||
browser: windows[i].browser,
|
||||
browserVersion: windows[i].browserVersion,
|
||||
platform: "Windows 10",
|
||||
build: config.build,
|
||||
name: config.name
|
||||
})
|
||||
}
|
||||
|
||||
for (i = 0; i < osx.length; i++) {
|
||||
envs.push({
|
||||
browser: osx[i].browser,
|
||||
browserVersion: osx[i].browserVersion,
|
||||
platform: "macOS 10.14",
|
||||
build: config.build,
|
||||
name: config.name
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return envs
|
||||
}
|
||||
|
||||
async function compile_and_embed(config) {
|
||||
@ -139,11 +164,27 @@ async function run_test(driver, url) {
|
||||
if (program.sauce) {
|
||||
const build = program.build
|
||||
const name = program.name
|
||||
|
||||
if (build == null || name == null) {
|
||||
throw ("A Build and a Name must be specified.");
|
||||
}
|
||||
|
||||
|
||||
var results = []
|
||||
console.log("TODO: PUBLISH FILE BEFORE TESTING")
|
||||
var url = "fail"
|
||||
// Publish to
|
||||
const envs = prepare_envs({ build: build, name: name })
|
||||
|
||||
// Publish to netlify
|
||||
childProcess.execSync("sh tests/automation/publish-file.sh", {
|
||||
env: {
|
||||
FILE: "test.html",
|
||||
BUILD: program.build,
|
||||
NAME: program.name
|
||||
}
|
||||
})
|
||||
var url = `http://elm-ui-testing.netlify.com/tests/${program.build}/${program.name}/`
|
||||
console.log(`Running sauce labs test ${url}`)
|
||||
|
||||
|
||||
const envs = prepare_all_envs({ build: build, name: name })
|
||||
for (i = 0; i < envs.length; i++) {
|
||||
var driver = prepare_sauce_driver(envs[i])
|
||||
results.push(await run_test(driver, url))
|
||||
@ -151,7 +192,9 @@ async function run_test(driver, url) {
|
||||
|
||||
|
||||
} else {
|
||||
if (program.chrome) {
|
||||
|
||||
// Run chrome if nothing else is selected
|
||||
if (program.chrome || (!program.chrome && !program.firefox)) {
|
||||
console.log("Running locally on Chrome...")
|
||||
const driver = await prepare_local_driver(osx.chrome)
|
||||
var results = await run_test(driver, "file://" + path.resolve('./tmp/test.html'))
|
||||
|
Loading…
Reference in New Issue
Block a user