Skip to content

Commit

Permalink
Clean up env usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Feb 1, 2025
1 parent 2dff8cb commit d1ee5dd
Showing 5 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -47,3 +47,7 @@ rust/jank

# secrets
.github_access_token

# CI thingies
/llvm.sh
/linux-install.sh
11 changes: 6 additions & 5 deletions bin/jank/test_everything.clj
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@
(do
; Install deps required for running our tests.
(util/quiet-shell {} "sudo apt-get install -y default-jdk software-properties-common lsb-release npm lcov leiningen")
(util/quiet-shell {} "sudo npm install --global @chrisoakman/standard-clojure-style")
; TODO: Enable once we're linting Clojure/jank again.
;(util/quiet-shell {} "sudo npm install --global @chrisoakman/standard-clojure-style")

; Install jank's build deps.
(util/quiet-shell {} (os->deps-cmd "Linux"))
@@ -58,7 +59,7 @@
(defn -main [{:keys [install-deps? validate-formatting? compiler+runtime]}]
(summary/initialize)

(util/log-boundary "Environment")
(util/log-boundary "Show environment")
(show-env)

(util/log-boundary "Install dependencies")
@@ -72,6 +73,6 @@
:build? (:build? compiler+runtime)}))

(when (= *file* (System/getProperty "babashka.file"))
(-main {:install-deps? (parse-boolean (or (System/getenv "JANK_INSTALL_DEPS") "true"))
:validate-formatting? (parse-boolean (or (System/getenv "JANK_LINT") "true"))
:compiler+runtime {:build? (some? (System/getenv "JANK_BUILD_TYPE"))}}))
(-main {:install-deps? (parse-boolean (util/get-env "JANK_INSTALL_DEPS" "true"))
:validate-formatting? (parse-boolean (util/get-env "JANK_LINT" "true"))
:compiler+runtime {:build? (some? (util/get-env "JANK_BUILD_TYPE"))}}))
9 changes: 9 additions & 0 deletions bin/jank/util.clj
Original file line number Diff line number Diff line change
@@ -7,6 +7,15 @@

(def llvm-version 19)

(defn get-env
([s]
(get-env s nil))
([s fallback]
(let [raw (System/getenv s)]
(if-not (empty? raw)
raw
fallback))))

(defn log-boundary [title]
(println "\n────────────────" title "────────────────")
(summary/boundary title))
2 changes: 1 addition & 1 deletion compiler+runtime/bin/jank/compiler+runtime/bash_test.clj
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
(util/log-info "Not enabled")
(let [bash-test-dir (str compiler+runtime-dir "/test/bash")
test-files (b.f/glob bash-test-dir "**/{pass,fail}-test")
extra-env {"PATH" (str compiler+runtime-dir "/build" ":" (System/getenv "PATH"))}]
extra-env {"PATH" (str compiler+runtime-dir "/build" ":" (util/get-env "PATH"))}]
(doseq [test-file test-files]
(let [expect-pass? (clojure.string/ends-with? (str test-file) "pass-test")
dirname (b.f/parent test-file)
10 changes: 5 additions & 5 deletions compiler+runtime/bin/jank/compiler+runtime/core.clj
Original file line number Diff line number Diff line change
@@ -15,16 +15,16 @@

; Compile and test
(jank.compiler+runtime.build+test/-main {:enabled? build?
:build-type (or (System/getenv "JANK_BUILD_TYPE") "Debug")
:analyze (or (System/getenv "JANK_ANALYZE") "off")
:sanitize (or (System/getenv "JANK_SANITIZE") "none")
:coverage (or (System/getenv "JANK_COVERAGE") "off")})
:build-type (util/get-env "JANK_BUILD_TYPE" "Debug")
:analyze (util/get-env "JANK_ANALYZE" "off")
:sanitize (util/get-env "JANK_SANITIZE" "none")
:coverage (util/get-env "JANK_COVERAGE" "off")})

; Bash tests
(jank.compiler+runtime.bash-test/-main {:enabled? build?})

; Codecov (merge results)
(jank.compiler+runtime.coverage/-main {:enabled? (= "on" (or (System/getenv "JANK_COVERAGE") "off"))}))
(jank.compiler+runtime.coverage/-main {:enabled? (= "on" (System/getenv "JANK_COVERAGE" "off"))}))

(when (= *file* (System/getProperty "babashka.file"))
(-main {:validate-formatting? true

0 comments on commit d1ee5dd

Please sign in to comment.