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

[ISSUE-68] Improved Specs and Added Coverage Report #70

Merged
merged 17 commits into from
Jul 19, 2024
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
87 changes: 10 additions & 77 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,28 @@
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby

name: Test

on: [push]

name: Code Guard
on:
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: read

jobs:
test:

runs-on: ubuntu-20.04

strategy:
matrix:
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
rails-version: ['4.2', '5.0', '5.1', '6.0', '6.1', '7.0', '7.1']
exclude:
# activesupport (~> 6.0.0) was resolved to 6.0.6.1, which depends on ruby (>= 2.5.0)
# activesupport (~> 6.1.0) was resolved to 6.1.7.2, which depends on ruby (>= 2.5.0)
- ruby-version: '2.3'
rails-version: '6.0'
- ruby-version: '2.3'
rails-version: '6.1'
- ruby-version: '2.4'
rails-version: '6.0'
- ruby-version: '2.4'
rails-version: '6.1'
# activesupport (~> 7.0.0) was resolved to 7.0.4.2, which depends on Ruby (>= 2.7.0)
- ruby-version: '2.3'
rails-version: '7.0'
- ruby-version: '2.4'
rails-version: '7.0'
- ruby-version: '2.5'
rails-version: '7.0'
- ruby-version: '2.6'
rails-version: '7.0'
# incompatbility with BigDecimal.new
- ruby-version: '2.7'
rails-version: '4.2'
- ruby-version: '3.0'
rails-version: '4.2'
- ruby-version: '3.1'
rails-version: '4.2'
- ruby-version: '3.2'
rails-version: '4.2'
# ArgumentError: expected attributes to be able to convert to Hash, got "#<Thing:0x000055d208b2e258>"
# probably keyword argument delegation different in Ruby 3
# https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
- ruby-version: '3.0'
rails-version: '5.0'
- ruby-version: '3.0'
rails-version: '5.1'
- ruby-version: '3.1'
rails-version: '5.0'
- ruby-version: '3.1'
rails-version: '5.1'
- ruby-version: '3.2'
rails-version: '5.0'
- ruby-version: '3.2'
rails-version: '5.1'
# rails (~> 7.1.0) was resolved to 7.1.3.2, which depends on Ruby (>= 2.7.0)
- ruby-version: '2.3'
rails-version: '7.1'
- ruby-version: '2.4'
rails-version: '7.1'
- ruby-version: '2.5'
rails-version: '7.1'
- ruby-version: '2.6'
rails-version: '7.1'
# Because rails >= 4.0.0.beta1, < 5.0.5.rc1 depends on bundler >= 1.3.0, < 2.0
# and the current Bundler version (2.5.9) does not satisfy bundler >= 1.3.0, < 2.0,
# rails >= 4.0.0.beta1, < 5.0.5.rc1 cannot be used.
# So, because Gemfile depends on rails ~> 4.2.0,
# version solving has failed.
- ruby-version: '3.3'
rails-version: '4.2'

ruby-version: ['3.0', '3.1', '3.2', '3.3']
rails-version: ['6.1', '7.0', '7.1']
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install bundler 1.x.x
if: matrix.rails-version == '4.2'
run: gem uninstall -aIx bundler && gem install bundler -v 1.17.3
- name: Install dependencies
run: bundle install
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ pkg/*
*DS_Store
.ruby-version
.tool-versions
coverage
.standard_todo.yml
3 changes: 3 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fix: false
parallel: true
ruby_version: 3.0
74 changes: 74 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM bash AS base

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV ASDF_DIR=/root/.asdf

# Install dependencies
RUN apk update && \
apk add --no-cache \
build-base \
git \
libffi-dev \
openssl-dev \
perl \
readline-dev \
tzdata \
yaml-dev \
zlib-dev

RUN git clone https://github.com/asdf-vm/asdf.git /root/.asdf --branch v0.14.0 && \
. "$ASDF_DIR/asdf.sh" && \
asdf plugin add ruby

## For parallelism, build in stages
# Ruby 3.0.7
FROM base AS ruby-3.0.7
RUN . "$ASDF_DIR/asdf.sh" && \
asdf install ruby 3.0.7 && \
asdf global ruby 3.0.7 && \
gem install bundler

# Ruby 3.1.4
FROM base AS ruby-3.1.4
RUN . "$ASDF_DIR/asdf.sh" && \
asdf install ruby 3.1.4 && \
asdf global ruby 3.1.4 && \
gem install bundler

# Ruby 3.2.2
FROM base AS ruby-3.2.2
RUN . "$ASDF_DIR/asdf.sh" && \
asdf install ruby 3.2.2 && \
asdf global ruby 3.2.2 && \
gem install bundler

# Ruby 3.3.4
FROM base AS ruby-3.3.4
RUN . "$ASDF_DIR/asdf.sh" && \
asdf install ruby 3.3.4 && \
asdf global ruby 3.3.4 && \
gem install bundler

# Final Image with Application Code
FROM base AS final

# Copy and merge installed ASDF directory from ruby versions
COPY --from=ruby-3.0.7 /root/.asdf /tmp/.asdf-3.0.7
COPY --from=ruby-3.1.4 /root/.asdf /tmp/.asdf-3.1.4
COPY --from=ruby-3.2.2 /root/.asdf /tmp/.asdf-3.2.2
COPY --from=ruby-3.3.4 /root/.asdf /tmp/.asdf-3.3.4
RUN cp -r /tmp/.asdf-3.0.7/* /root/.asdf/ && \
cp -r /tmp/.asdf-3.1.4/* /root/.asdf/ && \
cp -r /tmp/.asdf-3.2.2/* /root/.asdf/ && \
cp -r /tmp/.asdf-3.3.4/* /root/.asdf/ && \
rm -rf /tmp/.asdf*

WORKDIR /app

COPY gemfiles gemfiles
COPY lib lib
COPY spec spec
COPY cached_resource.gemspec Gemfile Rakefile scripts/docker/run_tests.sh .standard.yml .

CMD ["./run_tests.sh"]
22 changes: 11 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ gemspec
def eval_gemfile(path)
gemfile_local = File.expand_path(path, __FILE__)
if File.readable?(gemfile_local)
puts "Loading #{gemfile_local}..." if ENV['DEBUG']
puts "Loading #{gemfile_local}..." if ENV["DEBUG"]
instance_eval(File.read(gemfile_local))
end
end

puts "\e[93mUsing TEST_RAILS_VERSION #{ENV['TEST_RAILS_VERSION']}\e[0m" if ENV['DEBUG']
case ENV['TEST_RAILS_VERSION']
puts "\e[93mUsing TEST_RAILS_VERSION #{ENV["TEST_RAILS_VERSION"]}\e[0m" if ENV["DEBUG"]
case ENV["TEST_RAILS_VERSION"]
when "4.2"
eval_gemfile('../gemfiles/4.2.gemfile')
eval_gemfile("../gemfiles/4.2.gemfile")
when "5.0"
eval_gemfile('../gemfiles/5.0.gemfile')
eval_gemfile("../gemfiles/5.0.gemfile")
when "5.1"
eval_gemfile('../gemfiles/5.1.gemfile')
eval_gemfile("../gemfiles/5.1.gemfile")
when "6.0"
eval_gemfile('../gemfiles/6.0.gemfile')
eval_gemfile("../gemfiles/6.0.gemfile")
when "6.1"
eval_gemfile('../gemfiles/6.1.gemfile')
eval_gemfile("../gemfiles/6.1.gemfile")
when "7.0"
eval_gemfile('../gemfiles/7.0.gemfile')
eval_gemfile("../gemfiles/7.0.gemfile")
when "7.1"
eval_gemfile('../gemfiles/7.1.gemfile')
eval_gemfile("../gemfiles/7.1.gemfile")
else
puts "\e[93mNo TEST_RAILS_VERSION present, letting dependency manager decide what's best.\e[0m" if ENV['DEBUG']
puts "\e[93mNo TEST_RAILS_VERSION present, letting dependency manager decide what's best.\e[0m" if ENV["DEBUG"]
end
Loading