]> git.openstreetmap.org Git - rails.git/commitdiff
Switch to using annotaterb for annotations
authorTom Hughes <tom@compton.nu>
Fri, 21 Feb 2025 23:08:25 +0000 (23:08 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 28 Feb 2025 17:22:54 +0000 (17:22 +0000)
.annotaterb.yml [new file with mode: 0644]
.github/workflows/lint.yml
Gemfile
Gemfile.lock
lib/tasks/annotate_rb.rake [new file with mode: 0644]
lib/tasks/auto_annotate_models.rake [deleted file]

diff --git a/.annotaterb.yml b/.annotaterb.yml
new file mode 100644 (file)
index 0000000..ccc1cbf
--- /dev/null
@@ -0,0 +1,58 @@
+---
+:position: before
+:position_in_additional_file_patterns: before
+:position_in_class: before
+:position_in_factory: before
+:position_in_fixture: before
+:position_in_routes: before
+:position_in_serializer: before
+:position_in_test: before
+:classified_sort: false
+:exclude_controllers: true
+:exclude_factories: true
+:exclude_fixtures: true
+:exclude_helpers: true
+:exclude_scaffolds: true
+:exclude_serializers: true
+:exclude_sti_subclasses: false
+:exclude_tests: true
+:force: false
+:format_markdown: false
+:format_rdoc: false
+:format_yard: false
+:frozen: false
+:ignore_model_sub_dir: false
+:ignore_unknown_models: false
+:include_version: false
+:show_check_constraints: false
+:show_complete_foreign_keys: false
+:show_foreign_keys: true
+:show_indexes: true
+:simple_indexes: false
+:sort: false
+:timestamp: false
+:trace: false
+:with_comment: true
+:with_column_comments: true
+:with_table_comments: true
+:active_admin: false
+:command:
+:debug: false
+:hide_default_column_types: ''
+:hide_limit_column_types: 'integer,boolean'
+:ignore_columns:
+:ignore_routes:
+:models: true
+:routes: false
+:skip_on_db_migrate: false
+:target_action: :do_annotations
+:wrapper:
+:wrapper_close:
+:wrapper_open:
+:classes_default_to_s: []
+:additional_file_patterns: []
+:model_dir:
+- app/models
+:require: []
+:root_dir:
+- ''
index 433b523f7c866f12defc6717a2807d26fb77dfdc..099d0abf8352c9e386c35bbe4c132b51a3bc49fa 100644 (file)
@@ -86,14 +86,17 @@ jobs:
         ruby-version: ${{ env.ruby }}
         rubygems: 3.4.10
         bundler-cache: true
+    - name: Configure rails
+      run: |
+        cp config/github.database.yml config/database.yml
+        cp config/example.storage.yml config/storage.yml
     - name: Setup database
       run: |
         sudo systemctl start postgresql
         sudo -u postgres createuser -s $(id -un)
         createdb openstreetmap
-        cp config/github.database.yml config/database.yml
         bundle exec rails db:schema:load
     - name: Run Annotate Models
-      run: bundle exec rails annotate_models
+      run: bundle exec annotaterb models
     - name: Fail if model annotations are out of date
       run: git diff --exit-code
diff --git a/Gemfile b/Gemfile
index 660ff7f1a2adba56990d17b7b5454c02d5f5b2e5..ad6b3b3ef2637cc257b7d973de8c1c4eff23d674 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -176,7 +176,7 @@ group :test do
 end
 
 group :development, :test do
-  gem "annotate"
+  gem "annotaterb"
   gem "teaspoon"
   gem "teaspoon-mocha", "~> 2.3.3"
 
index 66f09585dc94479228d5f84e667273ba884a8815..38328c2807c91cb08ed08b5c56a4088131778ae1 100644 (file)
@@ -82,9 +82,7 @@ GEM
       tzinfo (~> 2.0, >= 2.0.5)
     addressable (2.8.7)
       public_suffix (>= 2.0.2, < 7.0)
-    annotate (3.2.0)
-      activerecord (>= 3.2, < 8.0)
-      rake (>= 10.4, < 14.0)
+    annotaterb (4.14.0)
     argon2 (2.3.2)
       ffi (~> 1.15)
       ffi-compiler (~> 1.0)
@@ -682,7 +680,7 @@ DEPENDENCIES
   active_record_union
   activerecord-import
   addressable (~> 2.8)
-  annotate
+  annotaterb
   argon2
   autoprefixer-rails
   aws-sdk-s3
diff --git a/lib/tasks/annotate_rb.rake b/lib/tasks/annotate_rb.rake
new file mode 100644 (file)
index 0000000..1ad0ec3
--- /dev/null
@@ -0,0 +1,8 @@
+# This rake task was added by annotate_rb gem.
+
+# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
+if Rails.env.development? && ENV["ANNOTATERB_SKIP_ON_DB_TASKS"].nil?
+  require "annotate_rb"
+
+  AnnotateRb::Core.load_rake_tasks
+end
diff --git a/lib/tasks/auto_annotate_models.rake b/lib/tasks/auto_annotate_models.rake
deleted file mode 100644 (file)
index e5ea370..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-# NOTE: only doing this in development as some production environments (Heroku)
-# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
-# NOTE: to have a dev-mode tool do its thing in production.
-if Rails.env.local?
-  task :set_annotation_options => :environment do
-    # You can override any of these by setting an environment variable of the
-    # same name.
-    Annotate.set_defaults(
-      "routes" => "false",
-      "position_in_routes" => "before",
-      "position_in_class" => "before",
-      "position_in_test" => "before",
-      "position_in_fixture" => "before",
-      "position_in_factory" => "before",
-      "position_in_serializer" => "before",
-      "show_foreign_keys" => "true",
-      "show_indexes" => "true",
-      "simple_indexes" => "false",
-      "model_dir" => "app/models",
-      "root_dir" => "",
-      "include_version" => "false",
-      "require" => "",
-      "exclude_tests" => "true",
-      "exclude_fixtures" => "true",
-      "exclude_factories" => "true",
-      "exclude_serializers" => "true",
-      "exclude_scaffolds" => "true",
-      "exclude_controllers" => "true",
-      "exclude_helpers" => "true",
-      "ignore_model_sub_dir" => "false",
-      "ignore_columns" => nil,
-      "ignore_routes" => nil,
-      "ignore_unknown_models" => "false",
-      "hide_limit_column_types" => "integer,boolean",
-      "skip_on_db_migrate" => "false",
-      "format_bare" => "true",
-      "format_rdoc" => "false",
-      "format_markdown" => "false",
-      "sort" => "false",
-      "force" => "false",
-      "trace" => "false",
-      "wrapper_open" => nil,
-      "wrapper_close" => nil
-    )
-  end
-
-  Annotate.load_tasks
-end