<commit_before>(ns circleci.backend.build
  (:use [arohner.utils :only (inspect fold)])
  (:use [circleci.backend.action :only (validate-action-result!)])
  (:use [circleci.backend.action.bash :only (with-pwd)])
  (:use [circleci.backend.nodes :only (node-info)]))

(defrecord Build [project-name ;; string
                  build-num ;; int
                  actions ;; a seq of actions
                  action-results
                  group ;; the pallet group spec to use for the build
                  continue  ;; if true, continue running the build. Failed actions will set this to false
                  ])

(defn build [& {:keys [project-name build-num actions action-results group continue]
                :or {failed false}}]
  (Build. project-name build-num actions (or action-results []) group true))

(defrecord BuildContext [build
                         action
                         node])



(defn run-build [build]
  (println "getting node info")
  (let [node (-> build :group (node-info) (first))]
    (with-pwd "" ;; bind here, so actions can set! it
      (fold build [act (-> build :actions)]
        (if (-> build :continue)
          (let [context {:build build
                         :action act
                         :node node}
                _ (println "calling" (-> act :name))
                action-result (-> act :act-fn (.invoke context))]
            (println "result:" action-result)
            (validate-action-result! action-result)
            (-> build
                (update-in [:action-results] conj action-result)
                (update-in [:continue] (fn [_] (continue? action-result)))))
          build)))))<commit_msg>Fix moving the file<commit_after>(ns circleci.backend.build
  (:use [arohner.utils :only (inspect fold)])
  (:use [circleci.backend.action :only (continue? validate-action-result!)])
  (:use [circleci.backend.action.bash :only (with-pwd)])
  (:use [circleci.backend.nodes :only (node-info)]))

(defrecord Build [project-name ;; string
                  build-num ;; int
                  actions ;; a seq of actions
                  action-results
                  group ;; the pallet group spec to use for the build
                  continue  ;; if true, continue running the build. Failed actions will set this to false
                  ])

(defn build [& {:keys [project-name build-num actions action-results group continue]
                :or {failed false}}]
  (Build. project-name build-num actions (or action-results []) group true))

(defrecord BuildContext [build
                         action
                         node])

(defn run-build [build]
  (println "getting node info")
  (let [node (-> build :group (node-info) (first))]
    (with-pwd "" ;; bind here, so actions can set! it
      (fold build [act (-> build :actions)]
        (if (-> build :continue)
          (let [context {:build build
                         :action act
                         :node node}
                _ (println "calling" (-> act :name))
                action-result (-> act :act-fn (.invoke context))]
            (println "result:" action-result)
            (validate-action-result! action-result)
            (-> build
                (update-in [:action-results] conj action-result)
                (update-in [:continue] (fn [_] (continue? action-result)))))
          build)))))
{'fraction_non_alphanumeric': 0.1276658767772512, 'fraction_numerical': 0.0, 'mean_word_length': 1.8642917726887192, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2951240', 'n_tokens_mistral': 954, 'n_tokens_neox': 887, 'n_words': 287}