From 6b3781b7466a97c68c313c2d2a7bc403d298f7bb Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Fri, 27 Nov 2020 11:57:05 -0800 Subject: [PATCH] Add an Ottofile which runs this repos tests Basically this requires: * `make run` to launch the service mesh * `./scripts/local-run` And then you wait, because log output from the agent's step invocation is not yet streaming :laughing: --- Ottofile | 18 ++++++++++++++++++ scripts/local-run | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Ottofile create mode 100755 scripts/local-run diff --git a/Ottofile b/Ottofile new file mode 100644 index 0000000..037e632 --- /dev/null +++ b/Ottofile @@ -0,0 +1,18 @@ + +pipeline { + steps { + sh 'pwd' + // branch needed until #45 is addressed + git url: 'https://git.brokenco.de/rtyler/otto', branch: 'main', into: '.' + } + + stage { + name = 'Build' + steps { + sh 'cargo test' + } + } +} + + +// vim: sw=2 et ts=2 ft=groovy diff --git a/scripts/local-run b/scripts/local-run new file mode 100755 index 0000000..38bd015 --- /dev/null +++ b/scripts/local-run @@ -0,0 +1,41 @@ +#!/usr/bin/env ruby + +require 'json' +require 'net/http' + +pipeline = nil + +# Parse it +Net::HTTP.start('localhost', 7672) do |http| + otto = File.read('Ottofile') + response = http.post('/v1/parse', otto) + + if response.code.to_i != 200 + puts 'Failed to parse file' + exit 1 + end + + pipeline = JSON.parse(response.read_body) +end + +# Hit the local-orchestrator +Net::HTTP.start('localhost', 7673) do |http| + contexts = [] + pipeline['batches'].each do |batch| + contexts += (batch['contexts']) + end + + payload = JSON.dump({ + :pipeline => pipeline['uuid'], + :contexts => contexts, + }) + + puts payload + res = http.post('/v1/run', payload) + + if res.code.to_i != 200 + puts "Failed to orchestrate! #{res.code} #{res.read_body}" + exit 1 + end + puts 'Enqueued' +end