Skip to content

Commit

Permalink
Update tests and tested versions to cover Ruby 3.4 and Rails 8 (#832)
Browse files Browse the repository at this point in the history
* Update rack with newly released version

* Add rails8 test fixture

* Add controllers to rails8 fixture

* Enable rails8 docker container to run

* Ensure the correct jobs are present

* Ensure bugsnag is installed in the rack app

* Ensure filter parameter is present

* Add exception to active job breadcrumb in rails 8

* Fix typo, remove 3.4 support

* Fix typo in skip method

* Downgrade to ruby 3.3 for rails tests

* Fix added ruby step

* Update tests for recent ruby ecosystem changes

* Use correct strings for version declarations

* Add base64 gem back into rails

* Add logger gem back into rails

* Add bigdecimal to 3.4 tests and use working version of sqlite3 in rails 6

* Add timeout to maze-runner runs

* Add side-case for Ruby 3.4 hash inspect change

* Skip JRuby test problematic on CI - See PLAT-13407

* Ensure rails_env is present in db config

* Update timestamp step to be more comprehensive

* Move rails8 to sql without bindings

* Use Ruby 3.4 as the latest version for running tests

* Disable didyoumean for rails8 test runs

* Test rails 6 & 7 on Ruby 3.4, update steps for different format of rails error message
  • Loading branch information
Cawllec authored Jan 16, 2025
1 parent 54acb0d commit f771d0b
Show file tree
Hide file tree
Showing 150 changed files with 2,830 additions and 89 deletions.
38 changes: 30 additions & 8 deletions .github/workflows/maze-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['1.9', '3.3']
ruby-version: ['1.9', '3.4']

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
rack-version: '2'
- ruby-version: '2.4'
rack-version: '3'
- ruby-version: '3.3'
- ruby-version: '3.4'
rack-version: '3'

uses: ./.github/workflows/run-maze-runner.yml
Expand All @@ -62,6 +62,12 @@ jobs:
que-version: '1'
- ruby-version: '2.7'
que-version: '1'
- ruby-version: '2.7'
que-version: '2'
- ruby-version: '3.0'
que-version: '2'
- ruby-version: '3.4'
que-version: '2'

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand All @@ -76,7 +82,7 @@ jobs:
ruby-version: ['2.5', '2.7']
sidekiq-version: ['2', '3', '4', '5', '6', '7']
include:
- ruby-version: '3.3'
- ruby-version: '3.4'
sidekiq-version: '7'
exclude:
# 2.7 is the minimum ruby version that sidekiq 7 supports
Expand All @@ -93,7 +99,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.5']
ruby-version: ['2.5', '3.4']

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand Down Expand Up @@ -123,19 +129,35 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
rails-version: ${{ matrix.rails-version }}

rails-6-7-integrations-maze-runner:
rails-6-7-maze-runner:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.3']
rails-version: ['6', '7', '_integrations']
rails-version: ['6', '7']
include:
- ruby-version: '2.5'
rails-version: '6'
exclude:
- ruby-version: '2.7'
rails-version: '6'
- ruby-version: '3.3'

uses: ./.github/workflows/run-maze-runner.yml
with:
features: features/rails_features/ --tags @rails${{ matrix.rails-version }}
ruby-version: ${{ matrix.ruby-version }}
rails-version: ${{ matrix.rails-version }}

rails-8-integrations-maze-runner:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.4']
rails-version: ['8', '_integrations']
exclude:
- ruby-version: '2.7'
rails-version: '8'
- ruby-version: '3.4'
rails-version: '_integrations'

uses: ./.github/workflows/run-maze-runner.yml
Expand All @@ -148,7 +170,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run-maze-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:
jobs:
maze-runner:
runs-on: ubuntu-latest
timeout-minutes: 30

env:
BUNDLE_GEMFILE: Gemfile-maze-runner
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
optional-groups: ['test sidekiq']
include:
- ruby-version: '1.9'
os: 'ubuntu-20.04'
optional-groups: 'test'
- ruby-version: '2.0'
optional-groups: 'test'
Expand Down
44 changes: 44 additions & 0 deletions features/fixtures/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,50 @@ services:
- target: 3000
published: 7257

rails8:
build:
context: rails8
args:
- RUBY_TEST_VERSION
depends_on:
- mongo
environment:
- BUGSNAG_API_KEY
- http_proxy
- RAILS_ENV
- BUGSNAG_APP_TYPE
- BUGSNAG_APP_VERSION
- BUGSNAG_AUTO_CAPTURE_SESSIONS
- BUGSNAG_AUTO_NOTIFY
- BUGSNAG_ENDPOINT
- BUGSNAG_IGNORE_CLASS
- BUGSNAG_IGNORE_MESSAGE
- BUGSNAG_META_DATA_FILTERS
- BUGSNAG_NOTIFY_RELEASE_STAGE
- BUGSNAG_PROJECT_ROOT
- BUGSNAG_PROXY_HOST
- BUGSNAG_PROXY_PASSWORD
- BUGSNAG_PROXY_PORT
- BUGSNAG_PROXY_USER
- BUGSNAG_RELEASE_STAGE
- BUGSNAG_SEND_CODE
- BUGSNAG_SEND_ENVIRONMENT
- BUGSNAG_SESSION_ENDPOINT
- BUGSNAG_TIMEOUT
- CALLBACK_INITIATOR
- SQL_ONLY_BREADCRUMBS
- ADD_ON_ERROR
- USE_DEFAULT_AUTO_CAPTURE_SESSIONS
- ADD_REQUEST_ON_ERROR
restart: "no"
networks:
default:
aliases:
- rails8
ports:
- target: 3000
published: 7258

rails_integrations:
build:
context: rails_integrations
Expand Down
2 changes: 1 addition & 1 deletion features/fixtures/rails6/app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3', '>= 1.3.6'
gem 'sqlite3', '~> 1.4.4'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
Expand Down
3 changes: 3 additions & 0 deletions features/fixtures/rails8/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore the lock file so that we always use an up to date version. This won't
# exist unless the fixtures are run manually anyway.
app/Gemfile.lock
30 changes: 30 additions & 0 deletions features/fixtures/rails8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
ARG RUBY_TEST_VERSION
FROM ruby:$RUBY_TEST_VERSION

RUN apt-get update

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 install -y nodejs yarn

WORKDIR /bugsnag
COPY temp-bugsnag-lib ./

WORKDIR /usr/src/app
COPY app/Gemfile /usr/src/app/
RUN bundle install

RUN cat Gemfile.lock

COPY app/ /usr/src/app

RUN bundle exec rake db:migrate

RUN mv /usr/src/app/bin-copy /usr/src/app/bin

# RUN bundle exec rake rails:update:bin

ENV RUBYOPT='--disable-did_you_mean'

CMD ["bundle", "exec", "bin/rails", "s", "-b", "0.0.0.0"]
47 changes: 47 additions & 0 deletions features/fixtures/rails8/app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.

# Ignore git directory.
/.git/
/.gitignore

# Ignore bundler config.
/.bundle

# Ignore all environment files.
/.env*

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep

# Ignore assets.
/node_modules/
/app/assets/builds/*
!/app/assets/builds/.keep
/public/assets

# Ignore CI service files.
/.github

# Ignore development files
/.devcontainer

# Ignore Docker-related files
/.dockerignore
/Dockerfile*
7 changes: 7 additions & 0 deletions features/fixtures/rails8/app/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
31 changes: 31 additions & 0 deletions features/fixtures/rails8/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# Temporary files generated by your text editor or operating system
# belong in git's global ignore instead:
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`

# Ignore bundler config.
/.bundle

# Ignore all environment files.
/.env*

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore storage (uploaded files in development and any SQLite databases).
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/
!/tmp/storage/.keep

/public/assets
8 changes: 8 additions & 0 deletions features/fixtures/rails8/app/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Omakase Ruby styling for Rails
inherit_gem: { rubocop-rails-omakase: rubocop.yml }

# Overwrite or add rules to create your own house style
#
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
1 change: 1 addition & 0 deletions features/fixtures/rails8/app/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.5
72 changes: 72 additions & 0 deletions features/fixtures/rails8/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# syntax=docker/dockerfile:1
# check=error=true

# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
# docker build -t app .
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name app app

# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.5
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base

# Rails app lives here
WORKDIR /rails

# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"

# Throw-away build stage to reduce size of final image
FROM base AS build

# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile

# Copy application code
COPY . .

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile




# Final stage for app image
FROM base

# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp
USER 1000:1000

# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start server via Thruster by default, this can be overwritten at runtime
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
Loading

0 comments on commit f771d0b

Please sign in to comment.