Skip to content

Commit 52c9d2f

Browse files
committed
8.1.0.beta1
1 parent 0577e54 commit 52c9d2f

25 files changed

+147
-55
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ updates:
33
- package-ecosystem: bundler
44
directory: "/"
55
schedule:
6-
interval: daily
6+
interval: weekly
77
open-pull-requests-limit: 10
88
- package-ecosystem: github-actions
99
directory: "/"
1010
schedule:
11-
interval: daily
11+
interval: weekly
1212
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,57 @@ jobs:
1111

1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
1515

1616
- name: Set up Ruby
1717
uses: ruby/setup-ruby@v1
1818
with:
19-
ruby-version: .ruby-version
2019
bundler-cache: true
2120

2221
- name: Scan for common Rails security vulnerabilities using static analysis
2322
run: bin/brakeman --no-pager
2423

24+
- name: Scan for known security vulnerabilities in gems used
25+
run: bin/bundler-audit
26+
2527
scan_js:
2628
runs-on: ubuntu-latest
2729

2830
steps:
2931
- name: Checkout code
30-
uses: actions/checkout@v4
32+
uses: actions/checkout@v5
3133

3234
- name: Set up Ruby
3335
uses: ruby/setup-ruby@v1
3436
with:
35-
ruby-version: .ruby-version
3637
bundler-cache: true
3738

3839
- name: Scan for security vulnerabilities in JavaScript dependencies
3940
run: bin/importmap audit
4041

4142
lint:
4243
runs-on: ubuntu-latest
44+
env:
45+
RUBOCOP_CACHE_ROOT: tmp/rubocop
4346
steps:
4447
- name: Checkout code
45-
uses: actions/checkout@v4
48+
uses: actions/checkout@v5
4649

4750
- name: Set up Ruby
4851
uses: ruby/setup-ruby@v1
4952
with:
50-
ruby-version: .ruby-version
5153
bundler-cache: true
5254

55+
- name: Prepare RuboCop cache
56+
uses: actions/cache@v4
57+
env:
58+
DEPENDENCIES_HASH: ${{ hashFiles('.ruby-version', '**/.rubocop.yml', '**/.rubocop_todo.yml', 'Gemfile.lock') }}
59+
with:
60+
path: ${{ env.RUBOCOP_CACHE_ROOT }}
61+
key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }}
62+
restore-keys: |
63+
rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-
64+
5365
- name: Lint code for consistent style
5466
run: bin/rubocop -f github
5567

@@ -58,28 +70,50 @@ jobs:
5870

5971
# services:
6072
# redis:
61-
# image: redis
73+
# image: valkey/valkey:8
6274
# ports:
6375
# - 6379:6379
6476
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
6577
steps:
66-
- name: Install packages
67-
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config google-chrome-stable
68-
6978
- name: Checkout code
70-
uses: actions/checkout@v4
79+
uses: actions/checkout@v5
7180

7281
- name: Set up Ruby
7382
uses: ruby/setup-ruby@v1
7483
with:
75-
ruby-version: .ruby-version
7684
bundler-cache: true
7785

7886
- name: Run tests
7987
env:
8088
RAILS_ENV: test
89+
# RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
90+
# REDIS_URL: redis://localhost:6379/0
91+
run: bin/rails db:test:prepare test
92+
93+
system-test:
94+
runs-on: ubuntu-latest
95+
96+
# services:
97+
# redis:
98+
# image: valkey/valkey:8
99+
# ports:
100+
# - 6379:6379
101+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
102+
steps:
103+
- name: Checkout code
104+
uses: actions/checkout@v5
105+
106+
- name: Set up Ruby
107+
uses: ruby/setup-ruby@v1
108+
with:
109+
bundler-cache: true
110+
111+
- name: Run System Tests
112+
env:
113+
RAILS_ENV: test
114+
# RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
81115
# REDIS_URL: redis://localhost:6379/0
82-
run: bin/rails db:test:prepare test test:system
116+
run: bin/rails db:test:prepare test:system
83117

84118
- name: Keep screenshots from failed system tests
85119
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030

3131
/public/assets
3232

33-
# Ignore master key for decrypting credentials and more.
34-
/config/master.key
33+
# Ignore key files for decrypting credentials and more.
34+
/config/*.key
35+

Dockerfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ WORKDIR /rails
1717
# Install base packages
1818
RUN apt-get update -qq && \
1919
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
20+
ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
2021
rm -rf /var/lib/apt/lists /var/cache/apt/archives
2122

22-
# Set production environment
23+
# Set production environment variables and enable jemalloc for reduced memory usage and latency.
2324
ENV RAILS_ENV="production" \
2425
BUNDLE_DEPLOYMENT="1" \
2526
BUNDLE_PATH="/usr/local/bundle" \
26-
BUNDLE_WITHOUT="development"
27+
BUNDLE_WITHOUT="development" \
28+
LD_PRELOAD="/usr/local/lib/libjemalloc.so"
2729

2830
# Throw-away build stage to reduce size of final image
2931
FROM base AS build
@@ -34,7 +36,8 @@ RUN apt-get update -qq && \
3436
rm -rf /var/lib/apt/lists /var/cache/apt/archives
3537

3638
# Install application gems
37-
COPY Gemfile Gemfile.lock ./
39+
COPY Gemfile Gemfile.lock vendor ./
40+
3841
RUN bundle install && \
3942
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
4043
bundle exec bootsnap precompile --gemfile
@@ -54,16 +57,15 @@ RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
5457
# Final stage for app image
5558
FROM base
5659

57-
# Copy built artifacts: gems, application
58-
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
59-
COPY --from=build /rails /rails
60-
6160
# Run and own only the runtime files as a non-root user for security
6261
RUN groupadd --system --gid 1000 rails && \
63-
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
64-
chown -R rails:rails db log storage tmp
62+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash
6563
USER 1000:1000
6664

65+
# Copy built artifacts: gems, application
66+
COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
67+
COPY --chown=rails:rails --from=build /rails /rails
68+
6769
# Entrypoint prepares the database.
6870
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
6971

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
source "https://rubygems.org"
22

33
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
4-
gem "rails", "~> 8.0.3"
4+
gem "rails", "~> 8.1.0.beta1"
55
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
66
gem "propshaft"
77
# Use sqlite3 as the database for Active Record
@@ -44,6 +44,9 @@ group :development, :test do
4444
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
4545
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
4646

47+
# Audits gems for known security defects (use config/bundler-audit.yml to ignore issues)
48+
gem "bundler-audit", require: false
49+
4750
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
4851
gem "brakeman", require: false
4952

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class ApplicationController < ActionController::Base
22
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
33
allow_browser versions: :modern
4+
5+
# Changes to the importmap will invalidate the etag for HTML responses
6+
stale_when_importmap_changes
47
end

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<title><%= content_for(:title) || "Railsdiff" %></title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
66
<meta name="apple-mobile-web-app-capable" content="yes">
7+
<meta name="application-name" content="Railsdiff">
78
<meta name="mobile-web-app-capable" content="yes">
89
<%= csrf_meta_tags %>
910
<%= csp_meta_tag %>

bin/bundler-audit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "bundler/audit/cli"
4+
5+
ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check")
6+
Bundler::Audit::CLI.start

bin/ci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "active_support/continuous_integration"
4+
5+
CI = ActiveSupport::ContinuousIntegration
6+
require_relative "../config/ci.rb"

bin/docker-entrypoint

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#!/bin/bash -e
22

3-
# Enable jemalloc for reduced memory usage and latency.
4-
if [ -z "${LD_PRELOAD+x}" ]; then
5-
LD_PRELOAD=$(find /usr/lib -name libjemalloc.so.2 -print -quit)
6-
export LD_PRELOAD
7-
fi
8-
93
# If running the rails server then create or migrate existing database
104
if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
115
./bin/rails db:prepare

0 commit comments

Comments
 (0)