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

Drop integration tests for Ruby 2 and Rails 5 #160

Merged
merged 6 commits into from
Aug 23, 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
11 changes: 6 additions & 5 deletions .github/workflows/rails-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ jobs:
outputs:
RAILS_VERSIONS: ${{ steps.compute-outputs.outputs.RAILS_VERSIONS }}
steps:
# Get latest Rails versions for 5.x.x, 6.x.x and 7.x.x
mec marked this conversation as resolved.
Show resolved Hide resolved
# Get latest Rails versions for 6.x.x and 7.x.x
- id: compute-outputs
name: Compute outputs
# fetches current Rails versions numbers > 5 and not 'beta'
run: |
rails_versions=$(curl https://rubygems.org/api/v1/versions/rails.json | jq 'group_by(.number[:1])[] | (.[0].number) | select(.[:1]|tonumber > 4)' | jq -s -c)
rails_versions=$(curl https://rubygems.org/api/v1/versions/rails.json | jq '[.[] | select(.number | test("beta") | not)] | group_by(.number[:1])[] | (.[0].number) | select(.[:1]|tonumber > 5)' | jq -s -c)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the jq syntax well enough to review this line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, me too, I would prefer something less dynamic but more obvious, but happy to trust in this having seen it work.

echo "RAILS_VERSIONS=$rails_versions" >> $GITHUB_OUTPUT
build-rails:
strategy:
fail-fast: false
matrix:
# Build containers with the latest 5.x.x, 6.x.x and 7.x.x Rails versions
# Build containers with the latest 6.x.x and 7.x.x Rails versions
rails: ${{ fromJSON(needs.set-matrix.outputs.RAILS_VERSIONS) }}
runs-on: ubuntu-latest
name: Build and cache Docker containers
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
mailer-previews:
strategy:
fail-fast: false
# Run against the latest 5.x.x, 6.x.x and 7.x.x Rails versions
# Run against the latest 6.x.x and 7.x.x Rails versions
matrix:
rails: ${{ fromJSON(needs.set-matrix.outputs.RAILS_VERSIONS) }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -114,4 +115,4 @@ jobs:
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}
}}
17 changes: 5 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
# We want to support older Rubies
ARG RUBY_VERSION=2.7.8
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
ARG RUBY_VERSION=3.1.6
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# Build stage
FROM base as build
FROM base AS build

# Install packages needed to build gems and node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential curl git

# Install Nokigiri version that supports Ruby 2.7.8
RUN gem install nokogiri -v 1.15.6

# Install Rails
ARG RAILS_VERSION=7.1.3.2
ARG RAILS_VERSION=7.2.1
RUN gem install rails -v ${RAILS_VERSION}

# create empty Rails application, we don't need ActiveRecord or JavaScript
Expand All @@ -27,9 +23,6 @@ WORKDIR mail-notify-integration
# install the gems into the bundle
RUN bundle install

# remove gems that will not work in Rails 5.2.8.1
RUN if [ "${RAILS_VERSION}" = "5.2.8.1" ]; then bundle remove selenium-webdriver chromedriver-helper; fi

# Final stage for app image
FROM base

Expand All @@ -45,7 +38,7 @@ COPY --from=build /rails /rails
WORKDIR /rails/mail-notify-integration

# add Mail Notify to the Gemfile
ARG MAIL_NOTIFY_BRANCH=v2
ARG MAIL_NOTIFY_BRANCH=2.0.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say "we generally pass this argument", do you mean it gets passed in somewhere else, overriding this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, when you build a docker image you can pass in arguments to change the output, it's a common pattern to declare and set a default like this, you see it a lot in this Dockerfile. ARG for images ENV for running containers.

RUN echo "gem 'mail-notify', git: 'https://github.com/dxw/mail-notify', branch: '${MAIL_NOTIFY_BRANCH}'" >> Gemfile

# install the mail-notify gem, we do this here to keep the last container layer small to help caching
Expand Down