require 'ruby_terraform' require 'git' require 'open3' class GovukGuix::FetchRevisionJob < GovukGuix::Job @retry_interval = 30 def run(commit_hash) repository.fetch repository.checkout(commit_hash) command = [ "#{repository_directory}/guix-pre-inst-env", "guix", "build", "-e", "(begin (use-modules (gds packages govuk)) (current-govuk-guix))" ] run_command(command) do |output| store_path = output.last.strip logger.debug("FetchRevisionJob: store_path: #{store_path}") GovukGuix::Revision.create( commit_hash: commit_hash, store_path: store_path ) end end def repository @_repository ||= begin if File.exists? repository_directory Git.open(repository_directory, :log => Rails.logger) else Git.clone(repository_remote_location, repository_directory) end end end def repository_directory 'tmp/cache/govuk-guix' end def repository_remote_location 'git@git.cbaines.net:gds/govuk-guix' end end