diff options
-rw-r--r-- | app/jobs/govuk_guix/fetch_revision_job.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/app/jobs/govuk_guix/fetch_revision_job.rb b/app/jobs/govuk_guix/fetch_revision_job.rb index c2c3c17..c747c13 100644 --- a/app/jobs/govuk_guix/fetch_revision_job.rb +++ b/app/jobs/govuk_guix/fetch_revision_job.rb @@ -23,6 +23,8 @@ require 'git' class GovukGuix::FetchRevisionJob < GovukGuix::Job extend EnqueuedJobs + REPOSITORY_DIRECTORY = 'tmp/cache/govuk-guix'.freeze + @retry_interval = 30 def run(commit_hash) @@ -33,7 +35,7 @@ class GovukGuix::FetchRevisionJob < GovukGuix::Job repository.checkout(sha) command = [ - "#{repository_directory}/guix-pre-inst-env", + "#{REPOSITORY_DIRECTORY}/guix-pre-inst-env", 'guix', 'build', '-e', @@ -54,10 +56,10 @@ class GovukGuix::FetchRevisionJob < GovukGuix::Job def repository @_repository ||= begin - if File.exist? repository_directory - Git.open(repository_directory, log: Rails.logger) + if File.exist? REPOSITORY_DIRECTORY + Git.open(REPOSITORY_DIRECTORY, log: Rails.logger) else - Git.clone(repository_remote_location, repository_directory) + Git.clone(self.class.repository_remote_location, REPOSITORY_DIRECTORY) end end end @@ -70,14 +72,16 @@ class GovukGuix::FetchRevisionJob < GovukGuix::Job "--json" ) - JSON.parse(command_output.join) - end + json_start = command_output.find_index { |line| line.starts_with?('[') } + json_output = command_output[json_start..command_output.length].join - def repository_directory - 'tmp/cache/govuk-guix' + JSON.parse(json_output) end - def repository_remote_location - 'git@git.cbaines.net:gds/govuk-guix' + def self.repository_remote_location + ENV.fetch( + 'GOVUK_GUIX_REPOSITORY_REMOTE', + 'https://github.com/alphagov/govuk-guix.git' + ) end end |