aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile8
-rwxr-xr-xbin/test.sh11
-rw-r--r--docker-compose.test.yml98
3 files changed, 112 insertions, 5 deletions
diff --git a/Gemfile b/Gemfile
index 294b9f3..e3952fb 100644
--- a/Gemfile
+++ b/Gemfile
@@ -36,6 +36,8 @@ gem 'rdiscount'
# UI
gem 'octicons_helper'
+gem 'rails-controller-testing'
+
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
@@ -63,8 +65,4 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
-end
-
-group :test do
- gem 'rails-controller-testing'
-end
+end \ No newline at end of file
diff --git a/bin/test.sh b/bin/test.sh
new file mode 100755
index 0000000..5397212
--- /dev/null
+++ b/bin/test.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Wait for Elasticsearch to start up
+sleep 30
+
+bundler install
+bundle exec rake tmp:create RAILS_ENV=test
+bundle exec rake assets:precompile RAILS_ENV=test
+bundle exec rake kkuleomi:index:init RAILS_ENV=test
+
+RAILS_ENV=test bundle exec rake test test/ \ No newline at end of file
diff --git a/docker-compose.test.yml b/docker-compose.test.yml
new file mode 100644
index 0000000..29c51c0
--- /dev/null
+++ b/docker-compose.test.yml
@@ -0,0 +1,98 @@
+
+version: '3.2'
+# This file is used for testing purposes. Call
+#
+# $ docker-compose -f docker-compose.test.yml up --exit-code-from http-serving
+#
+# to run all tests.
+#
+#
+services:
+ http-serving:
+ # Build from Dockerfile in .
+ build: .
+ ports:
+ - 5000
+ volumes:
+ - type: "bind"
+ source: "."
+ target: "/var/www/packages.gentoo.org/htdocs/"
+ - type: volume
+ source: portage
+ target: /var/db/repos/gentoo
+ - type: volume
+ source: portage-git
+ target: /mnt/packages-tree
+ environment:
+ # "Redis:port" and "elasticsearch:port" refer to sibling containers.
+ - REDIS_PROVIDER=REDIS_URL
+ - REDIS_URL=redis://redis:6379
+ - ELASTICSEARCH_URL=elasticsearch:9200
+ - RAILS_SERVE_STATIC_FILES=1
+ - RAILS_ENV=development
+ - MEMCACHE_URL="memcache:11211"
+ - SECRET_KEY_BASE=6c9710aeb74dd88ff1d1b8f4bd6d7d8e0f340905d0974400fffd7246714aa703cf7bf4a98c0bc90317a3b803b82c0f9371e18ada19fc4eed9d6118077a249f50
+ depends_on:
+ - redis
+ - elasticsearch
+ command: bash -c "/var/www/packages.gentoo.org/htdocs/bin/test.sh"
+ sidekiq:
+ build: .
+ volumes:
+ - type: "bind"
+ source: "."
+ target: "/var/www/packages.gentoo.org/htdocs/"
+ - type: volume
+ source: portage
+ target: /var/db/repos/gentoo
+ - type: volume
+ source: portage-git
+ target: /mnt/packages-tree
+ environment:
+ - RAILS_ENV=development
+ - RAILS_SERVE_STATIC_FILES=1
+ - REDIS_URL=redis://redis:6379
+ - MEMCACHE_URL="memcache:11211"
+ - ELASTICSEARCH_URL=elasticsearch:9200
+ - SECRET_KEY_BASE=6c9710aeb74dd88ff1d1b8f4bd6d7d8e0f340905d0974400fffd7246714aa703cf7bf4a98c0bc90317a3b803b82c0f9371e18ada19fc4eed9d6118077a249f50
+ depends_on:
+ - redis
+ - elasticsearch
+ command: >
+ bash -c " bundler install
+ && bundle exec sidekiq -c 5 -e test"
+ memcache:
+ image: memcached:latest
+ ports:
+ - 11211
+ elasticsearch:
+ # TODO(antarus): We should build a docker image for this based on gentoo.
+ image: docker.elastic.co/elasticsearch/elasticsearch:7.3.1
+ container_name: elasticsearch
+ environment:
+ - discovery.type=single-node
+ - http.port=9200
+ - http.cors.enabled=true
+ - http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358
+ - http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
+ - http.cors.allow-credentials=true
+ - bootstrap.memory_lock=true
+ - 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
+ ports:
+ - 9200
+ # elasticsearch browser
+ dejavu:
+ image: appbaseio/dejavu:3.4.0
+ container_name: dejavu
+ ports:
+ - '1358:1358'
+ links:
+ - elasticsearch
+ redis:
+ image: redis:4.0.6
+ ports:
+ - 6379
+
+volumes:
+ portage:
+ portage-git: