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

Get actions working again #133

Merged
merged 7 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 5 additions & 7 deletions .github/workflows/brakeman-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ jobs:
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Customize the ruby version depending on your needs
- name: Setup Ruby
uses: actions/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
ruby-version: '3.3'

- name: Setup Brakeman
env:
BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+
run: |
gem install brakeman --version $BRAKEMAN_VERSION
gem install brakeman

# Execute Brakeman CLI and generate a SARIF output with the security issues identified during the analysis
- name: Scan
Expand All @@ -41,6 +39,6 @@ jobs:

# Upload the SARIF file generated in the previous step
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: output.sarif.json
13 changes: 9 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Run tests

on:
Expand All @@ -8,15 +9,19 @@ on:

jobs:
test:

runs-on: ubuntu-latest

strategy:
matrix:
ruby-version: [2.7, 3.0, truffleruby-head]
ruby-version:
- "2.7"
Copy link
Owner

Choose a reason for hiding this comment

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

I think that we should only keep versions that are still supported (AKA 3.1+ as per https://endoflife.date/ruby)

Maybe also get rid of truffleruby? Can't remember if it was something someone requested compatibility for or if I added just to try and see if it was compatible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm fine to drop older Rubies an EoL'd dependencies in general. Maybe we can do all of that as part of the next major version bump, and include some of the other PRs in it too.

- "3.0"
- "3.1"
- "3.2"
- "3.3"
- truffleruby-head

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Ruby 3.0
- name: Set up Ruby 3.3
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
ruby-version: 3.3

- run: bundle install

Expand Down
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Style/Documentation:
- 'spec/**/*'
- 'test/**/*'
- 'app/controllers/letter_opener_web/letters_controller.rb'
- 'app/controllers/letter_opener_web/application_controller.rb'
- 'app/models/letter_opener_web/letter.rb'
- 'lib/letter_opener_web.rb'
- 'lib/letter_opener_web/delivery_method.rb'
Expand Down
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ source 'http://rubygems.org'
# development dependencies will be added by default to the :development group.
gemspec

group :test do
gem 'codecov', require: false
end
gem 'rails', '~> 6.1'
gem 'rspec-rails', '~> 5.0'
gem 'rubocop', '~> 1.22'
gem 'rubocop-rails', '~> 2.12'
gem 'rubocop-rspec', '~> 2.5'
gem 'shoulda-matchers', '~> 5.0'
4 changes: 2 additions & 2 deletions app/controllers/letter_opener_web/letters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def index

def show
text = @letter.send("#{params[:style]}_text")
.gsub(/"plain\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'plain')}\"")
.gsub(/"rich\.html"/, "\"#{routes.letter_path(id: @letter.id, style: 'rich')}\"")
.gsub('"plain.html"', "\"#{routes.letter_path(id: @letter.id, style: 'plain')}\"")
.gsub('"rich.html"', "\"#{routes.letter_path(id: @letter.id, style: 'rich')}\"")

render html: text.html_safe
end
Expand Down
8 changes: 1 addition & 7 deletions letter_opener_web.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ Gem::Specification.new do |gem|

gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
gem.executables = gem.files.grep(%r{^exe/}).map { |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ['lib']

gem.add_dependency 'actionmailer', '>= 5.2'
Copy link
Owner

Choose a reason for hiding this comment

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

Do u know if 5.x still works with the gem? I wouldn't mind bumping the dep to 6.x or 7.x if it gets into our way

Copy link
Collaborator Author

@stevenharman stevenharman May 13, 2024

Choose a reason for hiding this comment

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

Not sure. I've been using 6.1 since that's what's in the Gemfile, IIRC?

gem.add_dependency 'letter_opener', '~> 1.7'
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good to know. Now that this PR has CI ✅ again, I'm thinking maybe I'll merge it. Then take a pass at dropping older Rubies, updating minimum dependencies, etc… in another PR. Just to keep the PRs smaller and easier to "see" the deltas, if nothing else.

gem.add_dependency 'railties', '>= 5.2'
gem.add_dependency 'rexml'

gem.add_development_dependency 'rails', '~> 6.1'
gem.add_development_dependency 'rspec-rails', '~> 5.0'
gem.add_development_dependency 'rubocop', '~> 1.22'
gem.add_development_dependency 'rubocop-rails', '~> 2.12'
gem.add_development_dependency 'rubocop-rspec', '~> 2.5'
gem.add_development_dependency 'shoulda-matchers', '~> 5.0'
gem.metadata['rubygems_mfa_required'] = 'true'
end
2 changes: 1 addition & 1 deletion lib/letter_opener_web/delivery_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module LetterOpenerWeb
class DeliveryMethod < LetterOpener::DeliveryMethod
def deliver!(mail)
original = ENV['LAUNCHY_DRY_RUN']
original = ENV.fetch('LAUNCHY_DRY_RUN', nil)
ENV['LAUNCHY_DRY_RUN'] = 'true'

super
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
config.active_support.disallowed_deprecation_warnings = []

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new

# Use a different logger for distributed setups.
# require "syslog/logger"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# ActiveSupport::Reloader.to_prepare do
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Define an application-wide content security policy
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/inflections.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format. Inflections
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/mime_types.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Add new mime types for use in respond_to blocks:
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/config/initializers/permissions_policy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Define an application-wide HTTP permissions policy. For further
# information see https://developers.google.com/web/updates/2018/06/feature-policy
#
Expand Down
8 changes: 3 additions & 5 deletions spec/models/letter_opener_web/letter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ def rich_text(mail_id)

%w[1111_1111 2222_2222].each do |folder|
FileUtils.mkdir_p("#{location}/#{folder}")
File.open("#{location}/#{folder}/plain.html", 'w') { |f| f.write("Plain text for #{folder}") }
File.open("#{location}/#{folder}/rich.html", 'w') { |f| f.write(rich_text(folder)) }
File.write("#{location}/#{folder}/plain.html", "Plain text for #{folder}")
File.write("#{location}/#{folder}/rich.html", rich_text(folder))
FileUtils.mkdir_p("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}")
File.open("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}/rich.html", 'w') do |f|
f.write("Rich text for #{folder}")
end
File.write("#{Rails.root.join('tmp', 'letter_opener')}/#{folder}/rich.html", "Rich text for #{folder}")
end
end

Expand Down
8 changes: 0 additions & 8 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.start

if ENV.fetch('CI', '') == 'true'
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
end

require 'shoulda-matchers'

RSpec.configure do |config|
Expand Down
Loading