Run tests on all supported platforms

This commit is contained in:
Jyri-Petteri Paloposki 2020-08-26 00:38:06 +03:00
parent 042075d1e8
commit e89511aec8
11 changed files with 237 additions and 6 deletions

View file

@ -1,11 +1,38 @@
---
name: Continuous Integration
name: Automated tests
on: pull_request
jobs:
test:
test25mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: bash -x script/cibuild
- run: bash -x script/cibuild 2.5 mysql
test26mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: bash -x script/cibuild 2.6 mysql
test27mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: bash -x script/cibuild 2.7 mysql
test26postgres:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: bash -x script/cibuild 2.6 postgres
test26sqlite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: bash -x script/cibuild 2.6 sqlite
# - run: bash -x script/cibuild 2.5 postgres
# - run: bash -x script/cibuild 2.7 postgres

30
Dockerfile-2.5 Normal file
View file

@ -0,0 +1,30 @@
FROM ruby:2.5
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /app
RUN touch /etc/app-env
COPY Gemfile* /app/
RUN gem install bundler
RUN bundle install --jobs 4
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn
RUN mkdir /app/log
COPY . /app/
COPY config/database.docker.yml /app/config/database.yml
COPY config/site.docker.yml /app/config/site.yml
RUN RAILS_ENV=production bundle exec rake assets:precompile
ENTRYPOINT ["/app/docker-entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]

30
Dockerfile-2.7 Normal file
View file

@ -0,0 +1,30 @@
FROM ruby:2.7
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /app
RUN touch /etc/app-env
COPY Gemfile* /app/
RUN gem install bundler
RUN bundle install --jobs 4
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn
RUN mkdir /app/log
COPY . /app/
COPY config/database.docker.yml /app/config/database.yml
COPY config/site.docker.yml /app/config/site.yml
RUN RAILS_ENV=production bundle exec rake assets:precompile
ENTRYPOINT ["/app/docker-entrypoint.sh"]
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]

View file

@ -24,6 +24,7 @@ gem 'jquery-ui-rails' , '~>6.0.1'
# Alternatively use --without <group> arguments to bundler to not install that group
gem "sqlite3", group: :sqlite
gem "mysql2", "~> 0.5.3", group: :mysql
gem "pg", "~> 1.2.3", group: :postgresql
gem "RedCloth"
gem "sanitize", "~> 5.2"
@ -70,7 +71,6 @@ group :test do
gem 'rails-controller-testing'
gem 'rails-dom-testing', '~> 2.0.0'
gem "factory_bot_rails"
gem "rspec-expectations"
gem "database_cleaner"

View file

@ -165,6 +165,7 @@ GEM
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
pg (1.2.3)
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.3)
@ -326,6 +327,7 @@ DEPENDENCIES
mocha
mysql2 (~> 0.5.3)
paperclip
pg (~> 1.2.3)
puma (~> 4.3)
rack-mini-profiler
rails (~> 6.0.3)

View file

@ -2,7 +2,7 @@
set -e
docker_compose="docker-compose --file docker-compose.yml"
docker_compose="docker-compose --file test-envs/docker-compose-$1-$2.yml"
function cleanup() {
$docker_compose down
@ -25,6 +25,12 @@ script/poll-for-db
# Leaving this in since it will be needed for Rails 5
$docker_compose run web bin/rails db:environment:set RAILS_ENV=test || true
$docker_compose run web bin/rake db:reset
if [ "$2" == "mysql" ];
then
$docker_compose run web bin/rake db:reset
else
$docker_compose run web bin/rake db:migrate
$docker_compose run web bin/rake db:seed
fi
$docker_compose run web bin/rake test

View file

@ -0,0 +1,29 @@
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
volumes:
- db-data:/var/lib/mysql
web:
build:
context: ..
dockerfile: Dockerfile-2.5
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
DATABASE_NAME: $DATABASE_NAME
DATABASE_USERNAME: root
DATABASE_PASSWORD_EMPTY: 1
volumes:
- ${VOLUME:-..}:/app:Z
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
ports:
- 3000:3000
depends_on:
- db
volumes:
db-data:

View file

@ -0,0 +1,29 @@
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
volumes:
- db-data:/var/lib/mysql
web:
build:
context: ..
dockerfile: Dockerfile
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
DATABASE_NAME: $DATABASE_NAME
DATABASE_USERNAME: root
DATABASE_PASSWORD_EMPTY: 1
volumes:
- ${VOLUME:-..}:/app:Z
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
ports:
- 3000:3000
depends_on:
- db
volumes:
db-data:

View file

@ -0,0 +1,32 @@
version: '3'
services:
db:
image: postgres:13
environment:
POSTGRES_DB: ${DATABASE_NAME:-tracks}
POSTGRES_PASSWORD: password
volumes:
- db-data:/var/lib/postgresql/data
web:
build:
context: ..
dockerfile: Dockerfile
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
DATABASE_NAME: $DATABASE_NAME
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: password
DATABASE_TYPE: postgresql
DATABASE_ENCODING: unicode
DATABASE_PORT: 5432
volumes:
- ${VOLUME:-..}:/app:Z
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
ports:
- 3000:3000
depends_on:
- db
volumes:
db-data:

View file

@ -0,0 +1,17 @@
version: '3'
services:
web:
build:
context: ..
dockerfile: Dockerfile
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
DATABASE_NAME: "/app/db.sqlite"
DATABASE_TYPE: sqlite3
volumes:
- ${VOLUME:-..}:/app:Z
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
ports:
- 3000:3000

View file

@ -0,0 +1,29 @@
version: '3'
services:
db:
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
volumes:
- db-data:/var/lib/mysql
web:
build:
context: ..
dockerfile: Dockerfile-2.7
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
DATABASE_NAME: $DATABASE_NAME
DATABASE_USERNAME: root
DATABASE_PASSWORD_EMPTY: 1
volumes:
- ${VOLUME:-..}:/app:Z
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
ports:
- 3000:3000
depends_on:
- db
volumes:
db-data: