Skip to content

Implement Travis CI #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
sudo: required
language: python
cache:
directories:
- pip
before_install:
- make travis-before-install-$TEST_SUITE
install:
- make travis-install-$TEST_SUITE
before_script:
- make travis-before-script-$TEST_SUITE
script:
- make travis-$SCRIPT-$TEST_SUITE
jobs:
include:
- stage: test
python: 3.6
env:
- TEST_SUITE=backend
- SCRIPT=test
services:
- mysql
after_success:
- mysqldump --user='root' --password='' test_project > ~/$TRAVIS_BRANCH/databases/db.sql
- aws s3 sync ~/$TRAVIS_BRANCH s3://org-travis-ci/$TRAVIS_BRANCH
notifications:
email: false
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
travis-before-install-backend:
sudo rm -f /etc/boto.cfg

travis-install-backend:
pip install awscli
pip install -r ./requirements.txt

travis-before-script-backend:
mkdir -p ~/$(TRAVIS_BRANCH)/databases/
touch ~/$(TRAVIS_BRANCH)/databases/db.sql
aws s3 sync s3://org-travis-ci/$(TRAVIS_BRANCH) ~/$(TRAVIS_BRANCH)
mysql --user='root' --password='' -e 'CREATE DATABASE IF NOT EXISTS test_project;'
@case $$TRAVIS_COMMIT_MESSAGE in *"[reset mysql]"*) \
echo 'Resetting MySQL database...'; \
aws s3 rm s3://org-travis-ci/$(TRAVIS_BRANCH)/databases/db.sql; \
;; *) \
echo 'Loading previous MySQL database...'; \
mysql --user='root' --password='' test_project < ~/$(TRAVIS_BRANCH)/databases/db.sql; \
esac

travis-test-backend:
cd project; python manage.py test --keepdb --failfast -v 3 project

travis-noop:
@echo "Move along..."
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# travis-ci-persistent-db

Maintain a persistent database per branch on Travis CI builds.
Use `[reset mysql]` in a commit message to reset database.

### Pull Request Showing Difference

https://github.com/michaelhelmick/travis-ci-persistent-db/pull/1

### Blog Post

https://medium.com/@mikehelmick/persistent-databases-on-travis-ci-19ca6f968d50