diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..be414aa05 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,50 @@ +version: 2 + +defaults: &defaults + working_directory: ~/app + docker: + - image: buildpack-deps:trusty + environment: + DOCKER_VERSION: 18.03.1-ce + DOCKER_COMPOSE_VERSION: 1.21.1 + +jobs: + build: + <<: *defaults + steps: + - checkout + - setup_remote_docker + - run: + name: Install Docker + command: | + set -x + curl -L -o /tmp/docker-${DOCKER_VERSION}.tgz https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz + tar -xz -C /tmp -f /tmp/docker-${DOCKER_VERSION}.tgz + chmod +x /tmp/docker/* + mv /tmp/docker/* /usr/bin + - run: + name: Install Docker Compose + command: | + sudo rm -f /usr/local/bin/docker-compose + curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + chmod +x docker-compose + sudo mv docker-compose /usr/local/bin + - run: + name: Create .env.test file + command: env | egrep 'DEBUG|DANBOORU|RAILS|DATABASE_URL|SECRET' > .env.test + - run: + name: Build and Start Docker containers + command: docker-compose -f config/docker/compose.yml up -d web + - run: + name: Run database migrations + command: | + docker-compose -f config/docker/compose.yml exec archives dockerize -wait tcp://$PGHOST:$PGPORT bash -l -c 'cd /app ; bundle exec rake db:create ; bundle exec rake db:migrate' + docker-compose -f config/docker/compose.yml exec web dockerize -wait tcp://$PGHOST:$PGPORT bash -l -c 'cd /app ; bin/rake db:create ; bin/rake db:migrate' + - run: + name: Run tests + command: docker-compose -f config/docker/compose.yml exec web bin/rails t + - store_test_results: + path: test/reports + - run: + name: Teardown + command: docker-compose -f config/docker/compose.yml down diff --git a/.gitignore b/.gitignore index d91997ecf..6aa281710 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ danbooru.sublime-workspace script/scratch.* test/fixtures/vcr_cassettes .gitconfig +test/reports \ No newline at end of file diff --git a/Gemfile b/Gemfile index eb3c765e8..a5791940b 100644 --- a/Gemfile +++ b/Gemfile @@ -82,4 +82,5 @@ group :test do gem "simplecov", :require => false gem "timecop" gem "webmock" + gem "minitest-ci" end diff --git a/Gemfile.lock b/Gemfile.lock index 03d3ab585..9d60a85e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,6 +228,8 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.3) + minitest-ci (3.4.0) + minitest (>= 5.0.6) mocha (1.5.0) metaclass (~> 0.0.1) msgpack (1.2.4) @@ -460,6 +462,7 @@ DEPENDENCIES memcache-client memcache_mock memoist + minitest-ci mocha net-sftp newrelic_rpm