Skip to content
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

Drhuffman12 update to ruby 3 and dockerize #1

Merged
merged 7 commits into from
Oct 30, 2021
Merged
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
91 changes: 91 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Tests
on: [push]
# on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-20.04
services:
postgres:
image: postgres:10
# The postgres container requires the postgres user to be setup with a password in order to start it due to security
# reasons
env:
POSTGRES_PASSWORD: postgres
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
# ruby-version: 2.7.3
ruby-version: 3.0.2
# bundler-cache: true
# - name: Install Bundler
# run: gem install bundler:2.2.22
# - run: bundle exec rake # TODO: Why is this change not showing up in CI?
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: 16.11.1
- name: Setup the Rails application
env:
RAILS_ENV: test
run: |
sudo apt-get -yqq install libpq-dev
bundle config set --local deployment 'false'
bundle install --jobs 4 --retry 3
cp config/database.github.yml config/database.yml
bundle exec rails db:create
bundle exec rails db:migrate
yarn --frozen-lockfile

# - name: Run linters
# run: |
# bundle exec rubocop --parallel
# # bin/stylelint
# # bin/prettier
# # bin/eslint

# - name: Run security checks
# run: |
# bin/bundler-audit --update
# bin/brakeman -q -w2

- name: Run unit tests
run: bundle exec rails test
# - name: Run integration tests
# run: bundle exec cucumber

# - uses: actions/cache@v2
# with:
# path: vendor/bundle
# key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
# restore-keys: |
# ${{ runner.os }}-gems-
# # https://github.com/actions/cache/blob/9c77c9dbfc97cd17e1add865174d4622362960f2/examples.md#node---yarn-2
# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
# - name: Setup the Rails application
# env:
# RAILS_ENV: test
# run: |
# sudo apt-get -yqq install libpq-dev
# bundle config path vendor/bundle
# bundle install --no-deployment --jobs 4 --retry 3
# cp config/database.github.yml config/database.yml
# bundle exec rails db:create
# bundle exec rails db:migrate
# yarn --frozen-lockfile
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# syntax=docker/dockerfile:1
# FROM ruby:2.7
FROM ruby:3.0.2

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 -qq\
&& apt-get install -y nodejs postgresql-client\
&& apt install --no-install-recommends yarn

WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
RUN yarn install

# check versions
RUN ruby --version
RUN rails --version
RUN node --version
RUN yarn --version

# RUN rails webpacker:install # Run in container's console.

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

# Configure the main process to run when running the image
CMD ["rails", "server", "-b", "0.0.0.0"]
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.3'
# ruby '2.7.3'
ruby '3.0.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.3'
Expand Down Expand Up @@ -76,3 +77,5 @@ gem 'ofx', '~> 0.3.2' , github: 'annacruz/ofx', branch: 'master'
gem 'font-awesome-sass', '~> 5.12.0'
gem 'activerecord_where_assoc', '~> 1.0'


gem "rubocop", "~> 1.22"
Loading