-
Notifications
You must be signed in to change notification settings - Fork 44
/
ci.sh
executable file
·93 lines (73 loc) · 2.82 KB
/
ci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash -e
# -----------------------------------------------------------------------------
# _ ___
# / _ ._ _|_ o ._ _ _ | ._ _|_ _ _ ._ _. _|_ o _ ._
# \_ (_) | | |_ | | | |_| (_) |_| _> _|_ | | |_ (/_ (_| | (_| |_ | (_) | |
# _|
# -----------------------------------------------------------------------------
# This script deploy Mercator on /tmp with mercator_test database,
# check code quality and run unit testing with dusk.
# -----------------------------------------------------------------------------
cd /tmp
rm -rf /tmp/mercator
# Project
tput setaf 2; echo "Clone git"; tput setaf 7
git clone --branch dev https://github.com/dbarzin/mercator
# Composer
tput setaf 2; echo "Composer update"; tput setaf 7
cd /tmp/mercator
composer update
# Drop old test database
# If it fails execute this :
# sudo mysql
# CREATE USER 'yourname'@'localhost';
# GRANT ALL PRIVILEGES ON *.* TO 'yourname'@'localhost' WITH GRANT OPTION;
tput setaf 2; echo "Drop test database"; tput setaf 7
mysql -e "DROP DATABASE IF EXISTS mercator_test;"
mysql -e "DROP USER IF EXISTS 'mercator_test'@'localhost';"
# Create database
tput setaf 2; echo "Create database"; tput setaf 7
mysql -e "
CREATE DATABASE mercator_test CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'mercator_test'@'localhost' IDENTIFIED BY 's3cr3t';
GRANT ALL PRIVILEGES ON mercator_test.* TO 'mercator_test'@'localhost';
FLUSH PRIVILEGES;
"
# Config file
tput setaf 2; echo "Update config file"; tput setaf 7
cp .env.example .env
sed -i "s/\(DB_DATABASE *= *\).*/\1mercator_test/" .env
sed -i "s/\(DB_USERNAME *= *\).*/\1mercator_test/" .env
# Application key
tput setaf 2; echo "Generate application key"; tput setaf 7
php artisan key:generate
# Publush vendor packages
tput setaf 2; echo "Publish"; tput setaf 7
php artisan vendor:publish --all
# Migrate and seed the database
tput setaf 2; echo "Migrate and seed the application"; tput setaf 7
php artisan migrate --seed
# Insert test data
tput setaf 2; echo "Insert test data"; tput setaf 7
cat ./mercator_data.sql | mysql mercator_test
# Check code quality
tput setaf 2; echo "Check code quality"; tput setaf 7
php artisan insights -s
# Configure dusk
cp .env .env.dusk.local
# Start server
tput setaf 2; echo "Start server"; tput setaf 7
php artisan serve --no-reload > /dev/null &
sleep 3
# Install chrome driver
tput setaf 2; echo "Install Chrome Driver"; tput setaf 7
php artisan dusk:chrome-driver
# Start Chrome driver
tput setaf 2; echo "Start chrome"; tput setaf 7
./vendor/laravel/dusk/bin/chromedriver-linux --port=9515 &
# start dusk
tput setaf 2; echo "Dusk test"; tput setaf 7
php artisan dusk --stop-on-error --stop-on-failure
# kill server
kill $(lsof -t -i:8000)
tput setaf 2; echo "Done."; tput setaf 7