Use extracted CI short script (#1284)
* Use extracted CI short script * Use clojure build env * Update build script
This commit is contained in:
parent
40fdb19c95
commit
35b8204704
3 changed files with 15 additions and 53 deletions
|
|
@ -2,5 +2,9 @@
|
||||||
:deps {borkdude/gh-release-artifact
|
:deps {borkdude/gh-release-artifact
|
||||||
#_{:local/root "../gh-release-artifact"}
|
#_{:local/root "../gh-release-artifact"}
|
||||||
{:git/url "https://github.com/borkdude/gh-release-artifact"
|
{:git/url "https://github.com/borkdude/gh-release-artifact"
|
||||||
:sha "cf082df46a648178d1904e9cbcb787d8136a35c6"}}
|
:sha "cf082df46a648178d1904e9cbcb787d8136a35c6"}
|
||||||
:tasks {release-artifact babashka.release-artifact/release}}
|
babashka/.build {:git/url "https://github.com/babashka/.build"
|
||||||
|
:git/sha "1ce87f4960fea14f4d1248052e585e6027555d33"}}
|
||||||
|
:tasks {:requires ([scripts.short-ci :as short])
|
||||||
|
release-artifact babashka.release-artifact/release
|
||||||
|
short-ci short/main}}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ commands:
|
||||||
jobs:
|
jobs:
|
||||||
short-if-irrelevant:
|
short-if-irrelevant:
|
||||||
docker:
|
docker:
|
||||||
- image: cimg/base:stable
|
- image: cimg/clojure:1.11.1
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
|
|
@ -28,7 +28,7 @@ jobs:
|
||||||
command: mv /tmp/bb /tmp/bbb
|
command: mv /tmp/bb /tmp/bbb
|
||||||
- run:
|
- run:
|
||||||
name: Short CI if only irrelevant changes
|
name: Short CI if only irrelevant changes
|
||||||
command: /tmp/bbb .circleci/script/short.clj
|
command: /tmp/bbb --config .build/bb.edn short-ci "circleci task halt"
|
||||||
jvm:
|
jvm:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/clojure:openjdk-11-lein-2.9.8-bullseye
|
- image: circleci/clojure:openjdk-11-lein-2.9.8-bullseye
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
(require '[babashka.process :as proc]
|
|
||||||
'[clojure.string :as str])
|
|
||||||
|
|
||||||
(def config
|
|
||||||
{:skip-if-only [#".*.md$"]})
|
|
||||||
|
|
||||||
(defn exec [cmd]
|
|
||||||
(-> cmd
|
|
||||||
(proc/process)
|
|
||||||
(proc/check)))
|
|
||||||
|
|
||||||
(defn get-changes []
|
|
||||||
(-> "git diff --name-only HEAD~1"
|
|
||||||
(exec)
|
|
||||||
(:out)
|
|
||||||
slurp
|
|
||||||
(str/split-lines)))
|
|
||||||
|
|
||||||
(defn irrelevant-change? [change regexes]
|
|
||||||
(some? (some #(re-matches % change) regexes)))
|
|
||||||
|
|
||||||
(defn relevant? [change-set regexes]
|
|
||||||
(some? (some #(not (irrelevant-change? % regexes)) change-set)))
|
|
||||||
|
|
||||||
(defn main []
|
|
||||||
(let [{:keys [skip-if-only]} config
|
|
||||||
changed-files (get-changes)]
|
|
||||||
(if (relevant? changed-files skip-if-only)
|
|
||||||
(println "Proceeding with CI run")
|
|
||||||
(do
|
|
||||||
(println "Irrelevant changes - skipping CI run")
|
|
||||||
(exec "circleci task halt")))))
|
|
||||||
|
|
||||||
(when (= *file* (System/getProperty "babashka.file"))
|
|
||||||
(main))
|
|
||||||
|
|
||||||
(comment
|
|
||||||
(def regexes [#".*.md$"
|
|
||||||
#".*.clj"]) ;ignore clojure files
|
|
||||||
(irrelevant-change? "src/file.png" regexes)
|
|
||||||
(re-matches #".*.clj$" "src/file.clj.dfff")
|
|
||||||
(relevant? ["src/file.clj"] regexes))
|
|
||||||
Loading…
Reference in a new issue