2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
6 # Add your own tasks in files placed in lib/tasks ending in .rake,
7 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
9 require File.expand_path('../config/application', __FILE__)
11 Server::Application.load_tasks
15 # Copied from the definition in Rails 3.2.
16 # This may need to be updated if we upgrade Rails.
18 errors = %w(test:units test:functionals test:integration test:tasks).collect do |task|
20 Rake::Task[task].invoke
23 { :task => task, :exception => e }
28 puts errors.map { |e| "Errors running #{e[:task]}! #{e[:exception].inspect}" }.join("\n")
35 namespace :structure do
38 origfnm = File.expand_path('../db/structure.sql', __FILE__)
39 tmpfnm = Tempfile.new 'structure.sql', File.expand_path('..', origfnm)
40 copyright_done = false
42 tmpfile = File.new tmpfnm, 'w'
43 origfile = File.new origfnm
44 origfile.each_line do |line|
46 if !/Copyright .* Arvados/.match(line)
47 tmpfile.write "-- Copyright (C) The Arvados Authors. All rights reserved.\n--\n-- SPDX-License-Identifier: AGPL-3.0\n\n"
51 if /^SET lock_timeout = 0;/ =~ line
52 # Avoid edit wars between versions that do/don't write this line.
54 elsif /^COMMENT ON EXTENSION/ =~ line
55 # Avoid warning message when loading:
56 # "structure.sql:22: ERROR: must be owner of extension plpgsql"
63 File.rename tmpfnm, origfnm
66 File.unlink tmpfnm if tmpfnm
72 # Work around Rails3+PostgreSQL9.5 incompatibility (pg_dump used to
73 # accept -i as a no-op, but now it's not accepted at all).
75 alias_method :orig_backtick, :`
76 def `(*args) #`#` sorry, parsers
77 args[0].sub!(/\Apg_dump -i /, 'pg_dump ') rescue nil