Skip to content

Instantly share code, notes, and snippets.

@Myoldmopar
Forked from lefticus/run_ci.rb
Last active June 27, 2022 20:08
Show Gist options
  • Save Myoldmopar/c51580a92556ef344216c22ec390aa31 to your computer and use it in GitHub Desktop.
Save Myoldmopar/c51580a92556ef344216c22ec390aa31 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
if ARGV.length < 4
puts "Usage: #{__FILE__} <buildfolder> [options] <testruntrueorfalse> <githubtoken> <repositoryname> (<repositoryname> ...)"
abort("Not enough arguments")
end
puts "starting CI system"
while true
begin
puts "Creating folder #{ARGV[0]}"
FileUtils.mkdir_p(ARGV[0])
puts "Cleaning up old decent_ci folder"
FileUtils.rm_rf("#{ARGV[0]}/decent_ci")
puts "Changing to folder #{ARGV[0]}"
FileUtils.cd(ARGV[0])
break
rescue => e
puts "Error setting up build folders, sleeping and trying again"
sleep 120
end
end
while !system("git clone https://github.com/Myoldmopar/decent_ci")
puts "Unable to clone decent_ci repository. Sleeping and trying again";
sleep 120
end
puts "Successfully cloned decent_ci repository."
while true
puts "Updating decent_ci"
if system("cd decent_ci && git pull")
puts "Running ci.rb"
ci_args = ARGV[1..-1]
if !system("#{RbConfig.ruby}", "decent_ci/ci.rb", *ci_args)
puts "Unable to execute ci.rb script"
end
else
puts "Unable to update decent_ci repository, sleeping and will retry"
sleep(120)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment