From: Tom Hughes Date: Fri, 21 Feb 2025 23:08:25 +0000 (+0000) Subject: Switch to using annotaterb for annotations X-Git-Tag: live~159^2~2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a52558ecc440d37f2aefc27f81e2a7596a428bfd Switch to using annotaterb for annotations --- diff --git a/.annotaterb.yml b/.annotaterb.yml new file mode 100644 index 000000000..ccc1cbf67 --- /dev/null +++ b/.annotaterb.yml @@ -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: +- '' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 433b523f7..099d0abf8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 660ff7f1a..ad6b3b3ef 100644 --- 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" diff --git a/Gemfile.lock b/Gemfile.lock index 66f09585d..38328c280 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 index 000000000..1ad0ec39e --- /dev/null +++ b/lib/tasks/annotate_rb.rake @@ -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 index e5ea3700a..000000000 --- a/lib/tasks/auto_annotate_models.rake +++ /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