diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index fa93eef..08775ce 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -8,7 +8,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3.5 + ruby-version: 3.3.7 - name: rubocop uses: reviewdog/action-rubocop@v2 with: @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.3.5 + ruby-version: 3.3.7 - name: reek uses: reviewdog/action-reek@v1 with: diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 064c679..3d7539b 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -14,7 +14,7 @@ jobs: matrix: os: [ubuntu-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ["3.2.5", "3.3.5", truffleruby] + ruby: ["3.2.6", "3.3.7", truffleruby] db: ["mariadb", "mysql", "pg"] runs-on: ${{ matrix.os }} services: @@ -78,7 +78,7 @@ jobs: bin/test - name: Upload coverage - if: ${{ matrix.db == 'pg' && matrix.ruby == '3.2.5' }} + if: ${{ matrix.db == 'pg' && matrix.ruby == '3.2.6' }} uses: actions/upload-artifact@v4 with: name: review.txt diff --git a/.reek.yml b/.reek.yml index 1d23d22..5269b60 100644 --- a/.reek.yml +++ b/.reek.yml @@ -10,3 +10,6 @@ directories: "test": UtilityFunction: enabled: false + +exclude_paths: + - lib/generators/deploy_pin/**/templates/**/*.rb diff --git a/.rubocop.yml b/.rubocop.yml index a3d61f6..1015a4e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,8 @@ inherit_from: .rubocop_todo.yml require: rubocop-minitest AllCops: + Exclude: + - lib/generators/deploy_pin/**/templates/**/*.rb NewCops: disable TargetRubyVersion: 3.1 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7f008b9..b9c2cb9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-10-17 14:41:35 UTC using RuboCop version 1.66.1. +# on 2024-12-31 14:12:31 UTC using RuboCop version 1.69.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -23,12 +23,6 @@ Lint/Void: Metrics/AbcSize: Max: 20 -# Offense count: 2 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 29 - # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: @@ -57,7 +51,7 @@ Security/Eval: Exclude: - 'lib/deploy_pin/task.rb' -# Offense count: 13 +# Offense count: 11 # Configuration parameters: AllowedConstants. Style/Documentation: Exclude: @@ -73,9 +67,7 @@ Style/Documentation: - 'lib/deploy_pin/task.rb' - 'lib/deploy_pin/task_criteria.rb' - 'lib/generators/deploy_pin/install/install_generator.rb' - - 'lib/generators/deploy_pin/install/templates/create_deploy_pins.rb' - 'lib/generators/deploy_pin/task/task_generator.rb' - - 'lib/generators/deploy_pin/upgrade/templates/upgrade_deploy_pins.rb' # Offense count: 2 Style/MixinUsage: @@ -85,7 +77,7 @@ Style/MixinUsage: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https Layout/LineLength: Max: 121 diff --git a/.ruby-version b/.ruby-version index fa7adc7..86fb650 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.5 +3.3.7 diff --git a/Gemfile.lock b/Gemfile.lock index a2c1c74..474502c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,74 +5,74 @@ PATH colorize (~> 1.1) connection_pool (~> 2.2) parallel (~> 1.23) - rails (~> 7.0) + rails (>= 7.0, < 9.0) redis (> 4.0) ruby-progressbar (~> 1.13) GEM remote: https://rubygems.org/ specs: - actioncable (7.2.1.1) - actionpack (= 7.2.1.1) - activesupport (= 7.2.1.1) + actioncable (8.0.1) + actionpack (= 8.0.1) + activesupport (= 8.0.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (7.2.1.1) - actionpack (= 7.2.1.1) - activejob (= 7.2.1.1) - activerecord (= 7.2.1.1) - activestorage (= 7.2.1.1) - activesupport (= 7.2.1.1) + actionmailbox (8.0.1) + actionpack (= 8.0.1) + activejob (= 8.0.1) + activerecord (= 8.0.1) + activestorage (= 8.0.1) + activesupport (= 8.0.1) mail (>= 2.8.0) - actionmailer (7.2.1.1) - actionpack (= 7.2.1.1) - actionview (= 7.2.1.1) - activejob (= 7.2.1.1) - activesupport (= 7.2.1.1) + actionmailer (8.0.1) + actionpack (= 8.0.1) + actionview (= 8.0.1) + activejob (= 8.0.1) + activesupport (= 8.0.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (7.2.1.1) - actionview (= 7.2.1.1) - activesupport (= 7.2.1.1) + actionpack (8.0.1) + actionview (= 8.0.1) + activesupport (= 8.0.1) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) + rack (>= 2.2.4) 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.1) - actionpack (= 7.2.1.1) - activerecord (= 7.2.1.1) - activestorage (= 7.2.1.1) - activesupport (= 7.2.1.1) + actiontext (8.0.1) + actionpack (= 8.0.1) + activerecord (= 8.0.1) + activestorage (= 8.0.1) + activesupport (= 8.0.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.2.1.1) - activesupport (= 7.2.1.1) + actionview (8.0.1) + activesupport (= 8.0.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (7.2.1.1) - activesupport (= 7.2.1.1) + activejob (8.0.1) + activesupport (= 8.0.1) globalid (>= 0.3.6) - activemodel (7.2.1.1) - activesupport (= 7.2.1.1) - activerecord (7.2.1.1) - activemodel (= 7.2.1.1) - activesupport (= 7.2.1.1) + activemodel (8.0.1) + activesupport (= 8.0.1) + activerecord (8.0.1) + activemodel (= 8.0.1) + activesupport (= 8.0.1) timeout (>= 0.4.0) - activestorage (7.2.1.1) - actionpack (= 7.2.1.1) - activejob (= 7.2.1.1) - activerecord (= 7.2.1.1) - activesupport (= 7.2.1.1) + activestorage (8.0.1) + actionpack (= 8.0.1) + activejob (= 8.0.1) + activerecord (= 8.0.1) + activesupport (= 8.0.1) marcel (~> 1.0) - activesupport (7.2.1.1) + activesupport (8.0.1) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -82,31 +82,33 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) ast (2.4.2) base64 (0.2.0) - bigdecimal (3.1.8) + benchmark (0.4.0) + bigdecimal (3.1.9) builder (3.3.0) coderay (1.1.3) colorize (1.1.0) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) crass (1.0.6) - date (3.3.4) + date (3.4.1) docile (1.4.1) drb (2.2.1) - erubi (1.13.0) + erubi (1.13.1) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.6) concurrent-ruby (~> 1.0) - io-console (0.7.2) - irb (1.14.1) + io-console (0.8.0) + irb (1.14.3) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.7.2) + json (2.9.1) language_server-protocol (3.17.0.3) - logger (1.6.1) - loofah (2.23.1) + logger (1.6.5) + loofah (2.24.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -118,9 +120,9 @@ GEM method_source (1.1.0) mini_mime (1.1.5) mini_portile2 (2.8.8) - minitest (5.25.1) + minitest (5.25.4) mysql2 (0.5.6) - net-imap (0.4.16) + net-imap (0.5.5) date net-protocol net-pop (0.1.2) @@ -129,61 +131,60 @@ GEM timeout net-smtp (0.5.0) net-protocol - nio4r (2.7.3) - nokogiri (1.16.8) + nio4r (2.7.4) + nokogiri (1.18.1) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.8-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.8-arm-linux) + nokogiri (1.18.1-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.16.8-x86-linux) + nokogiri (1.18.1-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.16.8-x86_64-linux) + nokogiri (1.18.1-x86_64-linux-gnu) racc (~> 1.4) parallel (1.26.3) - parser (3.3.5.0) + parser (3.3.7.0) ast (~> 2.4.1) racc - pg (1.5.8) - pry (0.14.2) + pg (1.5.9) + pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.1.2) + psych (5.2.3) + date stringio racc (1.8.1) rack (3.1.8) - rack-session (2.0.0) + rack-session (2.1.0) + base64 (>= 0.1.0) rack (>= 3.0.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) - rails (7.2.1.1) - actioncable (= 7.2.1.1) - actionmailbox (= 7.2.1.1) - actionmailer (= 7.2.1.1) - actionpack (= 7.2.1.1) - actiontext (= 7.2.1.1) - actionview (= 7.2.1.1) - activejob (= 7.2.1.1) - activemodel (= 7.2.1.1) - activerecord (= 7.2.1.1) - activestorage (= 7.2.1.1) - activesupport (= 7.2.1.1) + rails (8.0.1) + actioncable (= 8.0.1) + actionmailbox (= 8.0.1) + actionmailer (= 8.0.1) + actionpack (= 8.0.1) + actiontext (= 8.0.1) + actionview (= 8.0.1) + activejob (= 8.0.1) + activemodel (= 8.0.1) + activerecord (= 8.0.1) + activestorage (= 8.0.1) + activesupport (= 8.0.1) bundler (>= 1.15.0) - railties (= 7.2.1.1) + railties (= 8.0.1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.1) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (7.2.1.1) - actionpack (= 7.2.1.1) - activesupport (= 7.2.1.1) + railties (8.0.1) + actionpack (= 8.0.1) + activesupport (= 8.0.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -191,32 +192,32 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) - rdoc (6.7.0) + rdoc (6.11.0) psych (>= 4.0.0) redis (5.3.0) redis-client (>= 0.22.0) - redis-client (0.22.2) + redis-client (0.23.2) connection_pool - regexp_parser (2.9.2) - reline (0.5.10) + regexp_parser (2.10.0) + reline (0.6.0) io-console (~> 0.5) - rubocop (1.66.1) + rubocop (1.70.0) 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) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.37.0) parser (>= 3.3.1.0) rubocop-minitest (0.36.0) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (1.13.0) - securerandom (0.3.1) + securerandom (0.4.1) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -225,18 +226,21 @@ GEM simplecov-review (0.3.0) simplecov (>= 0.21.2, < 0.23) simplecov_json_formatter (0.1.4) - stringio (3.1.1) + stringio (3.1.2) thor (1.3.2) - timeout (0.4.1) + timeout (0.4.3) 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) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + uri (1.0.2) + useragent (0.16.11) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.6.18) + zeitwerk (2.7.1) PLATFORMS linux @@ -255,4 +259,4 @@ DEPENDENCIES simplecov-review BUNDLED WITH - 2.4.21 + 2.5.23 diff --git a/README.md b/README.md index c4b4b14..70e4a9c 100644 --- a/README.md +++ b/README.md @@ -241,5 +241,34 @@ bundle exec rake deploy_pin:run[rollback] - # enters "pending state" ## Contributing Contribution directions go here. +### Running Tests Locally + +To ensure your changes meet the required standards and pass all tests before submitting a pull request, you can simulate the GitHub Actions workflow locally using the [`act`](https://github.com/nektos/act) tool. + +#### Prerequisites + +1. **Install `act`** + Follow the installation guide provided in the official [`act` documentation](https://nektosact.com/installation/index.html). + +2. **Docker** + Ensure Docker is installed and running on your machine. + +#### Running the Workflow + +Use the following command to simulate the workflow locally: + +```bash +act pull_request --secret-file .env --container-architecture linux/amd64 -W .github/workflows -j rspec +``` + +This command does the following: +- `pull_request`: Runs the pull_request workflow defined in your .github/workflows directory. +- `--secret-file .env`: Uses the .env file provided in the repository to load environment variables. +- `--container-architecture linux/amd64`: Ensures compatibility with GitHub Actions runners. +- `-W .github/workflows`: Specifies the directory containing the workflow files. +- `-j rspec`: Runs the `rspec` job defined in the workflow. + +For more details on customizing this command, refer to the [act documentation](https://nektosact.com/). + ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). diff --git a/deploy_pin.gemspec b/deploy_pin.gemspec index 4b9f907..51fdbd3 100644 --- a/deploy_pin.gemspec +++ b/deploy_pin.gemspec @@ -33,7 +33,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'colorize', '~> 1.1' spec.add_dependency 'connection_pool', '~> 2.2' spec.add_dependency 'parallel', '~> 1.23' - spec.add_dependency 'rails', '~> 7.0' + spec.add_dependency 'rails', '>= 7.0', '< 9.0' spec.add_dependency 'redis', '> 4.0' spec.add_dependency 'ruby-progressbar', '~> 1.13' diff --git a/lib/generators/deploy_pin/install/install_generator.rb b/lib/generators/deploy_pin/install/install_generator.rb index 16404a9..add92bc 100644 --- a/lib/generators/deploy_pin/install/install_generator.rb +++ b/lib/generators/deploy_pin/install/install_generator.rb @@ -19,5 +19,13 @@ def copy_migrations def copy_initializer template 'deploy_pin.rb', 'config/initializers/deploy_pin.rb' end + + def activerecord_migration_class + if ::ActiveRecord::Migration.respond_to?(:current_version) + "ActiveRecord::Migration[#{::ActiveRecord::Migration.current_version}]" + else + 'ActiveRecord::Migration' + end + end end end diff --git a/lib/generators/deploy_pin/install/templates/create_deploy_pins.rb b/lib/generators/deploy_pin/install/templates/create_deploy_pins.rb index 5dc0377..6004414 100644 --- a/lib/generators/deploy_pin/install/templates/create_deploy_pins.rb +++ b/lib/generators/deploy_pin/install/templates/create_deploy_pins.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateDeployPins < ActiveRecord::Migration[7.0] +class CreateDeployPins < <%= activerecord_migration_class %> def change create_table :deploy_pins do |t| t.string :uuid