Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Can run generate_seeders_i18n_source_file without rails runner

Christophe Bliard971803d5e69f
diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml
index f5f748b3ebb..f618fe2f6ac 100644
--- a/.github/workflows/crowdin.yml
+++ b/.github/workflows/crowdin.yml
@@ -60,12 +60,8 @@ jobs:
echo "crowdin_branch=release" >> $GITHUB_OUTPUT
fi
- name: "Generate seeders i18n source file"
- env:
- DATABASE_URL: "sqlite3::memory:"
run: |
- echo "gem 'sqlite3'" >> Gemfile
- bundle install
- bundle exec rails runner script/i18n/generate_seeders_i18n_source_file
+ bundle exec script/i18n/generate_seeders_i18n_source_file
- name: "Crowdin: upload sources and download translations"
uses: crowdin/[email protected]
with:
diff --git a/script/i18n/generate_seeders_i18n_source_file b/script/i18n/generate_seeders_i18n_source_file
index 89d3f38dd5a..578085a72ed 100755
--- a/script/i18n/generate_seeders_i18n_source_file
+++ b/script/i18n/generate_seeders_i18n_source_file
@@ -29,10 +29,27 @@
#++
if !defined? Rails
- warn 'Error: this script must be run with `rails runner`'
- warn ''
- warn "Try running: bundle exec rails runner #{$0}"
- exit 1
+ puts 'Loading necessary files to run without loading Rails'
+ puts "(Alternatively, you can try running bundle exec rails runner #{$0})"
+ puts
+
+ require 'pathname'
+ require 'yaml'
+ require 'active_support/core_ext/hash/keys'
+ require 'active_support/core_ext/object/blank'
+
+ class Rails
+ def self.root
+ Pathname.new File.expand_path('../../', __dir__)
+ end
+ end
+
+ module Source; end
+
+ # order is important
+ require Rails.root.join("app/seeders/source/translate.rb")
+ require Rails.root.join("app/seeders/source/filter_translatables.rb")
+ require Rails.root.join("app/seeders/source/seed_file.rb")
end
class GenerateSeederSourceTranslationFiles
@@ -84,6 +101,8 @@ class GenerateSeederSourceTranslationFiles
end
def relative_path(path)
+ return path unless path.start_with?('/')
+
Pathname.new(path).relative_path_from(Rails.root).to_s
end
end