Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
89dc99d
Use live-code-coverage to get Code Coverage
asbiin Jan 14, 2018
b6219b7
Mkdir coverage
asbiin Jan 14, 2018
54de2b5
Add test to pass Login form
asbiin Jan 14, 2018
481af45
Fix StyleCI
asbiin Jan 14, 2018
8dc5955
Add verbose option
asbiin Jan 15, 2018
1721666
Add waitForLinkText
asbiin Jan 15, 2018
e574ca1
Add FakeUserTableSeeder to environnement testing
asbiin Jan 15, 2018
b4a441b
Enhance tests
asbiin Jan 16, 2018
dd3ec55
Update composer
asbiin Jan 18, 2018
8ce05e7
Upload img capture and add comment to the PR
asbiin Jan 19, 2018
2db3a14
Update travis
asbiin Jan 19, 2018
3400788
Using submit instead of click
asbiin Jan 19, 2018
011e8f2
Add saucelabs
asbiin Jan 19, 2018
51233ee
Run one selenium instance only
asbiin Jan 19, 2018
5be9bdf
Using saucelabs
asbiin Jan 19, 2018
277a9a9
New try
asbiin Jan 19, 2018
e1e8963
using localhost to ping sauceconnect
asbiin Jan 19, 2018
e88cd55
Try adding capability
asbiin Jan 19, 2018
7bcfcd8
add new config travis
asbiin Jan 19, 2018
b8f4fd1
One quote !!
asbiin Jan 19, 2018
965256c
Add App_URL to env
asbiin Jan 19, 2018
343f5a8
Using SESSION_DRIVER=file
asbiin Jan 19, 2018
bc6a9ef
Run phpunit again, deactivate SAUCELABS
asbiin Jan 19, 2018
61df24f
Remove semicolons
asbiin Jan 19, 2018
de2cdfe
Remove fi
asbiin Jan 19, 2018
216d82e
Merge branch 'master' into ci/browser/add-code-coverage
asbiin Jan 19, 2018
e4abacd
Add runtests script
asbiin Jan 19, 2018
a8e7b6d
Update sig
asbiin Jan 19, 2018
f66892f
Use urldecode
asbiin Jan 19, 2018
650be06
Merge branch 'ci/browser/add-code-coverage' of github.com:monicahq/mo…
asbiin Jan 19, 2018
6fb71e8
Update travis script
asbiin Jan 19, 2018
7e71b3e
Fix steward lines
asbiin Jan 20, 2018
3d36f4d
Merge branch 'master' into ci/browser/add-code-coverage
asbiin Jan 22, 2018
202cfbc
Update scripts
asbiin Jan 22, 2018
e0d300d
Merge branch 'ci/browser/add-code-coverage' of github.com:monicahq/mo…
asbiin Jan 22, 2018
87e3750
Update composer
asbiin Jan 22, 2018
bb3f677
I can't chmod shell file right now
asbiin Jan 22, 2018
b209b2c
OK found howto chmod the file !
asbiin Jan 22, 2018
3e7879d
Bash is better
asbiin Jan 22, 2018
d5008b1
Fix root path
asbiin Jan 22, 2018
6119ffd
Update signatures
asbiin Jan 22, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .ci/runtests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P)

if [ -z "${DISPLAY:-}" ]; then
echo Start Xvfb;
export DISPLAY=:99.0;
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x24;
fi

if ! $(nc -z localhost 4444); then
$SELF_PATH/../vendor/bin/selenium-server-standalone -role hub -log $SELF_PATH/../selenium-server.log -enablePassThrough false &
until $(nc -z localhost 4444); do
echo Waiting for selenium hub to start...;
sleep 1;
done
fi

export PATH="$SELF_PATH/../vendor/bin:$PATH"
if ! $(nc -z localhost 8910); then
java -Dwebdriver.chrome.driver="$SELF_PATH/../vendor/bin/chromedriver" -jar $SELF_PATH/../vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -role node -port 8910 -log $SELF_PATH/..selenium-node.log &
until $(nc -z localhost 8910); do
echo Waiting for selenium node to start...;
sleep 1;
done
fi

if ! $(nc -z localhost 8000); then
pushd $SELF_PATH/..
php laravel serve &
popd
until $(nc -z localhost 8000); do
echo Waiting for laravel serve to start...;
sleep 1;
done
fi

$SELF_PATH/../vendor/bin/steward run laravel chrome -vvv
33 changes: 33 additions & 0 deletions .ci/server-cc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Copy of server.php with Code Coverage capture.
*/

/** Coverage files destination. */
const STORAGE = '/results/coverage';

$root = realpath(__DIR__.'/../');

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists($root.'/public'.$uri)) {
return false;
}

/**
* Set CodeCoverage via LiveCodeCoverage.
*/
require $root.'/vendor/autoload.php';

\LiveCodeCoverage\LiveCodeCoverage::bootstrap(
$root.STORAGE,
$root.'/phpunit.xml'
);

require_once $root.'/public/index.php';
27 changes: 27 additions & 0 deletions .ci/start-selenium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -evuo pipefail

SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
ROOT=$SELF_PATH/..

if [ -z "${DISPLAY:-}" ]; then
echo Start Xvfb;
export DISPLAY=:99.0;
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x24;
fi

if ! $(nc -z localhost 4444); then
$ROOT/vendor/bin/selenium-server-standalone -role hub -log "$ROOT/selenium-server.log" &
until $(nc -z localhost 4444); do
echo Waiting for selenium hub to start...;
sleep 1;
done
fi

if ! $(nc -z localhost 8910); then
java -Dwebdriver.chrome.driver="$ROOT/vendor/bin/chromedriver" -jar "$ROOT/vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar" -role node -port 8910 -log "$ROOT/selenium-node.log" &
until $(nc -z localhost 8910); do
echo Waiting for selenium node to start...;
sleep 1;
done
fi
72 changes: 72 additions & 0 deletions .ci/travis-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
set -euo pipefail

function api() {
set +u
fonction=$1
action=$2
content=$3

if [ -z "${action:-}" ]; then
curl --silent -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${TRAVIS_REPO_SLUG}$fonction
elif [ "$action" = "POST" ]; then
curl --silent -H "Authorization: token $GITHUB_TOKEN" -d "$content" https://api.github.com/repos/${TRAVIS_REPO_SLUG}$fonction
else
curl --silent -H "Authorization: token $GITHUB_TOKEN" -X "$action" https://api.github.com/repos/${TRAVIS_REPO_SLUG}$fonction
fi
set -u
}

function uploadimg() {
file=$1
curl -H "Authorization: Client-ID $IMGUR_CLIENTID" \
-H "Expect: " \
-F "image=@$file" \
https://api.imgur.com/3/image 2>/dev/null
}

function deleteimg() {
hash=$1
curl -H "Authorization: Client-ID $IMGUR_CLIENTID" \
-X "DELETE" \
https://api.imgur.com/3/image/$hash 2>/dev/null
}

if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ -n "${GITHUB_TOKEN:-}" ]; then

comments=$(api /issues/$TRAVIS_PULL_REQUEST/comments)

for ((i=1;i<=4294967295;i++)); do
comment=$(echo $comments | jq -r ".[$i]")
if [ "$comment" = "null" ]; then
break;
fi

body=$(echo $comment | jq -r ".body")
if $(echo $body | grep -q "^\[test\]"); then
id=$(echo $comment | jq -r ".id")
hash=$(echo "$body" | grep "\[id:" | sed -s 's/.*\[id\:\(.*\)\]/\1/g' 2>/dev/null)

echo Delete previous screenshot $id with $hash
if [ -n "${hash:-}" ]; then
echo Delete img
status=$(deleteimg $hash)
fi
api /issues/comments/$id DELETE
fi

done

for file in $(ls logs/*.png); do
echo Upload img and comment for $file
img=$(uploadimg $file)
success=$(echo $img | jq -r ".success")
if [ "$success" = "true" ]; then
url=$(echo $img | jq -r ".data.link")
echo $url
deletehash=$(echo $img | jq -r ".data.deletehash")
result=$(api /issues/$TRAVIS_PULL_REQUEST/comments POST "{ \"body\": \"[test]\n![capture]($url)\n$file\n[id:$deletehash]\"}")
fi
done

fi
3 changes: 2 additions & 1 deletion .env.travis
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
APP_ENV=testing
APP_KEY=base64:NTrXToqFZJlv48dgPc+kNpc3SBt333TfDnF1mDShsBg=
APP_URL=http://localhost:8000

DB_CONNECTION=testing
DB_TEST_HOST=127.0.0.1
Expand All @@ -8,7 +9,7 @@ DB_TEST_USERNAME=root
DB_TEST_PASSWORD=

CACHE_DRIVER=array
SESSION_DRIVER=array
SESSION_DRIVER=file
QUEUE_DRIVER=sync

2FA_ENABLED=false
45 changes: 26 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,54 @@ services:
jdk:
- oraclejdk8

git:
depth: false

addons:
chrome: stable
# sauce_connect:
# username: "asbiin"
# jwt:
# secure: "niuYhwCsFVUHS6DU3j0xi24habQOSqKpzo7qUlGmlx1x31wZNDrl+wfifeTVv6nnjoShyr4s6svn3ULl1K8tQMdyHJlO247WKMg/PSnaSUyll5+luuP5SLpV+USP8g9a7HAjU+jQO5uE/GXKDDQcD+o5dV6gv9stmc9u/np45kwgVx55bj013ll0M5qlyflJZFgp3b/M+bvqkvIFDPN2U7iFs0dkhqxBI+6qbTAN4aTtxPSPrsYdt9W8Re1suzy2/CJEEQ2xKE4zm7WQ2dg6BrpbaU2bdG6wWZUw2toA8iCyxFgbJUlXmAjPEQ5Wr+gWEQ9bLcwCIoHxUMIRbqY/SNzve7KnGXOUEF0yttyAv3aq9STA58Mr+H15zXdA5ZAwpE/tNojfaacEya/bg9fwUWOCqrPXIhwFirhf8oD2y8n+SWD27rP0qD9um9HGqGkh6bqFefIZi2xVzLya1r/2kxqFskrj+0xPjjKYwMwJIM5s7HyrtIxR7QTpFEbgHpZjCmT31I65ds56ec34wbZ0W61bm4aQAxz7UIedCYsTrqtTzTYxUJEht3/1D5FH0PSBWQACJmdjSHvh0pP7zzG2cqzq2IhHCSZjnhh6LGUPQtgZh3kq1fSP0Zw74iSVrxQETsGoPwYA6R38e+V39vV8yUHjMUXNPIhgcQQZHiZcEWI="

env:
global:
# - SAUCELABS=1

before_script:
- cp .env.travis .env
- mkdir -p $TRAVIS_BUILD_DIR/results/coverage
- mysql -e 'create database monica;'
- composer self-update
- travis_retry composer install --no-interaction --prefer-dist --no-suggest

# Start Xvfb
- "export DISPLAY=:99.0"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x24"

# Start selenium server
- vendor/bin/selenium-server-standalone -role hub -log selenium-server.log -enablePassThrough false &
- until $(echo | nc localhost 4444); do sleep 1; echo Waiting for selenium hub to start...; done;

# Start selenium node for headless Chrome
- export PATH="$(pwd)/vendor/bin:$PATH"
- vendor/bin/selenium-server-standalone -role node -port 8910 -log selenium-node.log -enablePassThrough false &
- until $(echo | nc localhost 8910); do sleep 1; echo Waiting for selenium node to start...; done;
- if [ ! "$SAUCELABS" = "1" ]; then .ci/start-selenium.sh; fi

script:
- php artisan migrate --env=testing --no-interaction -vvv
- php artisan db:seed --env=testing --no-interaction -vvv

# Run unit tests
- vendor/bin/phpunit

# Start http server
- php artisan serve &
- until $(echo | nc localhost 8000); do sleep 1; echo Waiting for laravel server to start...; done;
- vendor/bin/steward run laravel chrome
- php -S 127.0.0.1:8000 -t $TRAVIS_BUILD_DIR/public $TRAVIS_BUILD_DIR/.ci/server-cc.php &
- until $(nc -z localhost 8000); do sleep 1; echo Waiting for laravel server to start...; done;

# Run browser tests
- if [ "$SAUCELABS" = "1" ]; then vendor/bin/steward run travis chrome -vvv --server-url=http://$SAUCE_USERNAME:$SAUCE_ACCESS_KEY@localhost:4445 --capability="tunnel-identifier:'${TRAVIS_JOB_NUMBER}'"; fi
- if [ ! "$SAUCELABS" = "1" ]; then vendor/bin/steward run travis chrome -vvv; fi

after_success:
- bash <(curl -s https://codecov.io/bash)

after_script:
- vendor/bin/steward results -vvv
- .ci/travis-report.sh 2>/dev/null
- cat selenium-server.log
- cat selenium-node.log
- vendor/bin/phpcov merge --clover=$TRAVIS_BUILD_DIR/results/coverage2.xml $TRAVIS_BUILD_DIR/results/coverage/
- ./travis-sonar.sh

after_success:
- bash <(curl -s https://codecov.io/bash) -f results/clover.xml

cache:
directories:
- $HOME/.sonar/cache
Expand Down
Binary file modified .travis.yml.sig
Binary file not shown.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"enm1989/chromedriver": "^2.35",
"filp/whoops": "~2.0",
"lmc/steward": "dev-update-dependencies",
"matthiasnoback/live-code-coverage": "^0.1.0",
"mockery/mockery": "0.9.*",
"phpunit/phpcov": "^4.0",
"phpunit/phpunit": "~6.0",
"se/selenium-server-standalone": "^3.8",
"symfony/css-selector": "2.8.*|3.0.*",
Expand Down
Loading