forked from dbarzin/mercator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci.sh
executable file
·84 lines (64 loc) · 2.45 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
#!/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
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
# start dusk
tput setaf 2; echo "Dusk test"; tput setaf 7
php artisan dusk:chrome-driver
php artisan dusk --stop-on-error --stop-on-failure
# kill server
kill $(lsof -t -i:8000)
tput setaf 2; echo "Done."; tput setaf 7