Skip to content

Commit 545b0ea

Browse files
committed
7.2.0.beta1
1 parent 167498e commit 545b0ea

31 files changed

+378
-80
lines changed

.dockerignore

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Ignore git directory.
44
/.git/
5+
/.gitignore
56

67
# Ignore bundler config.
78
/.bundle
@@ -35,3 +36,13 @@
3536
/app/assets/builds/*
3637
!/app/assets/builds/.keep
3738
/public/assets
39+
40+
# Ignore CI service files.
41+
/.github
42+
43+
# Ignore development files
44+
/.devcontainer
45+
46+
# Ignore Docker-related files
47+
/.dockerignore
48+
/Dockerfile*

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: github-actions
9+
directory: "/"
10+
schedule:
11+
interval: daily
12+
open-pull-requests-limit: 10

.github/workflows/ci.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
scan_ruby:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: .ruby-version
20+
bundler-cache: true
21+
22+
- name: Scan for security vulnerabilities in Ruby dependencies
23+
run: bin/brakeman --no-pager
24+
25+
scan_js:
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Ruby
33+
uses: ruby/setup-ruby@v1
34+
with:
35+
ruby-version: .ruby-version
36+
bundler-cache: true
37+
38+
- name: Scan for security vulnerabilities in JavaScript dependencies
39+
run: bin/importmap audit
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: .ruby-version
51+
bundler-cache: true
52+
53+
- name: Lint code for consistent style
54+
run: bin/rubocop -f github
55+
56+
test:
57+
runs-on: ubuntu-latest
58+
59+
# services:
60+
# redis:
61+
# image: redis
62+
# ports:
63+
# - 6379:6379
64+
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
65+
steps:
66+
- name: Install packages
67+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libsqlite3-0 libvips libsqlite3-0
68+
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Ruby
73+
uses: ruby/setup-ruby@v1
74+
with:
75+
ruby-version: .ruby-version
76+
bundler-cache: true
77+
78+
- name: Run tests
79+
env:
80+
RAILS_ENV: test
81+
# REDIS_URL: redis://localhost:6379/0
82+
run: bin/rails db:test:prepare test test:system
83+
84+
- name: Keep screenshots from failed system tests
85+
uses: actions/upload-artifact@v4
86+
if: failure()
87+
with:
88+
name: screenshots
89+
path: ${{ github.workspace }}/tmp/screenshots
90+
if-no-files-found: ignore

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
22
#
3-
# If you find yourself ignoring temporary files generated by your text editor
4-
# or operating system, you probably want to add a global ignore instead:
5-
# git config --global core.excludesfile '~/.gitignore_global'
3+
# Temporary files generated by your text editor or operating system
4+
# belong in git's global ignore instead:
5+
# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore`
66

77
# Ignore bundler config.
88
/.bundle

.rubocop.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Omakase Ruby styling for Rails
2+
inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3+
4+
# Overwrite or add rules to create your own house style
5+
#
6+
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7+
# Layout/SpaceInsideArrayLiteralBrackets:
8+
# Enabled: false

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
your-ruby-version

Dockerfile

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
# syntax = docker/dockerfile:1
22

3-
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
3+
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
4+
# docker build -t my-app .
5+
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
6+
7+
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
8+
9+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
410
ARG RUBY_VERSION=your-ruby-version
5-
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
11+
FROM docker.io/library/ruby:$RUBY_VERSION-slim as base
612

713
# Rails app lives here
814
WORKDIR /rails
915

16+
# Install base packages
17+
RUN apt-get update -qq && \
18+
apt-get install --no-install-recommends -y curl libjemalloc2 libsqlite3-0 libvips && \
19+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
20+
1021
# Set production environment
1122
ENV RAILS_ENV="production" \
1223
BUNDLE_DEPLOYMENT="1" \
1324
BUNDLE_PATH="/usr/local/bundle" \
1425
BUNDLE_WITHOUT="development"
1526

16-
1727
# Throw-away build stage to reduce size of final image
1828
FROM base as build
1929

2030
# Install packages needed to build gems
2131
RUN apt-get update -qq && \
22-
apt-get install --no-install-recommends -y build-essential git libvips pkg-config
32+
apt-get install --no-install-recommends -y build-essential git pkg-config && \
33+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
2334

2435
# Install application gems
2536
COPY Gemfile Gemfile.lock ./
@@ -37,22 +48,20 @@ RUN bundle exec bootsnap precompile app/ lib/
3748
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
3849

3950

51+
52+
4053
# Final stage for app image
4154
FROM base
4255

43-
# Install packages needed for deployment
44-
RUN apt-get update -qq && \
45-
apt-get install --no-install-recommends -y curl libsqlite3-0 libvips && \
46-
rm -rf /var/lib/apt/lists /var/cache/apt/archives
47-
4856
# Copy built artifacts: gems, application
49-
COPY --from=build /usr/local/bundle /usr/local/bundle
57+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
5058
COPY --from=build /rails /rails
5159

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

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

Gemfile

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
source "https://rubygems.org"
22

3-
ruby "your-ruby-version"
4-
53
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
6-
gem "rails", "~> 7.1.5", ">= 7.1.5.1"
7-
4+
gem "rails", "~> 7.2.0.beta1"
85
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
96
gem "sprockets-rails"
10-
117
# Use sqlite3 as the database for Active Record
128
gem "sqlite3", ">= 1.4"
13-
149
# Use the Puma web server [https://github.com/puma/puma]
1510
gem "puma", ">= 5.0"
16-
1711
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
1812
gem "importmap-rails"
19-
2013
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
2114
gem "turbo-rails"
22-
2315
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
2416
gem "stimulus-rails"
25-
2617
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2718
gem "jbuilder"
28-
2919
# Use Redis adapter to run Action Cable in production
3020
# gem "redis", ">= 4.0.1"
3121

@@ -46,18 +36,18 @@ gem "bootsnap", require: false
4636

4737
group :development, :test do
4838
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
49-
gem "debug", platforms: %i[ mri windows ]
39+
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
40+
41+
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
42+
gem "brakeman", require: false
43+
44+
# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
45+
gem "rubocop-rails-omakase", require: false
5046
end
5147

5248
group :development do
5349
# Use console on exceptions pages [https://github.com/rails/web-console]
5450
gem "web-console"
55-
56-
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
57-
# gem "rack-mini-profiler"
58-
59-
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
60-
# gem "spring"
6151
end
6252

6353
group :test do
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
class ApplicationController < ActionController::Base
2+
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3+
allow_browser versions: :modern
24
end

app/views/layouts/application.html.erb

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Railsdiff</title>
4+
<title><%= content_for(:title) || "Railsdiff" %></title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<meta name="apple-mobile-web-app-capable" content="yes">
67
<%= csrf_meta_tags %>
78
<%= csp_meta_tag %>
89

10+
<%= yield :head %>
11+
12+
<link rel="manifest" href="/manifest.json">
13+
<link rel="icon" href="/icon.png" type="image/png">
14+
<link rel="icon" href="/icon.svg" type="image/svg+xml">
15+
<link rel="apple-touch-icon" href="/icon.png">
916
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
1017
</head>
1118

app/views/pwa/manifest.json.erb

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Railsdiff",
3+
"icons": [
4+
{
5+
"src": "/icon.png",
6+
"type": "image/png",
7+
"sizes": "512x512"
8+
},
9+
{
10+
"src": "/icon.png",
11+
"type": "image/png",
12+
"sizes": "512x512",
13+
"purpose": "maskable"
14+
}
15+
],
16+
"start_url": "/",
17+
"display": "standalone",
18+
"scope": "/",
19+
"description": "Railsdiff.",
20+
"theme_color": "red",
21+
"background_color": "red"
22+
}

app/views/pwa/service-worker.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Add a service worker for processing Web Push notifications:
2+
//
3+
// self.addEventListener("push", async (event) => {
4+
// const { title, options } = await event.data.json()
5+
// event.waitUntil(self.registration.showNotification(title, options))
6+
// })
7+
//
8+
// self.addEventListener("notificationclick", function(event) {
9+
// event.notification.close()
10+
// event.waitUntil(
11+
// clients.matchAll({ type: "window" }).then((clientList) => {
12+
// for (let i = 0; i < clientList.length; i++) {
13+
// let client = clientList[i]
14+
// let clientPath = (new URL(client.url)).pathname
15+
//
16+
// if (clientPath == event.notification.data.path && "focus" in client) {
17+
// return client.focus()
18+
// }
19+
// }
20+
//
21+
// if (clients.openWindow) {
22+
// return clients.openWindow(event.notification.data.path)
23+
// }
24+
// })
25+
// )
26+
// })

bin/brakeman

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
ARGV.unshift("--ensure-latest")
6+
7+
load Gem.bin_path("brakeman", "brakeman")

bin/docker-entrypoint

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash -e
22

3+
# Enable jemalloc for reduced memory usage and latency.
4+
if [ -z "${LD_PRELOAD+x}" ] && [ -f /usr/lib/*/libjemalloc.so.2 ]; then
5+
export LD_PRELOAD="$(echo /usr/lib/*/libjemalloc.so.2)"
6+
fi
7+
38
# If running the rails server then create or migrate existing database
49
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
510
./bin/rails db:prepare

bin/rubocop

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env ruby
2+
require "rubygems"
3+
require "bundler/setup"
4+
5+
# explicit rubocop config increases performance slightly while avoiding config confusion.
6+
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7+
8+
load Gem.bin_path("rubocop", "rubocop")

bin/setup

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env ruby
22
require "fileutils"
33

4-
# path to your application root.
54
APP_ROOT = File.expand_path("..", __dir__)
5+
APP_NAME = "railsdiff"
66

77
def system!(*args)
88
system(*args, exception: true)
@@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do
3030

3131
puts "\n== Restarting application server =="
3232
system! "bin/rails restart"
33+
34+
# puts "\n== Configuring puma-dev =="
35+
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
36+
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
3337
end

0 commit comments

Comments
 (0)