mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:25:24 +08:00
DEV: Add annotate
rake tasks, and enforce via GitHub actions
`bin/rake annotate` is an alias of `bin/annotate --models` `bin/rake annotate:clean` generates annotations by using a temporary, freshly migrated database. This should help us to produce more consistent annotations, even if development databases have been polluted by plugin migrations. A GitHub actions task is also added which generates annotations on a clean database, and raises an error if they differ from the committed annotations.
This commit is contained in:
@ -99,6 +99,28 @@ class TemporaryDb
|
||||
`#{pg_ctl_path} -D '#{PG_TEMP_PATH}' stop`
|
||||
end
|
||||
|
||||
def with_env(&block)
|
||||
old_host = ENV["PGHOST"]
|
||||
old_user = ENV["PGUSER"]
|
||||
old_port = ENV["PGPORT"]
|
||||
old_dev_db = ENV["DISCOURSE_DEV_DB"]
|
||||
old_rails_db = ENV["RAILS_DB"]
|
||||
|
||||
ENV["PGHOST"] = "localhost"
|
||||
ENV["PGUSER"] = "discourse"
|
||||
ENV["PGPORT"] = pg_port.to_s
|
||||
ENV["DISCOURSE_DEV_DB"] = "discourse"
|
||||
ENV["RAILS_DB"] = "discourse"
|
||||
|
||||
yield
|
||||
ensure
|
||||
ENV["PGHOST"] = old_host
|
||||
ENV["PGUSER"] = old_user
|
||||
ENV["PGPORT"] = old_port
|
||||
ENV["DISCOURSE_DEV_DB"] = old_dev_db
|
||||
ENV["RAILS_DB"] = old_rails_db
|
||||
end
|
||||
|
||||
def remove
|
||||
raise "Error: the database must be stopped before it can be removed" if @started
|
||||
FileUtils.rm_rf PG_TEMP_PATH
|
||||
|
Reference in New Issue
Block a user