diff --git a/ci/bundle_helper/Dockerfile b/ci/bundle_helper/Dockerfile new file mode 100644 index 0000000..a4cf0cd --- /dev/null +++ b/ci/bundle_helper/Dockerfile @@ -0,0 +1,15 @@ +FROM debian:jessie + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update -q 2 && apt-get install -y --no-install-recommends git \ + bundler \ + ruby-dev \ + libgmp-dev \ + build-essential \ + nodejs \ + mysql-client +RUN git clone https://repo.grnet.gr/source/webdns.git /srv/webdns +RUN apt-get install -y --no-install-recommends capistrano unicorn rails ruby-mysql2 ruby-jquery-rails libmysqlclient-dev + +WORKDIR /srv/webdns +ENTRYPOINT ["bundle","install","--deployment"] diff --git a/ci/ruby_tests/rake/Dockerfile b/ci/ruby_tests/rake/Dockerfile new file mode 100644 index 0000000..afaf409 --- /dev/null +++ b/ci/ruby_tests/rake/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:jessie + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update -q 2 && apt-get install -y --no-install-recommends git \ + bundler \ + ruby-dev \ + libgmp-dev \ + build-essential \ + nodejs \ + mysql-client +RUN git clone https://repo.grnet.gr/source/webdns.git /srv/webdns +RUN apt-get install -y --no-install-recommends capistrano unicorn rails ruby-mysql2 ruby-jquery-rails +WORKDIR /srv/webdns +RUN bundle install + +EXPOSE 8080 +COPY seeds_policies.rb / +COPY seeds_users.rb / +COPY entrypoint.sh / +RUN chmod u+x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/ci/ruby_tests/rake/entrypoint.sh b/ci/ruby_tests/rake/entrypoint.sh new file mode 100644 index 0000000..46863c9 --- /dev/null +++ b/ci/ruby_tests/rake/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ -z "${MYSQL_HOST}" ]; then + echo "You need to specify a mysql host." + exit +fi + +MYSQL_DATABASE=${MYSQL_DATABASE-dns} +MYSQL_USER=${MYSQL_USER-dns} +MYSQL_PORT=${MYSQL_PORT-3306} +MYSQL_PASSWORD=${MYSQL_PASSWORD-12345} + +MYSQL_TEST_DATABASE="${MYSQL_DATABASE}_test" + +sleep 20 + +cat << EOF > /srv/webdns/config/database.yml +development: + database: ${MYSQL_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} + +test: + database: ${MYSQL_TEST_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} +EOF + +/usr/bin/rake db:migrate +/usr/bin/rails runner /seeds_users.rb +#/usr/bin/rails runner seeds_policies.rb +cd /srv/webdns +rake test diff --git a/ci/ruby_tests/rake/seeds_policies.rb b/ci/ruby_tests/rake/seeds_policies.rb new file mode 100644 index 0000000..31aed85 --- /dev/null +++ b/ci/ruby_tests/rake/seeds_policies.rb @@ -0,0 +1,133 @@ +policies = {} +policies[:default] = <<-POLICY + + + + A default policy that will amaze you and your friends + + PT7200S + PT259200S + + PT1209600S + PT1209600S + + PT43200S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT3600S + PT3600S + PT3600S + PT1209600S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT7776000S + SoftHSM + 0 + + + + PT43200S + + PT3600S + PT3600S + unixtime + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY +policies[:lab] = <<-POLICY + + + + Quick turnaround policy for lab work + + PT600S + PT1800S + + PT3600S + PT3600S + + PT60S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT300S + PT360S + PT360S + PT432000S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT14400S + SoftHSM + 0 + + + + PT30S + + PT300S + PT300S + counter + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY + +policies.each_pair { |name, policy| + DnssecPolicy.create(name: name, policy: policy) +} diff --git a/ci/ruby_tests/rake/seeds_users.rb b/ci/ruby_tests/rake/seeds_users.rb new file mode 100644 index 0000000..fe4e228 --- /dev/null +++ b/ci/ruby_tests/rake/seeds_users.rb @@ -0,0 +1,4 @@ +users = [] +users << User.create!(email: 'admin@example.com', password: 'adminadmin') +g_admin = Group.create!(name: 'admin') +g_admin.users << users.first diff --git a/ci/ruby_tests/reek/Dockerfile b/ci/ruby_tests/reek/Dockerfile new file mode 100644 index 0000000..7c7cee6 --- /dev/null +++ b/ci/ruby_tests/reek/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:jessie + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update -q 2 && apt-get install -y --no-install-recommends git \ + bundler \ + ruby-dev \ + libgmp-dev \ + build-essential \ + nodejs \ + mysql-client +RUN git clone https://repo.grnet.gr/source/webdns.git /srv/webdns +RUN apt-get install -y --no-install-recommends capistrano unicorn rails ruby-mysql2 ruby-jquery-rails +WORKDIR /srv/webdns +RUN bundle install +RUN gem install reek -v 4.8.2 + +EXPOSE 8080 +COPY seeds_policies.rb / +COPY seeds_users.rb / +COPY entrypoint.sh / +RUN chmod u+x /entrypoint.sh +ENTRYPOINT ["reek","/srv/webdns"] diff --git a/ci/ruby_tests/reek/entrypoint.sh b/ci/ruby_tests/reek/entrypoint.sh new file mode 100644 index 0000000..46863c9 --- /dev/null +++ b/ci/ruby_tests/reek/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ -z "${MYSQL_HOST}" ]; then + echo "You need to specify a mysql host." + exit +fi + +MYSQL_DATABASE=${MYSQL_DATABASE-dns} +MYSQL_USER=${MYSQL_USER-dns} +MYSQL_PORT=${MYSQL_PORT-3306} +MYSQL_PASSWORD=${MYSQL_PASSWORD-12345} + +MYSQL_TEST_DATABASE="${MYSQL_DATABASE}_test" + +sleep 20 + +cat << EOF > /srv/webdns/config/database.yml +development: + database: ${MYSQL_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} + +test: + database: ${MYSQL_TEST_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} +EOF + +/usr/bin/rake db:migrate +/usr/bin/rails runner /seeds_users.rb +#/usr/bin/rails runner seeds_policies.rb +cd /srv/webdns +rake test diff --git a/ci/ruby_tests/reek/seeds_policies.rb b/ci/ruby_tests/reek/seeds_policies.rb new file mode 100644 index 0000000..31aed85 --- /dev/null +++ b/ci/ruby_tests/reek/seeds_policies.rb @@ -0,0 +1,133 @@ +policies = {} +policies[:default] = <<-POLICY + + + + A default policy that will amaze you and your friends + + PT7200S + PT259200S + + PT1209600S + PT1209600S + + PT43200S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT3600S + PT3600S + PT3600S + PT1209600S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT7776000S + SoftHSM + 0 + + + + PT43200S + + PT3600S + PT3600S + unixtime + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY +policies[:lab] = <<-POLICY + + + + Quick turnaround policy for lab work + + PT600S + PT1800S + + PT3600S + PT3600S + + PT60S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT300S + PT360S + PT360S + PT432000S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT14400S + SoftHSM + 0 + + + + PT30S + + PT300S + PT300S + counter + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY + +policies.each_pair { |name, policy| + DnssecPolicy.create(name: name, policy: policy) +} diff --git a/ci/ruby_tests/reek/seeds_users.rb b/ci/ruby_tests/reek/seeds_users.rb new file mode 100644 index 0000000..fe4e228 --- /dev/null +++ b/ci/ruby_tests/reek/seeds_users.rb @@ -0,0 +1,4 @@ +users = [] +users << User.create!(email: 'admin@example.com', password: 'adminadmin') +g_admin = Group.create!(name: 'admin') +g_admin.users << users.first diff --git a/ci/ruby_tests/rubocop/Dockerfile b/ci/ruby_tests/rubocop/Dockerfile new file mode 100644 index 0000000..d3dbcea --- /dev/null +++ b/ci/ruby_tests/rubocop/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:jessie + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update -q 2 && apt-get install -y --no-install-recommends git \ + bundler \ + ruby-dev \ + libgmp-dev \ + build-essential \ + nodejs \ + mysql-client +RUN git clone https://repo.grnet.gr/source/webdns.git /srv/webdns +RUN apt-get install -y --no-install-recommends capistrano unicorn rails ruby-mysql2 ruby-jquery-rails +WORKDIR /srv/webdns +RUN bundle install +RUN gem uninstall rubocop && gem install rubocop -v 0.34.2 + +EXPOSE 8080 +COPY seeds_policies.rb / +COPY seeds_users.rb / +COPY entrypoint.sh / +RUN chmod u+x /entrypoint.sh +ENTRYPOINT ["rubocop"] diff --git a/ci/ruby_tests/rubocop/entrypoint.sh b/ci/ruby_tests/rubocop/entrypoint.sh new file mode 100644 index 0000000..46863c9 --- /dev/null +++ b/ci/ruby_tests/rubocop/entrypoint.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +if [ -z "${MYSQL_HOST}" ]; then + echo "You need to specify a mysql host." + exit +fi + +MYSQL_DATABASE=${MYSQL_DATABASE-dns} +MYSQL_USER=${MYSQL_USER-dns} +MYSQL_PORT=${MYSQL_PORT-3306} +MYSQL_PASSWORD=${MYSQL_PASSWORD-12345} + +MYSQL_TEST_DATABASE="${MYSQL_DATABASE}_test" + +sleep 20 + +cat << EOF > /srv/webdns/config/database.yml +development: + database: ${MYSQL_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} + +test: + database: ${MYSQL_TEST_DATABASE} + adapter: mysql2 + encoding: utf8 + username: ${MYSQL_USER} + password: ${MYSQL_PASSWORD} + host: ${MYSQL_HOST} +EOF + +/usr/bin/rake db:migrate +/usr/bin/rails runner /seeds_users.rb +#/usr/bin/rails runner seeds_policies.rb +cd /srv/webdns +rake test diff --git a/ci/ruby_tests/rubocop/seeds_policies.rb b/ci/ruby_tests/rubocop/seeds_policies.rb new file mode 100644 index 0000000..31aed85 --- /dev/null +++ b/ci/ruby_tests/rubocop/seeds_policies.rb @@ -0,0 +1,133 @@ +policies = {} +policies[:default] = <<-POLICY + + + + A default policy that will amaze you and your friends + + PT7200S + PT259200S + + PT1209600S + PT1209600S + + PT43200S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT3600S + PT3600S + PT3600S + PT1209600S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT7776000S + SoftHSM + 0 + + + + PT43200S + + PT3600S + PT3600S + unixtime + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY +policies[:lab] = <<-POLICY + + + + Quick turnaround policy for lab work + + PT600S + PT1800S + + PT3600S + PT3600S + + PT60S + PT3600S + + + + PT8640000S + + 1 + 5 + + + + + + PT300S + PT360S + PT360S + PT432000S + + 8 + PT31536000S + SoftHSM + 0 + + + 8 + PT14400S + SoftHSM + 0 + + + + PT30S + + PT300S + PT300S + counter + + + + PT9999S + + PT3600S + + + PT172800S + PT10800S + + + + +POLICY + +policies.each_pair { |name, policy| + DnssecPolicy.create(name: name, policy: policy) +} diff --git a/ci/ruby_tests/rubocop/seeds_users.rb b/ci/ruby_tests/rubocop/seeds_users.rb new file mode 100644 index 0000000..fe4e228 --- /dev/null +++ b/ci/ruby_tests/rubocop/seeds_users.rb @@ -0,0 +1,4 @@ +users = [] +users << User.create!(email: 'admin@example.com', password: 'adminadmin') +g_admin = Group.create!(name: 'admin') +g_admin.users << users.first diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml index af213d5..8a803e0 100644 --- a/docker-compose-ci.yml +++ b/docker-compose-ci.yml @@ -1,76 +1,103 @@ --- version: '2' services: mysql: image: mysql:5.5 env_file: - env environment: - MYSQL_RANDOM_ROOT_PASSWORD=yes powerdns: build: powerdns/. depends_on: - mysql ports: - '53:53' env_file: - env environment: - MYSQL_HOST=mysql webdns: build: webdns/. depends_on: - mysql ports: - '3000:3000' env_file: - env environment: - MYSQL_HOST=mysql - RAILS_ENV=development volumes: - ./data/webdns:/srv/webdns reverse-proxy: image: traefik command: --api --docker ports: - "81:80" - "8081:8080" volumes: - /var/run/docker.sock:/var/run/docker.sock + webdns4_bundle_helper: + build: ci/bundle_helper/. + env_file: + - env + environment: + - RAILS_ENV=test + volumes: + - ./data/webdns:/srv/webdns + webdns-rake-test: - build: webdns/. + build: ci/ruby_tests/rake/. depends_on: - mysql ports: - '3000:3000' env_file: - env environment: - MYSQL_HOST=mysql - RAILS_ENV=test volumes: - ./data/webdns:/srv/webdns + webdns-rubocop-test: + build: ci/ruby_tests/rubocop/. + env_file: + - env + environment: + - RAILS_ENV=test + volumes: + - ./data/webdns:/srv/webdns + + webdns-reek-test: + build: ci/ruby_tests/reek/. + env_file: + - env + environment: + - RAILS_ENV=test + volumes: + - ./data/webdns:/srv/webdns + webdns-browser-test: build: webdns/. depends_on: - mysql ports: - '3000:3000' env_file: - env environment: - MYSQL_HOST=mysql - RAILS_ENV=development volumes: - ./data/webdns:/srv/webdns labels: - traefik.frontend.rule=Host:web.dns.local user: ${CURRENT_UID}