-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from femiwiki/travis-ci
Travis ci Co-authored-by: Hyeon Kim <[email protected]>
- Loading branch information
Showing
9 changed files
with
542 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
/configs/secret.php | ||
/configs/env | ||
|
||
# Composer | ||
/vendor | ||
|
||
# Git | ||
/.git/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# secret | ||
/configs/secret.php | ||
/configs/env | ||
|
||
# Composer | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="MediaWiki"> | ||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> | ||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment"/> | ||
<exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle"/> | ||
</rule> | ||
<file>.</file> | ||
<arg name="encoding" value="UTF-8"/> | ||
<arg name="extensions" value="php,php5,inc,sample"/> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
os: linux | ||
dist: xenial | ||
git: | ||
quiet: true | ||
depth: 3 | ||
|
||
# PHP | ||
language: php | ||
php: '7.2' | ||
cache: | ||
directories: | ||
- vendor | ||
|
||
env: | ||
global: | ||
# Maximum iteration limit for loop | ||
- LOOP_LIMIT=300 | ||
|
||
services: | ||
- docker | ||
|
||
jobs: | ||
include: | ||
# | ||
# LocalSettings.php 코드 lint | ||
# | ||
- name: lint | ||
before_script: | ||
- composer install --prefer-source --quiet --no-interaction | ||
script: | ||
- composer test | ||
|
||
|
||
# | ||
# 미디어위키 도커 이미지가 정상적으로 실행되는지 확인 | ||
# | ||
- name: docker | ||
before_script: | ||
# Setup files for database and memcached | ||
- git clone https://github.com/femiwiki/database.git ~/swarm --depth=1 | ||
- sudo mkdir -p /srv/mysql/ | ||
# Initialize docker swarm and start memcached and MySQL | ||
- docker swarm init | ||
- docker stack deploy -c ~/swarm/memcached.yml memcached | ||
- docker stack deploy -c ~/swarm/database.yml database | ||
# Wait until root account's password of MySQL is generated | ||
- | | ||
printf 'Waiting for database_mysql service...'; | ||
# Set counter to check endless loop | ||
COUNTER=0; | ||
while [ -z $(docker service logs database_mysql 2>&1 | grep -oP 'GENERATED ROOT PASSWORD: \K.+') ]; do | ||
# retry every 1 second. | ||
sleep 1; | ||
# Append dots to the previous message if process is delayed. | ||
printf '.'; | ||
# Terminate Travis-ci if loop exceeds limit | ||
(( COUNTER++ )); | ||
if [ $COUNTER -gt $LOOP_LIMIT ]; then | ||
printf '\n'; | ||
echo 'Falied to start database_mysql service'; | ||
# Print logs for debugging | ||
docker service logs database_mysql; | ||
travis_terminate 1; | ||
fi | ||
done; | ||
printf '\n'; | ||
# Edit configuration | ||
- | | ||
HOST_IP="$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')"; | ||
MYSQL_PW="$(docker service logs database_mysql 2>&1 | grep -Po 'GENERATED ROOT PASSWORD: \K.+')"; | ||
- mv configs/env.example configs/env | ||
- sed -ri "s/mysqlhostname/${HOST_IP}/; s/mysqlusername/root/; s/mysqlpassword/${MYSQL_PW}/" configs/env | ||
- mv configs/secret.php.example configs/secret.php | ||
- sed -ri "s/DB_HOSTNAME/${HOST_IP}/; s/DB_USERNAME/root/; s/DB_PASSWORD/${MYSQL_PW}/; s/MEMCACHED_HOSTNAME/${HOST_IP}/" configs/secret.php | ||
# Tweak LocalSettings.php for debugging | ||
- printf 'wfRunDebugMode("localhost");\nrequire_once "$IP/includes/DevelopmentSettings.php";\n' >> configs/LocalSettings.php | ||
script: | ||
- docker build --tag femiwiki/mediawiki . | ||
- docker stack deploy -c docker-compose.yml mediawiki | ||
# Check if status of container is shutdown | ||
- test -z "$(docker service ps -qf 'desired-state=Shutdown' mediawiki_fastcgi)" | ||
# Access localhost until success | ||
- | | ||
printf 'Waiting for http...' | ||
COUNTER=0; | ||
until [ "$(curl -Lfs localhost)" ]; do | ||
sleep 1; | ||
printf '.'; | ||
(( COUNTER++ )); | ||
if [ $COUNTER -gt $LOOP_LIMIT ]; then | ||
printf '\n'; | ||
echo 'Failed to connect to localhost'; | ||
travis_terminate 1; | ||
fi | ||
done; printf '\n' | ||
- docker service logs mediawiki_fastcgi | ||
- curl -Lf localhost | head |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"require-dev": { | ||
"mediawiki/mediawiki-codesniffer": "23.0.0", | ||
"jakub-onderka/php-parallel-lint": "0.9.2" | ||
}, | ||
"scripts": { | ||
"fix": "phpcbf", | ||
"test": [ | ||
"php -l configs/LocalSettings.php", | ||
"parallel-lint --exclude vendor .", | ||
"phpcs -p -s ." | ||
] | ||
} | ||
} |
Oops, something went wrong.