diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fdcca75 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI + +on: + pull_request: + push: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby-3.2.5 + bundler-cache: true + + - name: Lint code for consistent style + run: bin/rubocop -f github + + test: + runs-on: ubuntu-latest + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips sqlite3 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ruby-3.2.5 + bundler-cache: true + + - name: Run tests + env: + RAILS_ENV: test + # REDIS_URL: redis://localhost:6379/0 + run: bin/rails test + + - name: Keep screenshots from failed system tests + uses: actions/upload-artifact@v4 + if: failure() + with: + name: screenshots + path: ${{ github.workspace }}/tmp/screenshots + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore index 09e0435..a3ee5aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ -.bundle/ -log/*.log -pkg/ -test/dummy/db/*.sqlite3 -test/dummy/db/*.sqlite3-journal -test/dummy/log/*.log -test/dummy/tmp/ -/Gemfile.lock +/.bundle/ +/doc/ +/log/*.log +/pkg/ +/tmp/ +/test/dummy/db/*.sqlite3 +/test/dummy/db/*.sqlite3-* +/test/dummy/log/*.log +/test/dummy/storage/ +/test/dummy/tmp/ diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3c869df --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,12 @@ +require: + - standard + +inherit_gem: + standard: config/base.yml + +AllCops: + NewCops: enable + Exclude: + - node_modules/**/* + - test/dummy/**/* + - vendor/bundle/**/* diff --git a/Appraisals b/Appraisals index 7a9cdbd..1a69d73 100644 --- a/Appraisals +++ b/Appraisals @@ -1,3 +1,11 @@ appraise "rails-7.0" do gem "rails", "~> 7.0.0" end + +appraise "rails-7.1" do + gem "rails", "~> 7.1.0" +end + +appraise "rails-7.2" do + gem "rails", "~> 7.2.0" +end diff --git a/Rakefile b/Rakefile index 7e11b1e..4fda60f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,4 @@ -begin - require "bundler/setup" -rescue LoadError - puts "You must `gem install bundler` and `bundle install` to run rake tasks" -end +require "bundler/setup" require "rdoc/task" @@ -14,13 +10,12 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include("lib/**/*.rb") end -APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) load "rails/tasks/engine.rake" load "rails/tasks/statistics.rake" require "bundler/gem_tasks" - require "rake/testtask" require "standard/rake" diff --git a/TAGS b/TAGS new file mode 100644 index 0000000..fc34e3e --- /dev/null +++ b/TAGS @@ -0,0 +1,287 @@ + +.dir-locals.el,0 + +.envrc,0 + +.standard.yml,0 + +app/controllers/spinnaker/sidekiq/application_controller.rb,145 +module SpinnakerSpinnaker1,0 + module SidekiqSidekiq2,17 + class ApplicationController < ActionController::BaseApplicationController3,34 + +app/controllers/spinnaker/sidekiq/api_controller.rb,357 +module SpinnakerSpinnaker4,85 + module SidekiqSidekiq5,102 + class ApiController < ApplicationControllerApiController6,119 + def quiet_allquiet_all13,371 + def statusstatus20,625 + def terminate_allterminate_all34,1050 + def authenticateauthenticate45,1332 + def api_authentication_tokenapi_authentication_token54,1685 + +test/dummy/app/mailers/application_mailer.rb,67 +class ApplicationMailer < ActionMailer::BaseApplicationMailer1,0 + +test/dummy/app/models/application_record.rb,67 +class ApplicationRecord < ActiveRecord::BaseApplicationRecord1,0 + +test/dummy/app/models/concerns/.keep,0 + +test/dummy/app/jobs/application_job.rb,58 +class ApplicationJob < ActiveJob::BaseApplicationJob1,0 + +test/dummy/app/controllers/application_controller.rb,79 +class ApplicationController < ActionController::BaseApplicationController1,0 + +test/dummy/app/controllers/concerns/.keep,0 + +test/dummy/app/views/layouts/application.html.erb,0 + +test/dummy/app/views/layouts/mailer.html.erb,0 + +test/dummy/app/views/layouts/mailer.text.erb,0 + +test/dummy/app/assets/config/manifest.js,0 + +test/dummy/app/assets/images/.keep,0 + +test/dummy/app/assets/javascripts/cable.js,50 +(function() {anonymousFunctionc8adf8bc01008,254 + +test/dummy/app/assets/javascripts/application.js,0 + +test/dummy/app/assets/javascripts/channels/.keep,0 + +test/dummy/app/assets/stylesheets/application.css,0 + +test/dummy/app/helpers/application_helper.rb,47 +module ApplicationHelperApplicationHelper1,0 + +test/dummy/app/channels/application_cable/connection.rb,112 +module ApplicationCableApplicationCable1,0 + class Connection < ActionCable::Connection::BaseConnection2,24 + +test/dummy/app/channels/application_cable/channel.rb,103 +module ApplicationCableApplicationCable1,0 + class Channel < ActionCable::Channel::BaseChannel2,24 + +test/dummy/bin/update,109 +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)APP_ROOT7,111 +def system!(*args)system!9,173 + +test/dummy/bin/rake,0 + +test/dummy/bin/setup,90 +APP_ROOT = File.expand_path("..", __dir__)APP_ROOT5,74 +def system!(*args)system!7,118 + +test/dummy/bin/bundle,0 + +test/dummy/bin/yarn,63 +VENDOR_PATH = File.expand_path('..', __dir__)VENDOR_PATH2,20 + +test/dummy/bin/rails,76 +APP_PATH = File.expand_path("../config/application", __dir__)APP_PATH2,20 + +test/dummy/config/secrets.yml,0 + +test/dummy/config/routes.rb,0 + +test/dummy/config/locales/en.yml,111 + hello: "Hello world"hello33,825 + hello: "Hello world"hello33,825 + hello: "Hello world"en.hello33,825 + +test/dummy/config/cable.yml,0 + +test/dummy/config/environments/production.rb,0 + +test/dummy/config/environments/development.rb,0 + +test/dummy/config/environments/test.rb,0 + +test/dummy/config/spring.rb,0 + +test/dummy/config/environment.rb,0 + +test/dummy/config/storage.yml,0 + +test/dummy/config/application.rb,85 +module DummyDummy9,192 + class Application < Rails::ApplicationApplication10,205 + +test/dummy/config/puma.rb,0 + +test/dummy/config/database.yml,32 +default: &defaultdefault7,122 + +test/dummy/config/boot.rb,0 + +test/dummy/config/initializers/application_controller_renderer.rb,0 + +test/dummy/config/initializers/backtrace_silencers.rb,0 + +test/dummy/config/initializers/mime_types.rb,0 + +test/dummy/config/initializers/filter_parameter_logging.rb,0 + +test/dummy/config/initializers/wrap_parameters.rb,0 + +test/dummy/config/initializers/cookies_serializer.rb,0 + +test/dummy/config/initializers/permissions_policy.rb,0 + +test/dummy/config/initializers/content_security_policy.rb,0 + +test/dummy/config/initializers/inflections.rb,0 + +test/dummy/config/initializers/new_framework_defaults_7_0.rb,0 + +test/dummy/config.ru,0 + +test/dummy/Rakefile,0 + +test/dummy/public/favicon.ico,0 + +test/dummy/public/422.html,199 + The change you wanted was rejected (422)The change you wanted was rejected (422)4,30 +

The change you wanted was rejected.

The change you wanted was rejected.61,1461 + +test/dummy/public/apple-touch-icon.png,0 + +test/dummy/public/500.html,211 + We're sorry, but something went wrong (500)We're sorry, but something went wrong (500)4,30 +

We're sorry, but something went wrong.

We're sorry, but something went wrong.61,1464 + +test/dummy/public/404.html,235 + The page you were looking for doesn't exist (404)The page you were looking for doesn't exist (404)4,30 +

The page you were looking for doesn't exist.

The page you were looking for doesn't exist.61,1470 + +test/dummy/public/apple-touch-icon-precomposed.png,0 + +test/dummy/package.json,99 + "name": "dummy",name2,2 + "private": true,private3,21 + "dependencies": {}dependencies4,40 + +test/dummy/lib/assets/.keep,0 + +test/dummy/db/schema.rb,0 + +test/dummy/db/migrate/20241022192403_create_active_storage_variant_records.active_storage.rb,246 +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]CreateActiveStorageVariantRecords2,71 + def changechange3,142 + def primary_key_typeprimary_key_type17,698 + def blobs_primary_key_typeblobs_primary_key_type22,846 + +test/dummy/db/migrate/20241022192402_add_service_name_to_active_storage_blobs.active_storage.rb,153 +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0]AddServiceNameToActiveStorageBlobs2,71 + def upup3,143 + def downdown17,586 + +test/dummy/db/migrate/20241022192404_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb,152 +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0]RemoveNotNullOnActiveStorageBlobsChecksum2,71 + def changechange3,150 + +test/dummy/log/test.log,0 + +test/dummy/log/.keep,0 + +test/dummy/log/development.log,0 + +test/dummy/tmp/pids/.keep,0 + +test/dummy/tmp/.keep,0 + +test/dummy/tmp/storage/.keep,0 + +test/dummy/tmp/local_secret.txt,0 + +test/spinnaker/sidekiq_test.rb,67 +class Spinnaker::Sidekiq::Test < ActiveSupport::TestCaseTest3,23 + +test/test_helper.rb,0 + +test/controllers/spinnaker/sidekiq/api_controller_test.rb,147 +module SpinnakerSpinnaker3,23 + module SidekiqSidekiq4,40 + class ApiControllerTest < ActionDispatch::IntegrationTestApiControllerTest5,57 + +bin/test,0 + +bin/standardrb,0 + +bin/rubocop,0 + +bin/rails,245 +ENGINE_ROOT = File.expand_path("..", __dir__)ENGINE_ROOT5,146 +ENGINE_PATH = File.expand_path("../lib/spinnaker/sidekiq/engine", __dir__)ENGINE_PATH6,192 +APP_PATH = File.expand_path("../test/dummy/config/application", __dir__)APP_PATH7,267 + +config/routes.rb,0 + +gemfiles/rails_7.0.gemfile.lock,0 + +gemfiles/rails_7.0.gemfile,0 + +gemfiles/.bundle/config,0 + +spinnaker-sidekiq.gemspec,55 + s.name = "spinnaker-sidekiq"spinnaker-sidekiq8,194 + +.tool-versions,0 + +.byebug_history,0 + +script/test,0 + +TAGS,0 + +README.md,163 +# Spinnaker::SidekiqSpinnaker::Sidekiq1,0 +## InstallationInstallation5,106 +## UsageUsage22,317 +## ContributingContributing48,938 +## LicenseLicense51,988 + +Rakefile,168 +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)APP_RAKEFILE17,367 +Rake::TestTask.new(:test) do |t|test28,582 +task default: :testdefault34,693 + +.github/workflows/ci.yml,0 + +lib/tasks/spinnaker/sidekiq_tasks.rake,0 + +lib/spinnaker/sidekiq/engine.rb,108 +module SpinnakerSpinnaker1,0 + module SidekiqSidekiq2,17 + class Engine < ::Rails::EngineEngine3,34 + +lib/spinnaker/sidekiq/version.rb,96 +module SpinnakerSpinnaker1,0 + module SidekiqSidekiq2,17 + VERSION = "0.2.0"VERSION3,34 + +lib/spinnaker/sidekiq.rb,677 +module SpinnakerSpinnaker3,36 + module SidekiqSidekiq4,53 + class MissingApiToken < StandardErrorMissingApiToken5,70 + def initialize(msg = "Set SPINNAKER_SIDEKIQ_API_TOKEN environment variable or Spinnaker::Sinitialize6,112 + attr_writer :api_token, :shutdown_signal_ttl, :terminate_callbackapi_token=12,278 + attr_writer :api_token, :shutdown_signal_ttl, :terminate_callbackshutdown_signal_ttl=12,278 + attr_writer :api_token, :shutdown_signal_ttl, :terminate_callbackterminate_callback=12,278 + def api_tokenapi_token14,351 + def shutdown_signal_ttlshutdown_signal_ttl18,472 + def terminate_callbackterminate_callback22,606 + +Gemfile,0 + +.rubocop.yml,0 + +Gemfile.lock,0 + +MIT-LICENSE,0 + +Appraisals,0 diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000..4eb7d7b --- /dev/null +++ b/bin/rake @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rake' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..40330c0 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/test b/bin/test new file mode 100755 index 0000000..5516a12 --- /dev/null +++ b/bin/test @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +$: << File.expand_path("../test", __dir__) + +require "bundler/setup" +require "rails/plugin/test" diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..fbb2570 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "byebug", group: [:development, :test] +gem "rails", "~> 7.1.0" + +gemspec path: "../" diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock new file mode 100644 index 0000000..d1773a5 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile.lock @@ -0,0 +1,281 @@ +PATH + remote: .. + specs: + spinnaker-sidekiq (0.2.0) + rails (>= 5.0) + sidekiq (>= 4.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.1.4.2) + actionpack (= 7.1.4.2) + activesupport (= 7.1.4.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.1.4.2) + actionpack (= 7.1.4.2) + activejob (= 7.1.4.2) + activerecord (= 7.1.4.2) + activestorage (= 7.1.4.2) + activesupport (= 7.1.4.2) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.1.4.2) + actionpack (= 7.1.4.2) + actionview (= 7.1.4.2) + activejob (= 7.1.4.2) + activesupport (= 7.1.4.2) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.4.2) + actionview (= 7.1.4.2) + activesupport (= 7.1.4.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.4.2) + actionpack (= 7.1.4.2) + activerecord (= 7.1.4.2) + activestorage (= 7.1.4.2) + activesupport (= 7.1.4.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.1.4.2) + activesupport (= 7.1.4.2) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.4.2) + activesupport (= 7.1.4.2) + globalid (>= 0.3.6) + activemodel (7.1.4.2) + activesupport (= 7.1.4.2) + activerecord (7.1.4.2) + activemodel (= 7.1.4.2) + activesupport (= 7.1.4.2) + timeout (>= 0.4.0) + activestorage (7.1.4.2) + actionpack (= 7.1.4.2) + activejob (= 7.1.4.2) + activerecord (= 7.1.4.2) + activesupport (= 7.1.4.2) + marcel (~> 1.0) + activesupport (7.1.4.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + minitest (>= 5.1) + mutex_m + tzinfo (~> 2.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + builder (3.3.0) + byebug (11.1.3) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + drb (2.2.1) + erubi (1.13.0) + gem-release (2.2.2) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.7.4) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) + logger (1.6.1) + loofah (2.23.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + mini_mime (1.1.5) + minitest (5.25.1) + mutex_m (0.2.0) + net-imap (0.5.0) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + psych (5.1.2) + stringio + racc (1.8.1) + rack (3.1.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.4.2) + actioncable (= 7.1.4.2) + actionmailbox (= 7.1.4.2) + actionmailer (= 7.1.4.2) + actionpack (= 7.1.4.2) + actiontext (= 7.1.4.2) + actionview (= 7.1.4.2) + activejob (= 7.1.4.2) + activemodel (= 7.1.4.2) + activerecord (= 7.1.4.2) + activestorage (= 7.1.4.2) + activesupport (= 7.1.4.2) + bundler (>= 1.15.0) + railties (= 7.1.4.2) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.1.4.2) + actionpack (= 7.1.4.2) + activesupport (= 7.1.4.2) + irb + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + redis-client (0.22.2) + connection_pool + regexp_parser (2.9.2) + reline (0.5.10) + io-console (~> 0.5) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + rubocop-performance (1.22.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (1.13.0) + sidekiq (7.3.4) + connection_pool (>= 2.3.0) + logger + rack (>= 2.2.4) + redis-client (>= 0.22.2) + sqlite3 (2.1.1-aarch64-linux-gnu) + sqlite3 (2.1.1-aarch64-linux-musl) + sqlite3 (2.1.1-arm-linux-gnu) + sqlite3 (2.1.1-arm-linux-musl) + sqlite3 (2.1.1-arm64-darwin) + sqlite3 (2.1.1-x86-linux-gnu) + sqlite3 (2.1.1-x86-linux-musl) + sqlite3 (2.1.1-x86_64-darwin) + sqlite3 (2.1.1-x86_64-linux-gnu) + sqlite3 (2.1.1-x86_64-linux-musl) + standard (1.41.1) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.66.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.5) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.5.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.22.0) + stringio (3.1.1) + thor (1.3.2) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.6.0) + webrick (1.8.2) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.7.1) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + appraisal + byebug + gem-release + rails (~> 7.1.0) + spinnaker-sidekiq! + sqlite3 + standard + +BUNDLED WITH + 2.5.19 diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile new file mode 100644 index 0000000..de42935 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "byebug", group: [:development, :test] +gem "rails", "~> 7.2.0" + +gemspec path: "../" diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock new file mode 100644 index 0000000..c91fb99 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile.lock @@ -0,0 +1,246 @@ +PATH + remote: .. + specs: + spinnaker-sidekiq (0.2.0) + rails (>= 5.0) + sidekiq (>= 4.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.2.1.2) + actionpack (= 7.2.1.2) + activesupport (= 7.2.1.2) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (7.2.1.2) + actionpack (= 7.2.1.2) + activejob (= 7.2.1.2) + activerecord (= 7.2.1.2) + activestorage (= 7.2.1.2) + activesupport (= 7.2.1.2) + mail (>= 2.8.0) + actionmailer (7.2.1.2) + actionpack (= 7.2.1.2) + actionview (= 7.2.1.2) + activejob (= 7.2.1.2) + activesupport (= 7.2.1.2) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (7.2.1.2) + actionview (= 7.2.1.2) + activesupport (= 7.2.1.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4, < 3.2) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (7.2.1.2) + actionpack (= 7.2.1.2) + activerecord (= 7.2.1.2) + activestorage (= 7.2.1.2) + activesupport (= 7.2.1.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.2.1.2) + activesupport (= 7.2.1.2) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.2.1.2) + activesupport (= 7.2.1.2) + globalid (>= 0.3.6) + activemodel (7.2.1.2) + activesupport (= 7.2.1.2) + activerecord (7.2.1.2) + activemodel (= 7.2.1.2) + activesupport (= 7.2.1.2) + timeout (>= 0.4.0) + activestorage (7.2.1.2) + actionpack (= 7.2.1.2) + activejob (= 7.2.1.2) + activerecord (= 7.2.1.2) + activesupport (= 7.2.1.2) + marcel (~> 1.0) + activesupport (7.2.1.2) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.2) + base64 (0.2.0) + bigdecimal (3.1.8) + builder (3.3.0) + byebug (11.1.3) + concurrent-ruby (1.3.4) + connection_pool (2.4.1) + crass (1.0.6) + date (3.3.4) + drb (2.2.1) + erubi (1.13.0) + gem-release (2.2.2) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.7.4) + language_server-protocol (3.17.0.3) + lint_roller (1.1.0) + logger (1.6.1) + loofah (2.23.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + mini_mime (1.1.5) + minitest (5.25.1) + net-imap (0.5.0) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + psych (5.1.2) + stringio + racc (1.8.1) + rack (3.1.8) + rack-session (2.0.0) + rack (>= 3.0.0) + rack-test (2.1.0) + rack (>= 1.3) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.2.1.2) + actioncable (= 7.2.1.2) + actionmailbox (= 7.2.1.2) + actionmailer (= 7.2.1.2) + actionpack (= 7.2.1.2) + actiontext (= 7.2.1.2) + actionview (= 7.2.1.2) + activejob (= 7.2.1.2) + activemodel (= 7.2.1.2) + activerecord (= 7.2.1.2) + activestorage (= 7.2.1.2) + activesupport (= 7.2.1.2) + bundler (>= 1.15.0) + railties (= 7.2.1.2) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.2.1.2) + actionpack (= 7.2.1.2) + activesupport (= 7.2.1.2) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) + redis-client (0.22.2) + connection_pool + regexp_parser (2.9.2) + reline (0.5.10) + io-console (~> 0.5) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + rubocop-performance (1.22.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (1.13.0) + securerandom (0.3.1) + sidekiq (7.3.4) + connection_pool (>= 2.3.0) + logger + rack (>= 2.2.4) + redis-client (>= 0.22.2) + sqlite3 (2.1.1-arm64-darwin) + standard (1.41.1) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.66.0) + standard-custom (~> 1.0.0) + standard-performance (~> 1.5) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.5.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.22.0) + stringio (3.1.1) + thor (1.3.2) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (2.6.0) + useragent (0.16.10) + webrick (1.8.2) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.7.1) + +PLATFORMS + arm64-darwin + +DEPENDENCIES + appraisal + byebug + gem-release + rails (~> 7.2.0) + spinnaker-sidekiq! + sqlite3 + standard + +BUNDLED WITH + 2.5.19 diff --git a/lib/spinnaker/sidekiq.rb b/lib/spinnaker/sidekiq.rb index c637acd..90dce6e 100644 --- a/lib/spinnaker/sidekiq.rb +++ b/lib/spinnaker/sidekiq.rb @@ -1,3 +1,4 @@ +require "spinnaker/sidekiq/version" require "spinnaker/sidekiq/engine" module Spinnaker diff --git a/spinnaker-sidekiq.gemspec b/spinnaker-sidekiq.gemspec index 720a2c7..ff1b10e 100644 --- a/spinnaker-sidekiq.gemspec +++ b/spinnaker-sidekiq.gemspec @@ -1,7 +1,4 @@ -$:.push File.expand_path("../lib", __FILE__) - -# Maintain your gem's version: -require "spinnaker/sidekiq/version" +require_relative "lib/spinnaker/sidekiq/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| diff --git a/test/controllers/spinnaker/sidekiq/api_controller_test.rb b/test/controllers/spinnaker/sidekiq/api_controller_test.rb index 46053ab..0877741 100644 --- a/test/controllers/spinnaker/sidekiq/api_controller_test.rb +++ b/test/controllers/spinnaker/sidekiq/api_controller_test.rb @@ -75,6 +75,7 @@ class ApiControllerTest < ActionDispatch::IntegrationTest ::Sidekiq::ProcessSet.stub :new, [process] do post "/spinnaker/sidekiq/quiet_all", headers: {"HTTP_AUTHORIZATION" => @credentials} + assert_response :success end end diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index e85f913..9a5ea73 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js index 19dc561..2fdba71 100644 --- a/test/dummy/app/assets/config/manifest.js +++ b/test/dummy/app/assets/config/manifest.js @@ -1,5 +1,3 @@ - //= link_tree ../images -//= link_directory ../javascripts .js //= link_directory ../stylesheets .css //= link spinnaker_sidekiq_manifest.js diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 1c07694..0d95db2 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ class ApplicationController < ActionController::Base - protect_from_forgery with: :exception + # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. + allow_browser versions: :modern end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb index a009ace..d394c3d 100644 --- a/test/dummy/app/jobs/application_job.rb +++ b/test/dummy/app/jobs/application_job.rb @@ -1,2 +1,7 @@ class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb index 286b223..3c34c81 100644 --- a/test/dummy/app/mailers/application_mailer.rb +++ b/test/dummy/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb index 10a4cba..b63caeb 100644 --- a/test/dummy/app/models/application_record.rb +++ b/test/dummy/app/models/application_record.rb @@ -1,3 +1,3 @@ class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true + primary_abstract_class end diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index a6eb017..9c59674 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -1,11 +1,19 @@ - Dummy + <%= content_for(:title) || "Dummy" %> + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> + <%= yield :head %> + + + + + + <%= stylesheet_link_tag "application" %> diff --git a/test/dummy/app/views/layouts/mailer.html.erb b/test/dummy/app/views/layouts/mailer.html.erb index cbd34d2..3aac900 100644 --- a/test/dummy/app/views/layouts/mailer.html.erb +++ b/test/dummy/app/views/layouts/mailer.html.erb @@ -1,7 +1,7 @@ - + diff --git a/test/dummy/app/views/pwa/manifest.json.erb b/test/dummy/app/views/pwa/manifest.json.erb new file mode 100644 index 0000000..a3c046e --- /dev/null +++ b/test/dummy/app/views/pwa/manifest.json.erb @@ -0,0 +1,22 @@ +{ + "name": "Dummy", + "icons": [ + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512" + }, + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512", + "purpose": "maskable" + } + ], + "start_url": "/", + "display": "standalone", + "scope": "/", + "description": "Dummy.", + "theme_color": "red", + "background_color": "red" +} diff --git a/test/dummy/app/views/pwa/service-worker.js b/test/dummy/app/views/pwa/service-worker.js new file mode 100644 index 0000000..b3a13fb --- /dev/null +++ b/test/dummy/app/views/pwa/service-worker.js @@ -0,0 +1,26 @@ +// Add a service worker for processing Web Push notifications: +// +// self.addEventListener("push", async (event) => { +// const { title, options } = await event.data.json() +// event.waitUntil(self.registration.showNotification(title, options)) +// }) +// +// self.addEventListener("notificationclick", function(event) { +// event.notification.close() +// event.waitUntil( +// clients.matchAll({ type: "window" }).then((clientList) => { +// for (let i = 0; i < clientList.length; i++) { +// let client = clientList[i] +// let clientPath = (new URL(client.url)).pathname +// +// if (clientPath == event.notification.data.path && "focus" in client) { +// return client.focus() +// } +// } +// +// if (clients.openWindow) { +// return clients.openWindow(event.notification.data.path) +// } +// }) +// ) +// }) diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup index ec47b79..027ead2 100755 --- a/test/dummy/bin/setup +++ b/test/dummy/bin/setup @@ -1,11 +1,11 @@ #!/usr/bin/env ruby require "fileutils" -# path to your application root. APP_ROOT = File.expand_path("..", __dir__) +APP_NAME = "dummy" def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end FileUtils.chdir APP_ROOT do @@ -30,4 +30,8 @@ FileUtils.chdir APP_ROOT do puts "\n== Restarting application server ==" system! "bin/rails restart" + + # puts "\n== Configuring puma-dev ==" + # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}" + # system "curl -Is https://#{APP_NAME}.test/up | head -n 1" end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index f7ba0b5..4a3c09a 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -1,5 +1,6 @@ # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application +Rails.application.load_server diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index cbca596..4b5ce8c 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -8,8 +8,18 @@ module Dummy class Application < Rails::Application - # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.0 + config.load_defaults Rails::VERSION::STRING.to_f + + # For compatibility with applications that use this config + config.action_controller.include_all_helpers = false + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + + if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 1 + config.autoload_lib(ignore: %w[assets tasks]) + end # Configuration for the application, engines, and railties goes here. # diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 2820116..116591a 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,3 +1,5 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +# Set up gems listed in the Gemfile. +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) -require "bundler/setup" # Set up gems listed in the Gemfile. +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) +$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) diff --git a/test/dummy/config/cable.yml b/test/dummy/config/cable.yml index d3dfabd..98367f8 100644 --- a/test/dummy/config/cable.yml +++ b/test/dummy/config/cable.yml @@ -2,9 +2,9 @@ development: adapter: async test: - adapter: async + adapter: test production: adapter: redis - url: redis://localhost:6379/1 + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: dummy_production diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 0d02f24..01bebb5 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -1,8 +1,8 @@ -# SQLite version 3.x +# SQLite. Versions 3.8.0 and up are supported. # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile -# gem 'sqlite3' +# gem "sqlite3" # default: &default adapter: sqlite3 @@ -11,15 +11,22 @@ default: &default development: <<: *default - database: db/development.sqlite3 + database: storage/development.sqlite3 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: storage/test.sqlite3 + +# SQLite3 write its data on the local filesystem, as such it requires +# persistent disks. If you are deploying to a managed service, you should +# make sure it provides disk persistence, as many don't. +# +# Similarly, if you deploy your application as a Docker container, you must +# ensure the database is located in a persisted volume. production: <<: *default - database: db/production.sqlite3 + # database: path/to/persistent/storage/production.sqlite3 diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 8d1635e..da5f9df 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -6,7 +6,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -14,7 +14,7 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable server timing + # Enable server timing. config.server_timing = true # Enable/disable caching. By default caching is disabled. @@ -24,9 +24,7 @@ config.action_controller.enable_fragment_cache_logging = true config.cache_store = :memory_store - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.to_i}" - } + config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{2.days.to_i}"} else config.action_controller.perform_caching = false @@ -39,8 +37,12 @@ # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false + config.action_mailer.default_url_options = {host: "localhost", port: 3000} + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log @@ -56,13 +58,23 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations. # config.i18n.raise_on_missing_translations = true # Annotate rendered view with file names. - # config.action_view.annotate_rendered_view_with_filenames = true + config.action_view.annotate_rendered_view_with_filenames = true # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions. + if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 1 + config.action_controller.raise_on_missing_callback_actions = true + end end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index 83a5a16..8a87570 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -4,7 +4,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -13,16 +13,21 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. + # config.public_file_server.enabled = false + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fall back to assets pipeline if a precompiled asset is missed. + config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.asset_host = "http://assets.example.com" @@ -39,23 +44,38 @@ # config.action_cable.url = "wss://example.com/cable" # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true - # Include generic and useful information about system operation, but avoid logging too much - # information to avoid inadvertent exposure of personally identifiable information (PII). - config.log_level = :info + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + + # Log to STDOUT by default + config.logger = ActiveSupport::Logger.new(STDOUT) + .tap { |logger| logger.formatter = ::Logger::Formatter.new } + .then { |logger| ActiveSupport::TaggedLogging.new(logger) } # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] + # "info" includes generic and useful information about system operation, but avoids logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). If you + # want to log everything, set the level to "debug". + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). - # config.active_job.queue_adapter = :resque + # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "dummy_production" + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -69,19 +89,14 @@ # Don't log any deprecations. config.active_support.report_deprecations = false - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Use a different logger for distributed setups. - # require "syslog/logger" - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") - - if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 6ea4d1e..b9a1a7c 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -8,27 +8,25 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # Turn false under Spring and add config.action_view.cache_template_loading = true. - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Eager loading loads your whole application. When running a single test locally, - # this probably isn't necessary. It's a good idea to do in a continuous integration - # system, or in some way before deploying your code. + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. config.eager_load = ENV["CI"].present? # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.to_i}" - } + config.public_file_server.headers = {"Cache-Control" => "public, max-age=#{1.hour.to_i}"} # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false @@ -36,6 +34,8 @@ # Store uploaded files on the local file system in a temporary directory. config.active_storage.service = :test + # Disable caching for Action Mailer templates even if Action Controller + # caching is enabled. config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. @@ -43,6 +43,10 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Unlike controllers, the mailer instance doesn't have any context about the + # incoming request so you'll need to provide the :host parameter yourself. + config.action_mailer.default_url_options = {host: "www.example.com"} + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr @@ -57,4 +61,9 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 1 + config.action_controller.raise_on_missing_callback_actions = true + end end diff --git a/test/dummy/config/initializers/content_security_policy.rb b/test/dummy/config/initializers/content_security_policy.rb index 54f47cf..b3076b3 100644 --- a/test/dummy/config/initializers/content_security_policy.rb +++ b/test/dummy/config/initializers/content_security_policy.rb @@ -16,9 +16,9 @@ # # policy.report_uri "/csp-violation-report-endpoint" # end # -# # Generate session nonces for permitted importmap and inline scripts +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } -# config.content_security_policy_nonce_directives = %w(script-src) +# config.content_security_policy_nonce_directives = %w(script-src style-src) # # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index adc6568..c010b83 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -1,8 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure parameters to be filtered from the log file. Use this to limit dissemination of -# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported -# notations and behaviors. +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. Rails.application.config.filter_parameters += [ - :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn ] diff --git a/test/dummy/config/initializers/permissions_policy.rb b/test/dummy/config/initializers/permissions_policy.rb index 00f64d7..7db3b95 100644 --- a/test/dummy/config/initializers/permissions_policy.rb +++ b/test/dummy/config/initializers/permissions_policy.rb @@ -1,11 +1,13 @@ +# Be sure to restart your server when you modify this file. + # Define an application-wide HTTP permissions policy. For further -# information see https://developers.google.com/web/updates/2018/06/feature-policy -# -# Rails.application.config.permissions_policy do |f| -# f.camera :none -# f.gyroscope :none -# f.microphone :none -# f.usb :none -# f.fullscreen :self -# f.payment :self, "https://secure.example.com" +# information see: https://developers.google.com/web/updates/2018/06/feature-policy + +# Rails.application.config.permissions_policy do |policy| +# policy.camera :none +# policy.gyroscope :none +# policy.microphone :none +# policy.usb :none +# policy.fullscreen :self +# policy.payment :self, "https://secure.example.com" # end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml index decc5a8..6c349ae 100644 --- a/test/dummy/config/locales/en.yml +++ b/test/dummy/config/locales/en.yml @@ -1,14 +1,14 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. +# Files in the config/locales directory are used for internationalization and +# are automatically loaded by Rails. If you want to use locales other than +# English, add the necessary files in this directory. # # To use the locales, use `I18n.t`: # -# I18n.t 'hello' +# I18n.t "hello" # # In views, this is aliased to just `t`: # -# <%= t('hello') %> +# <%= t("hello") %> # # To use a different locale, set it with `I18n.locale`: # @@ -16,18 +16,16 @@ # # This would use the information in config/locales/es.yml. # -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. # -# true, false, on, off, yes, no +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: # -# Instead, surround them with single quotes. -# -# en: -# 'true': 'foo' -# -# To learn more, please read the Rails Internationalization guide -# available at http://guides.rubyonrails.org/i18n.html. +# en: +# "yes": yup +# enabled: "ON" en: hello: "Hello world" diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb index 1e19380..03c166f 100644 --- a/test/dummy/config/puma.rb +++ b/test/dummy/config/puma.rb @@ -1,56 +1,34 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -# -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -threads threads_count, threads_count +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. # -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# to prioritize throughput over latency. # -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. # -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. # -# preload_app! - -# If you are preloading your application and using Active Record, it's -# recommended that you close any connections to the database before workers -# are forked to prevent connection leakage. -# -# before_fork do -# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) -# end +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads threads_count, threads_count -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted, this block will be run. If you are using the `preload_app!` -# option, you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, as Ruby -# cannot share connections between processes. -# -# on_worker_boot do -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -# end -# +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT", 3000) -# Allow puma to be restarted by `rails restart` command. +# Allow puma to be restarted by `bin/rails restart` command. plugin :tmp_restart + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/test/dummy/db/migrate/20241022192402_add_service_name_to_active_storage_blobs.active_storage.rb b/test/dummy/db/migrate/20241022192402_add_service_name_to_active_storage_blobs.active_storage.rb deleted file mode 100644 index a15c6ce..0000000 --- a/test/dummy/db/migrate/20241022192402_add_service_name_to_active_storage_blobs.active_storage.rb +++ /dev/null @@ -1,22 +0,0 @@ -# This migration comes from active_storage (originally 20190112182829) -class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] - def up - return unless table_exists?(:active_storage_blobs) - - unless column_exists?(:active_storage_blobs, :service_name) - add_column :active_storage_blobs, :service_name, :string - - if configured_service = ActiveStorage::Blob.service.name - ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) - end - - change_column :active_storage_blobs, :service_name, :string, null: false - end - end - - def down - return unless table_exists?(:active_storage_blobs) - - remove_column :active_storage_blobs, :service_name - end -end diff --git a/test/dummy/db/migrate/20241022192403_create_active_storage_variant_records.active_storage.rb b/test/dummy/db/migrate/20241022192403_create_active_storage_variant_records.active_storage.rb deleted file mode 100644 index 94ac83a..0000000 --- a/test/dummy/db/migrate/20241022192403_create_active_storage_variant_records.active_storage.rb +++ /dev/null @@ -1,27 +0,0 @@ -# This migration comes from active_storage (originally 20191206030411) -class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] - def change - return unless table_exists?(:active_storage_blobs) - - # Use Active Record's configured type for primary key - create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| - t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type - t.string :variation_digest, null: false - - t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true - t.foreign_key :active_storage_blobs, column: :blob_id - end - end - - private - def primary_key_type - config = Rails.configuration.generators - config.options[config.orm][:primary_key_type] || :primary_key - end - - def blobs_primary_key_type - pkey_name = connection.primary_key(:active_storage_blobs) - pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } - pkey_column.bigint? ? :bigint : pkey_column.type - end -end diff --git a/test/dummy/db/migrate/20241022192404_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/test/dummy/db/migrate/20241022192404_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb deleted file mode 100644 index 93c8b85..0000000 --- a/test/dummy/db/migrate/20241022192404_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +++ /dev/null @@ -1,8 +0,0 @@ -# This migration comes from active_storage (originally 20211119233751) -class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] - def change - return unless table_exists?(:active_storage_blobs) - - change_column_null(:active_storage_blobs, :checksum, true) - end -end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb deleted file mode 100644 index d9bdd36..0000000 --- a/test/dummy/db/schema.rb +++ /dev/null @@ -1,14 +0,0 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# This file is the source Rails uses to define your schema when running `bin/rails -# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to -# be faster and is potentially less error prone than running all of your -# migrations from scratch. Old migrations may fail to apply correctly if those -# migrations use external dependencies or application code. -# -# It's strongly recommended that you check this file into your version control system. - -ActiveRecord::Schema[7.0].define(version: 2024_10_22_192404) do -end diff --git a/test/dummy/public/406-unsupported-browser.html b/test/dummy/public/406-unsupported-browser.html new file mode 100644 index 0000000..7cf1e16 --- /dev/null +++ b/test/dummy/public/406-unsupported-browser.html @@ -0,0 +1,66 @@ + + + + Your browser is not supported (406) + + + + + + +
+
+

Your browser is not supported.

+

Please upgrade your browser to continue.

+
+
+ + diff --git a/test/dummy/public/icon.png b/test/dummy/public/icon.png new file mode 100644 index 0000000..f3b5abc Binary files /dev/null and b/test/dummy/public/icon.png differ diff --git a/test/dummy/public/icon.svg b/test/dummy/public/icon.svg new file mode 100644 index 0000000..78307cc --- /dev/null +++ b/test/dummy/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/test/dummy/storage/.keep b/test/dummy/storage/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/spinnaker/sidekiq_test.rb b/test/spinnaker/sidekiq_test.rb index ff3657a..5d231be 100644 --- a/test/spinnaker/sidekiq_test.rb +++ b/test/spinnaker/sidekiq_test.rb @@ -1,24 +1,7 @@ require "test_helper" -class Spinnaker::Sidekiq::Test < ActiveSupport::TestCase - teardown do - Spinnaker::Sidekiq.api_token = nil - ENV.delete("SPINNAKER_SIDEKIQ_API_TOKEN") - end - - test "api_token must be set" do - assert_raises Spinnaker::Sidekiq::MissingApiToken do - Spinnaker::Sidekiq.api_token - end - end - - test "api_token can be set with environment variable" do - ENV["SPINNAKER_SIDEKIQ_API_TOKEN"] = "env-var" - assert_equal "env-var", Spinnaker::Sidekiq.api_token - end - - test "api_token can be set on the module" do - Spinnaker::Sidekiq.api_token = "module" - assert_equal "module", Spinnaker::Sidekiq.api_token +class Spinnaker::SidekiqTest < ActiveSupport::TestCase + test "it has a version number" do + assert Spinnaker::Sidekiq::VERSION end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 919cfee..74233b9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,31 +1,19 @@ # Configure Rails Environment ENV["RAILS_ENV"] = "test" -require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) -ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] -ActiveRecord::Migrator.migrations_paths << File.expand_path("../../db/migrate", __FILE__) -require "rails/test_help" -# Filter out Minitest backtrace while allowing backtrace from other libraries -# to be shown. -Minitest.backtrace_filter = Minitest::BacktraceFilter.new +require_relative "../test/dummy/config/environment" +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__) +require "rails/test_help" # Load fixtures from the engine -if ActiveSupport::TestCase.respond_to?(:fixture_path=) - ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) - ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path - ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" +if ActiveSupport::TestCase.respond_to?(:fixture_paths=) + ActiveSupport::TestCase.fixture_paths = [File.expand_path("fixtures", __dir__)] + ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths + ActiveSupport::TestCase.file_fixture_path = File.expand_path("fixtures", __dir__) + "/files" ActiveSupport::TestCase.fixtures :all end -# Enable protect from forgery when running tests. -# -# This is needed since that is the default on ActionController::Base -# from Rails 5.2 On previous applications it would be defined on the -# application's ApplicationController which wouldn't affect the engine -Spinnaker::Sidekiq::ApplicationController.class_eval do - protect_from_forgery with: :exception -end - require "sidekiq" require "sidekiq/testing" require "sidekiq/api"