Skip to content

Commit

Permalink
Add CLI smoke tests to GitHub Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Jun 11, 2023
1 parent 4635f0a commit 8f142b4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,30 @@ jobs:
java-version: '8'

- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@10.1
uses: DeLaGuardo/setup-clojure@11.0
with:
lein: 2.9.10
bb: latest
clj-kondo: 2023.05.18

- name: Install GraalVM
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.2'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install native dev tools
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install build-essential zlib1g-dev
- name: Build executable
working-directory: ./cljfmt
run: lein native-image

- name: Execute tests
working-directory: ./cljfmt
run: lein test
Expand All @@ -28,7 +46,12 @@ jobs:
run: bb test

- name: Check formatting
run: bb fmt check
run: cljfmt/target/cljfmt check

- name: Lint sourcecode
run: bb lint

- name: Run smoke tests
run: bb smoke


7 changes: 4 additions & 3 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{:deps {cljfmt/cljfmt {:local/root "."}}
:paths ["scripts"]
:tasks
{fmt {:doc "Run cljfmt"
:requires ([cljfmt.main :as fmt])
:task (binding [fmt/*command* "bb fmt"]
(apply fmt/-main *command-line-args*))}
:task (shell "cljfmt check")}
lint {:doc "Run clj-kondo"
:task (shell "clj-kondo --lint cljfmt/src lein-cljfmt/src")}
smoke {:doc "Run smoke tests"
:task smoke-test/-main}
test {:doc "Run babashka tests"
:extra-deps {eftest/eftest {:mvn/version "0.6.0"}}
:extra-paths ["cljfmt/test"]
Expand Down
20 changes: 20 additions & 0 deletions scripts/smoke_test.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(ns smoke-test
(:require [babashka.process :as p]
[clojure.test :refer [deftest is run-tests]]))

(deftest check-lein-plugin
(is (zero? (:exit (p/shell {:dir "lein-cljfmt", :continue true}
"lein cljfmt check")))))

(deftest check-clj-tool
(is (zero? (:exit (p/shell
"clj -M -m cljfmt.main check cljfmt/src cljfmt/test")))))

(deftest check-standalone
(is (zero? (:exit (p/shell
"cljfmt/target/cljfmt check cljfmt/src cljfmt/test")))))

(defn -main []
(let [{:keys [fail error]} (run-tests 'smoke-test)]
(when (pos? (+ fail error))
(System/exit 1))))

0 comments on commit 8f142b4

Please sign in to comment.