aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks
diff options
context:
space:
mode:
authorLuc Donnet2018-02-19 11:04:29 +0100
committerLuc Donnet2018-02-19 11:04:29 +0100
commit7b17deff51545358009cb417cbb9d796565e7540 (patch)
treea43a5586ad39d838dd607e600dbc15ff18a58ab3 /lib/tasks
parent89428163fc93a7e09ebb0ca47939f8558afeb5eb (diff)
parent5f6008d165df4499319a2121a71842657d6ac3c9 (diff)
downloadchouette-core-7b17deff51545358009cb417cbb9d796565e7540.tar.bz2
Merge branch 'master' into 0000-docker
Diffstat (limited to 'lib/tasks')
-rw-r--r--lib/tasks/ci.rake16
-rw-r--r--lib/tasks/compliance_check_sets.rb11
-rw-r--r--lib/tasks/erd.rake4
-rw-r--r--lib/tasks/imports.rake7
-rw-r--r--lib/tasks/referential.rake43
5 files changed, 72 insertions, 9 deletions
diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake
index 3e73b7a3b..89f9aa9c8 100644
--- a/lib/tasks/ci.rake
+++ b/lib/tasks/ci.rake
@@ -3,7 +3,7 @@ namespace :ci do
task :setup do
cp "config/database/jenkins.yml", "config/database.yml"
sh "RAILS_ENV=test rake db:drop db:create db:migrate"
- sh "yarn --production --no-progress install"
+ sh "yarn --no-progress install"
end
def git_branch
@@ -31,18 +31,22 @@ namespace :ci do
sh "bundle exec bundle-audit check --update"
end
- task :spec => ["ci:assets","spec"]
-
task :assets do
sh "RAILS_ENV=test bundle exec rake assets:precompile"
end
- task :jest => "ci:assets" do
- sh "node_modules/.bin/jest"
+ task :i18n_js_export do
+ sh "RAILS_ENV=test bundle exec rake i18n:js:export"
+ end
+
+ task :jest do
+ sh "node_modules/.bin/jest" unless ENV["CHOUETTE_JEST_DISABLED"]
end
desc "Deploy after CI"
task :deploy do
+ return if ENV["CHOUETTE_DEPLOY_DISABLED"]
+
if deploy_env
sh "cap #{deploy_env} deploy:migrations"
else
@@ -58,4 +62,4 @@ namespace :ci do
end
desc "Run continuous integration tasks (spec, ...)"
-task :ci => ["ci:setup", "ci:spec", "ci:jest", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
+task :ci => ["ci:setup", "ci:assets", "ci:i18n_js_export", "spec", "ci:jest", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
diff --git a/lib/tasks/compliance_check_sets.rb b/lib/tasks/compliance_check_sets.rb
new file mode 100644
index 000000000..c53c7f9ed
--- /dev/null
+++ b/lib/tasks/compliance_check_sets.rb
@@ -0,0 +1,11 @@
+namespace :compliance_check_sets do
+ desc "Notify parent check sets when children finish"
+ task notify_parent: :environment do
+ ParentNotifier.new(ComplianceCheckSet).notify_when_finished
+ end
+
+ desc "Mark old unfinished check sets as 'aborted'"
+ task abort_old: :environment do
+ ComplianceCheckSet.abort_old
+ end
+end
diff --git a/lib/tasks/erd.rake b/lib/tasks/erd.rake
index e2665374e..96bb7fe37 100644
--- a/lib/tasks/erd.rake
+++ b/lib/tasks/erd.rake
@@ -2,12 +2,12 @@ namespace :generate do
desc "Create model diagrams for Chouette"
task :model_diagram => :environment do
- sh "bundle exec rake erd only='Organisation,Referential,User,Workbench' filename='organisation' title='Organisation'"
+ sh "bundle exec rake erd only='Organisation,Referential,User,Workbench,Workgroup' filename='organisation' title='Organisation'"
sh "bundle exec rake erd only='Calendar,Referential,ReferentialMetadata,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"
sh "bundle exec rake erd only='Organisation,StopAreaReferential,StopAreaReferentialSync,StopAreaReferentialSyncMessage,StopAreaReferentialMembership,LineReferential,LineReferentialSync,LineReferentialSyncMessage,LineReferentialMembership' filename='referentiels_externes' title='Référentiels externes'"
sh "bundle exec rake erd only='NetexImport,Import,WorkbenchImport,ImportResource,ImportMessage' filename='import' title='Import'"
sh "bundle exec rake erd only='ComplianceControlSet,ComplianceControlBlock,ComplianceControl,ComplianceCheckSet,ComplianceCheckBlock,ComplianceCheck,ComplianceCheckResource,ComplianceCheckMessage' filename='validation' title='Validation'"
- sh "bundle exec rake erd only='Organisation,Workbench,ReferentialSuite,Referential' filename='merge' title='Merge'"
+ sh "bundle exec rake erd only='Organisation,Workgroup,Workbench,ReferentialSuite,Referential' filename='merge' title='Merge'"
#sh "bundle exec rake erd only='VehicleJourney,VehicleJourneyExport' filename='export' title='Export'"
#sh "bundle exec rake erd only='' filename='integration' title='Integration'"
#sh "bundle exec rake erd only='' filename='publication' title='Publication'"
diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake
index 6bc84acc8..02e32fd3d 100644
--- a/lib/tasks/imports.rake
+++ b/lib/tasks/imports.rake
@@ -1,6 +1,11 @@
namespace :import do
desc "Notify parent imports when children finish"
task notify_parent: :environment do
- ParentImportNotifier.notify_when_finished
+ ParentNotifier.new(Import).notify_when_finished
+ end
+
+ desc "Mark old unfinished Netex imports as 'aborted'"
+ task netex_abort_old: :environment do
+ NetexImport.abort_old
end
end
diff --git a/lib/tasks/referential.rake b/lib/tasks/referential.rake
index 7bab6e040..d53157312 100644
--- a/lib/tasks/referential.rake
+++ b/lib/tasks/referential.rake
@@ -67,4 +67,47 @@ namespace :referential do
referential.update(ready: true)
end
end
+
+ def update_checksums_for_referential referential
+ thing = %w(\\ | / —)
+ Referential.force_register_models_with_checksum if Rails.env.development? && Referential.models_with_checksum.empty?
+ puts "\n \e[33m***\e[0m Referential #{referential.name}"
+ referential.switch do
+ Referential.models_with_checksum.each do |klass|
+ i = 0
+ j = 0
+ prev_size = 1
+ head = "Updating checksums for #{klass.name}: "
+ print head
+ print "⎯"*(80-head.size)
+ print " "
+ count = klass.count
+ klass.find_each do |o|
+ o.update_checksum!
+ if j%10 == 0
+ out = "#{"\b"*prev_size}\e[33m#{thing[i]}\e[0m (#{j}/#{count})"
+ prev_size = out.size - prev_size - 9
+ print out
+ i = (i+1) % thing.size
+ end
+ j += 1
+ end
+ print "#{"\b"*prev_size}\e[32m✓\e[0m (#{count}/#{count})\n"
+ end
+ end
+ end
+
+ desc 'Update all the checksums in the given referential'
+ task :update_checksums_in_referential, [:slug] => :environment do |t, args|
+ referential = Referential.find_by_slug(args[:slug])
+ update_checksums_for_referential referential
+ end
+
+ desc 'Update all the checksums in the given organisation'
+ task :update_checksums_in_organisation, [:organisation_id] => :environment do |t, args|
+ thing = %w(\\ | / —)
+ Organisation.find(args[:organisation_id]).referentials.find_each do |referential|
+ update_checksums_for_referential referential
+ end
+ end
end