Skip to content

Instantly share code, notes, and snippets.

@robsyme
Created September 9, 2022 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robsyme/6e5134ef3f5bd6d92fcbcfa088b4fbb6 to your computer and use it in GitHub Desktop.
Save robsyme/6e5134ef3f5bd6d92fcbcfa088b4fbb6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'json'
require 'optparse'
options = {}
OptionParser.new do |opt|
opt.on('--report FILENAME') { |report| options[:report] = report }
end.parse!
inputs = JSON.parse(ARGF.read)
File.open(options[:report], 'w') do |report|
if inputs["fav_colour"] != "maroon"
report.puts "Reports do not pass"
exit 100
else
report.puts "Everything looks good"
end
end
#!/usr/bin/env ruby
require 'optparse'
require 'json'
options = {}
OptionParser.new do |opt|
opt.on('--iteration INT') { |it|
iteration = it.to_i
case iteration
when 0..2
options["effort"] = "light"
when 3..5
options["effort"] = "moderate"
else
options["effort"] = "extreme"
end
case iteration
when 0..1
options["fav_colour"] = "green"
when 2..6
options["fav_colour"] = "purple"
else
options["fav_colour"] = "maroon"
end
}
end.parse!
puts JSON.pretty_generate(options)
process Foo {
output:
path("*")
"touch out.{1,2,3,4,5,6,7,8}.txt"
}
process Bar {
errorStrategy { task.exitStatus == 100 ? 'retry' : 'terminate' }
maxRetries 20
input:
path(infiles)
output:
path("report.html")
"""
generate_params --iteration ${task.attempt} > params.txt
bar params.txt --report report.html
"""
}
workflow {
Foo() | Bar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment