From 6afa77de4fdc7177ec7587426ed0861569f44a82 Mon Sep 17 00:00:00 2001 From: Florian Sellmayr Date: Sun, 16 Oct 2016 14:08:40 +0200 Subject: [PATCH] patch from #135 that reproduces the issue --- dev-resources/first.sh | 2 ++ dev-resources/second.sh | 9 +++++ example/clj/todopipeline/pipeline.clj | 5 ++- example/clj/todopipeline/steps.clj | 49 +++++++++++++++++++++++---- 4 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 dev-resources/first.sh create mode 100644 dev-resources/second.sh diff --git a/dev-resources/first.sh b/dev-resources/first.sh new file mode 100644 index 00000000..63ca1e7b --- /dev/null +++ b/dev-resources/first.sh @@ -0,0 +1,2 @@ +#!/bin/bash +./second.sh diff --git a/dev-resources/second.sh b/dev-resources/second.sh new file mode 100644 index 00000000..9de1e1cd --- /dev/null +++ b/dev-resources/second.sh @@ -0,0 +1,9 @@ +#!/bin/bash +echo "creating long output..." + +for i in `seq 3000`; +do + OUTPUT="$OUTPUT\n$i) here is a very long line. Bacon ipsum dolor amet shankle kevin ball tip tenderloin burgdoggen jerky rump frankfurter" +done + +echo -e $OUTPUT diff --git a/example/clj/todopipeline/pipeline.clj b/example/clj/todopipeline/pipeline.clj index d432589e..46edf656 100644 --- a/example/clj/todopipeline/pipeline.clj +++ b/example/clj/todopipeline/pipeline.clj @@ -42,9 +42,8 @@ ;; uncomment this, run and see the magic happen (the first build will immediately run since there is no known state) ; wait-for-frontend-repo - ; do-stuff - compare-screenshots - ;; this step executes his child-steps (the arguments after the in-parallel) in parallel and waits + chaining-long-output + ;; until all of them are done. if one of them fails, the whole step fails. (alias "build and publish" (in-parallel diff --git a/example/clj/todopipeline/steps.clj b/example/clj/todopipeline/steps.clj index 0600adcc..b55c94b3 100644 --- a/example/clj/todopipeline/steps.clj +++ b/example/clj/todopipeline/steps.clj @@ -6,7 +6,9 @@ (:require [lambdacd.steps.shell :as shell] [lambdacd.steps.git :as git] [lambdacd.steps.manualtrigger :as manualtrigger] - [lambdacd.steps.support :as support])) + [lambdacd.steps.support :as support :refer [injected-args injected-ctx]] + [clojure.java.io :as io] + )) ;; Let's define some constants (def backend-repo "git@github.com:flosell/todo-backend-compojure.git") @@ -40,7 +42,42 @@ (git/checkout-and-execute backend-repo (:backend-revision args) args ctx steps))) (defn wait-for-greeting [args ctx] - (manualtrigger/parameterized-trigger {:greeting { :desc "some greeting"}} ctx)) + (manualtrigger/parameterized-trigger {:greeting {:desc "some greeting"}} ctx)) + +(defn prepare-failure1 [args ctx] + (let [home (:home-dir (:config ctx)) + first-source (-> "first.sh" io/resource io/file) + second-source (-> "second.sh" io/resource io/file) + dest (fn [name] (io/file home name)) + ] + (io/copy first-source (dest "first.sh")) + (io/copy second-source (dest "second.sh")) + {:status :success :out (str "Copied '" first-source "' and '" second-source "' to '" (dest "") "'")})) + +(defn prepare-failure [args ctx] + (let [home (:home-dir (:config ctx)) + first-source (-> "build.sh" io/resource io/file) + second-source (-> "updatedependencies" io/resource io/file) + third-source (-> "package.json" io/resource io/file) + dest (fn [name] (io/file home name)) + ] + (io/copy first-source (dest "build.sh")) + (io/copy second-source (dest "updatedependencies")) + (io/copy third-source (dest "package.json")) + {:status :success :out (str "Copied '" first-source "' and '" second-source "' to '" (dest "") "'")})) + +(defn run-failure [args ctx] + (let [home (:home-dir (:config ctx)) + _ (shell/bash ctx home "chmod +x *")] + (shell/bash ctx home "./first.sh") + )) + +(defn chaining-long-output [args ctx] + (support/always-chaining args ctx + (prepare-failure1 injected-args injected-ctx) + (run-failure injected-args injected-ctx)) + ) + (defn demonstrate-ansi [args ctx] (shell/bash ctx "/" @@ -99,12 +136,12 @@ (defn server-test [{cwd :cwd} ctx] (println "server test cwd: " cwd) (shell/bash ctx cwd - "lein test")) + "lein test")) (defn server-package [{cwd :cwd} ctx] (println "server package cwd: " cwd) (shell/bash ctx cwd - "lein uberjar")) + "lein uberjar")) (defn ^{:depends-on-previous-steps true} server-publish [{cwd :cwd} ctx] (shell/bash ctx cwd @@ -123,8 +160,8 @@ ;; more or less means that some values have special meaning for the UI to display things. ;; Check out the implementation of ```shell/bash``` if you want to know more. (defn some-step-that-cant-be-reached [& _] - { :some-info "hello world" - :status :success}) + {:some-info "hello world" + :status :success}) ;; Another step that just fails using bash.