Use extracted CI short script (#1284)

* Use extracted CI short script

* Use clojure build env

* Update build script
This commit is contained in:
Rahuλ Dé 2022-05-29 21:58:09 +01:00 committed by GitHub
parent 40fdb19c95
commit 35b8204704
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 53 deletions

View file

@ -2,5 +2,9 @@
:deps {borkdude/gh-release-artifact
#_{:local/root "../gh-release-artifact"}
{:git/url "https://github.com/borkdude/gh-release-artifact"
:sha "cf082df46a648178d1904e9cbcb787d8136a35c6"}}
:tasks {release-artifact babashka.release-artifact/release}}
:sha "cf082df46a648178d1904e9cbcb787d8136a35c6"}
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}}

View file

@ -15,10 +15,10 @@ commands:
jobs:
short-if-irrelevant:
docker:
- image: cimg/base:stable
- image: cimg/clojure:1.11.1
steps:
- checkout
- run:
- run:
name: Bootstrap Babashka
command: |
curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
@ -28,7 +28,7 @@ jobs:
command: mv /tmp/bb /tmp/bbb
- run:
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:
docker:
- image: circleci/clojure:openjdk-11-lein-2.9.8-bullseye
@ -485,22 +485,22 @@ workflows:
ci:
jobs:
- short-if-irrelevant
- jvm:
- jvm:
requires:
- short-if-irrelevant
- linux:
- linux:
requires:
- short-if-irrelevant
- linux-static:
- linux-static:
requires:
- short-if-irrelevant
- mac:
- mac:
requires:
- short-if-irrelevant
- linux-aarch64:
- linux-aarch64:
requires:
- short-if-irrelevant
- linux-aarch64-static:
- linux-aarch64-static:
requires:
- short-if-irrelevant
- deploy:

View file

@ -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))