Switch to using annotaterb for annotations

This commit is contained in:
Tom Hughes 2025-02-21 23:08:25 +00:00
parent b3443b7553
commit a52558ecc4
6 changed files with 74 additions and 55 deletions

58
.annotaterb.yml Normal file
View file

@ -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:
- ''

View file

@ -86,14 +86,17 @@ jobs:
ruby-version: ${{ env.ruby }} ruby-version: ${{ env.ruby }}
rubygems: 3.4.10 rubygems: 3.4.10
bundler-cache: true 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 - name: Setup database
run: | run: |
sudo systemctl start postgresql sudo systemctl start postgresql
sudo -u postgres createuser -s $(id -un) sudo -u postgres createuser -s $(id -un)
createdb openstreetmap createdb openstreetmap
cp config/github.database.yml config/database.yml
bundle exec rails db:schema:load bundle exec rails db:schema:load
- name: Run Annotate Models - name: Run Annotate Models
run: bundle exec rails annotate_models run: bundle exec annotaterb models
- name: Fail if model annotations are out of date - name: Fail if model annotations are out of date
run: git diff --exit-code run: git diff --exit-code

View file

@ -176,7 +176,7 @@ group :test do
end end
group :development, :test do group :development, :test do
gem "annotate" gem "annotaterb"
gem "teaspoon" gem "teaspoon"
gem "teaspoon-mocha", "~> 2.3.3" gem "teaspoon-mocha", "~> 2.3.3"

View file

@ -82,9 +82,7 @@ GEM
tzinfo (~> 2.0, >= 2.0.5) tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7) addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0) public_suffix (>= 2.0.2, < 7.0)
annotate (3.2.0) annotaterb (4.14.0)
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
argon2 (2.3.2) argon2 (2.3.2)
ffi (~> 1.15) ffi (~> 1.15)
ffi-compiler (~> 1.0) ffi-compiler (~> 1.0)
@ -682,7 +680,7 @@ DEPENDENCIES
active_record_union active_record_union
activerecord-import activerecord-import
addressable (~> 2.8) addressable (~> 2.8)
annotate annotaterb
argon2 argon2
autoprefixer-rails autoprefixer-rails
aws-sdk-s3 aws-sdk-s3

View file

@ -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

View file

@ -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