diff --git a/.build/bb.edn b/.build/bb.edn
index b68f2790..6ec32294 100644
--- a/.build/bb.edn
+++ b/.build/bb.edn
@@ -2,5 +2,5 @@
:deps {borkdude/gh-release-artifact
#_{:local/root "../gh-release-artifact"}
{:git/url "https://github.com/borkdude/gh-release-artifact"
- :sha "f34f3e382e6a0ef7f52748b2f27eb681f799a822"}}
+ :git/sha "ce060c12a25b552b864dc90f8fb344a2eb91ea9d"}}
:tasks {release-artifact babashka.release-artifact/release}}
diff --git a/.circleci/config.yml b/.circleci/config.yml
index aac22a89..3e0293e5 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -3,484 +3,38 @@
# Check https://circleci.com/docs/2.0/language-clojure/ for more details
#
version: 2.1
-commands:
- setup-docker-buildx:
- steps:
- - run:
- name: Create multi-platform capabale buildx builder
- command: |
- docker run --privileged --rm tonistiigi/binfmt --install all
- docker buildx create --name ci-builder --use
-jobs:
- jvm:
- docker:
- - image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- BABASHKA_PLATFORM: linux # could be used in jar name
- resource_class: large
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- - restore_cache:
- keys:
- - v1-dependencies-{{ checksum "project.clj" }}-{{ checksum "deps.edn" }}
- # fallback to using the latest cache if no exact match is found
- - v1-dependencies-
- - run:
- name: Install Clojure
- command: |
- sudo script/install-clojure
- - run:
- name: Run JVM tests
- command: |
- export BABASHKA_FEATURE_JDBC=true
- export BABASHKA_FEATURE_POSTGRESQL=true
- script/test
- script/run_lib_tests
- - run:
- name: Run as lein command
- command: |
- .circleci/script/lein
- - run:
- name: Create uberjar
- command: |
- mkdir -p /tmp/release
- script/uberjar
- VERSION=$(cat resources/BABASHKA_VERSION)
- jar=target/babashka-$VERSION-standalone.jar
- cp $jar /tmp/release
- java -jar $jar script/reflection.clj
- reflection="babashka-$VERSION-reflection.json"
- java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$jar"
- java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$reflection"
- - store_artifacts:
- path: /tmp/release
- destination: release
- - save_cache:
- paths:
- - ~/.m2
- key: v1-dependencies-{{ checksum "project.clj" }}-{{ checksum "deps.edn" }}
- linux:
- docker:
- - image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- GRAALVM_VERSION: "22.0.0.2"
- GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
- BABASHKA_PLATFORM: linux # used in release script
- BABASHKA_TEST_ENV: native
- BABASHKA_XMX: "-J-Xmx6500m"
- resource_class: large
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- - restore_cache:
- keys:
- - linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - run:
- name: Install Clojure
- command: |
- sudo script/install-clojure
- - run:
- name: Install native dev tools
- command: |
- sudo apt-get update
- sudo apt-get -y install build-essential zlib1g-dev
- - run:
- name: Download GraalVM
- command: |
- script/install-graalvm
- - run:
- name: Build binary
- command: |
- script/uberjar
- script/compile
- no_output_timeout: 30m
- - run:
- name: Run tests
- command: |
- script/test
- script/run_lib_tests
- - run:
- name: Release
- command: |
- .circleci/script/release
- - persist_to_workspace:
- root: /tmp
- paths:
- - release
- - save_cache:
- paths:
- - ~/.m2
- - ~/graalvm-ce-java11-22.0.0.2
- key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - store_artifacts:
- path: /tmp/release
- destination: release
- - run:
- name: Publish artifact link to Slack
- command: |
- ./bb .circleci/script/publish_artifact.clj || true
- linux-static:
- docker:
- - image: circleci/clojure:openjdk-11-lein-2.9.6-bullseye
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- GRAALVM_VERSION: "22.0.0.2"
- GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
- BABASHKA_PLATFORM: linux # used in release script
- BABASHKA_TEST_ENV: native
- BABASHKA_STATIC: "true"
- BABASHKA_MUSL: "true"
- BABASHKA_XMX: "-J-Xmx6500m"
- resource_class: large
- steps:
- - checkout
- - attach_workspace:
- at: /tmp
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- # - run:
- # name: "Short circuit on SNAPSHOT"
- # command: |
- # VERSION=$(cat resources/BABASHKA_VERSION)
- # if [[ "$VERSION" == *-SNAPSHOT ]]
- # then
- # circleci task halt
- # fi
- - restore_cache:
- keys:
- - linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - run:
- name: Install Clojure
- command: |
- sudo script/install-clojure
- - run:
- name: Install native dev tools
- command: |
- sudo apt-get update
- sudo apt-get -y install build-essential zlib1g-dev
- sudo -E script/setup-musl
- - run:
- name: Download GraalVM
- command: |
- script/install-graalvm
- - run:
- name: Build binary
- command: |
- script/uberjar
- script/compile
- no_output_timeout: 30m
- - run:
- name: Run tests
- command: |
- script/test
- script/run_lib_tests
- - run:
- name: Release
- command: |
- .circleci/script/release
- - persist_to_workspace:
- root: /tmp
- paths:
- - release
- - save_cache:
- paths:
- - ~/.m2
- - ~/graalvm-ce-java11-22.0.0.2
- key: linux-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - store_artifacts:
- path: /tmp/release
- destination: release
- - run:
- name: Publish artifact link to Slack
- command: |
- ./bb .circleci/script/publish_artifact.clj || true
- linux-aarch64:
- machine:
- enabled: true
- image: ubuntu-2004:202101-01
- resource_class: arm.large
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- GRAALVM_VERSION: "22.0.0.2"
- GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
- BABASHKA_PLATFORM: linux # used in release script
- BABASHKA_ARCH: aarch64
- BABASHKA_TEST_ENV: native
- BABASHKA_XMX: "-J-Xmx6500m"
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- - run:
- name: Install Clojure
- command: |
- sudo script/install-clojure
- - restore_cache:
- keys:
- - linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - run:
- name: Install native dev tools
- command: |
- sudo apt-get update
- sudo apt-get -y install build-essential zlib1g-dev
- - run:
- name: Download GraalVM
- command: |
- script/install-graalvm
- - run:
- name: Build binary
- command: |
- script/uberjar
- script/compile
- no_output_timeout: 30m
- - run:
- name: Run tests
- command: |
- script/test
- script/run_lib_tests
- - run:
- name: Release
- command: |
- .circleci/script/release
- - persist_to_workspace:
- root: /tmp
- paths:
- - release
- - save_cache:
- paths:
- - ~/.m2
- - ~/graalvm-ce-java11-22.0.0.2
- key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - store_artifacts:
- path: /tmp/release
- destination: release
- - run:
- name: Publish artifact link to Slack
- command: |
- ./bb .circleci/script/publish_artifact.clj || true
- linux-aarch64-static:
- machine:
- enabled: true
- image: ubuntu-2004:202101-01
- resource_class: arm.large
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- GRAALVM_VERSION: "22.0.0.2"
- GRAALVM_HOME: /home/circleci/graalvm-ce-java11-22.0.0.2
- BABASHKA_PLATFORM: linux # used in release script
- BABASHKA_ARCH: aarch64
- BABASHKA_TEST_ENV: native
- BABASHKA_XMX: "-J-Xmx6500m"
- BABASHKA_STATIC: "true"
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- # - run:
- # name: "Short circuit on SNAPSHOT"
- # command: |
- # VERSION=$(cat resources/BABASHKA_VERSION)
- # if [[ "$VERSION" == *-SNAPSHOT ]]
- # then
- # circleci task halt
- # fi
- - run:
- name: Install Clojure
- command: |
- sudo script/install-clojure
- - restore_cache:
- keys:
- - linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - run:
- name: Install native dev tools
- command: |
- sudo apt-get update
- sudo apt-get -y install build-essential zlib1g-dev
- # sudo -E script/setup-musl
- - run:
- name: Download GraalVM
- command: |
- script/install-graalvm
- - run:
- name: Build binary
- command: |
- script/uberjar
- script/compile
- no_output_timeout: 30m
- - run:
- name: Run tests
- command: |
- script/test
- script/run_lib_tests
- - run:
- name: Release
- command: |
- .circleci/script/release
- - persist_to_workspace:
- root: /tmp
- paths:
- - release
- - save_cache:
- paths:
- - ~/.m2
- - ~/graalvm-ce-java11-22.0.0.2
- key: linux-aarch64-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - store_artifacts:
- path: /tmp/release
- destination: release
- - run:
- name: Publish artifact link to Slack
- command: |
- ./bb .circleci/script/publish_artifact.clj || true
- mac:
- macos:
- xcode: "12.0.0"
- environment:
- MACOSX_DEPLOYMENT_TARGET: 10.13 # 10.12 is EOL
- GRAALVM_VERSION: "22.0.0.2"
- GRAALVM_HOME: /Users/distiller/graalvm-ce-java11-22.0.0.2/Contents/Home
- BABASHKA_PLATFORM: macos # used in release script
- BABASHKA_TEST_ENV: native
- BABASHKA_XMX: "-J-Xmx6500m"
- resource_class: large
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- - restore_cache:
- keys:
- - mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - run:
- name: Install Clojure
- command: |
- script/install-clojure
- - run:
- name: Install Leiningen
- command: |
- script/install-leiningen
- - run:
- name: Download GraalVM
- command: |
- script/install-graalvm
- - run:
- name: Build binary
- command: |
- export PATH=$GRAALVM_HOME/bin:$PATH
- script/uberjar
- script/compile
- no_output_timeout: 30m
- - run:
- name: Run tests
- command: |
- export PATH=$GRAALVM_HOME/bin:$PATH
- script/test
- script/run_lib_tests
- - run:
- name: Release
- command: |
- .circleci/script/release
- - save_cache:
- paths:
- - ~/.m2
- - ~/graalvm-ce-java11-22.0.0.2/Contents/Home
- key: mac-{{ checksum "project.clj" }}-{{ checksum ".circleci/config.yml" }}
- - store_artifacts:
- path: /tmp/release
- destination: release
- - run:
- name: Publish artifact link to Slack
- command: |
- ./bb .circleci/script/publish_artifact.clj || true
- deploy:
- resource_class: large
- docker:
- - image: circleci/clojure:lein-2.9.6
- working_directory: ~/repo
- environment:
- LEIN_ROOT: "true"
- steps:
- - checkout
- - run:
- name: "Pull Submodules"
- command: |
- git submodule init
- git submodule update
- - restore_cache:
- keys:
- - v1-dependencies-{{ checksum "project.clj" }}
- # fallback to using the latest cache if no exact match is found
- - v1-dependencies-
- - run: .circleci/script/deploy
- - save_cache:
- paths:
- - ~/.m2
- key: v1-dependencies-{{ checksum "project.clj" }}
- docker:
- machine:
- image: ubuntu-2004:202111-01
- steps:
- - checkout
- - setup-docker-buildx
- - attach_workspace:
- at: /tmp
- - run:
- name: Build Docker image
- environment:
- PLATFORM: linux/amd64,linux/arm64
- command: .circleci/script/docker
+# this allows you to use CircleCI's dynamic configuration feature
+setup: true
+
+# the continuation orb is required in order to use dynamic configuration
+orbs:
+ continuation: circleci/continuation@0.1.2
+
+# our defined job, and its steps
+jobs:
+ setup:
+ docker:
+ - image: cimg/clojure:1.11.1
+ steps:
+ - checkout
+ - run:
+ name: Bootstrap Babashka
+ command: |
+ curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
+ sudo bash install --dir /tmp
+ - run:
+ name: Rename bb binary
+ command: mv /tmp/bb /tmp/bbb
+ - run:
+ name: Generate config
+ command: |
+ /tmp/bbb .circleci/script/short_ci.clj > generated_config.yml
+ - continuation/continue:
+ configuration_path: generated_config.yml
+
+# our single workflow, that triggers the setup job defined above
workflows:
- version: 2
- ci:
+ setup:
jobs:
- - jvm
- - linux
- - linux-static
- - mac
- - linux-aarch64
- - linux-aarch64-static
- - deploy:
- filters:
- branches:
- only: master
- requires:
- - jvm
- - linux
- - mac
- - docker:
- filters:
- branches:
- only:
- - master
- requires:
- - linux
- - linux-static
- - linux-aarch64
+ - setup
diff --git a/.circleci/script/docker b/.circleci/script/docker
deleted file mode 100755
index f16447b6..00000000
--- a/.circleci/script/docker
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env bash
-
-set -eo pipefail
-
-image_name="babashka/babashka"
-image_tag=$(cat resources/BABASHKA_VERSION)
-platform=${PLATFORM:-"linux/amd64"}
-latest_tag="latest"
-label_args=("--label" "'org.opencontainers.image.description=Native, fast starting Clojure interpreter for scripting'"
- "--label" "org.opencontainers.image.title=Babashka"
- "--label" "org.opencontainers.image.created=$(date -Iseconds)"
- "--label" "org.opencontainers.image.url=${CIRCLE_REPOSITORY_URL}"
- "--label" "org.opencontainers.image.documentation=${CIRCLE_REPOSITORY_URL}"
- "--label" "org.opencontainers.image.source=${CIRCLE_REPOSITORY_URL}"
- "--label" "org.opencontainers.image.revision=${CIRCLE_SHA1}"
- "--label" "org.opencontainers.image.ref.name=${CIRCLE_TAG}:${CIRCLE_BRANCH}"
- "--label" "org.opencontainers.image.version=${image_tag}")
-
-if [[ $image_tag =~ SNAPSHOT$ ]]; then
- echo "This is a snapshot version"
- snapshot="true"
-else
- echo "This is a non-snapshot version"
- snapshot="false"
-fi
-
-if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]; then
- echo "Building & pushing $platform Docker image(s) $image_name:$image_tag"
- echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
- IFS=',' read -r -a platforms <<< "$platform"
- for p in "${platforms[@]}"; do
- tarball_platform=${p//\//-}
- if [[ $tarball_platform == "linux-arm64" ]]; then tarball_platform="linux-aarch64"; fi
- mkdir -p $p
- tar zxvf "/tmp/release/babashka-${image_tag}-${tarball_platform}.tar.gz" -C $p
- # this overwrites, but this is to work around having built the uberjar/metabom multiple times
- cp "/tmp/release/${tarball_platform}-metabom.jar" ./metabom.jar
- done
- docker buildx build -t "$image_name:$image_tag" --platform "$platform" "${label_args[@]}" --push -f Dockerfile.ci .
- if [[ $snapshot == "false" ]]; then
- echo "Building & pushing $platform Docker image(s) $image_name:$latest_tag"
- docker buildx build -t "$image_name:$latest_tag" --platform "$platform" "${label_args[@]}" --push -f Dockerfile.ci .
- fi
- for p in "${platforms[@]}"; do
- rm -rf $p
- done
-
- # build alpine image for linux-amd64 only (no upstream arm64 support yet)
- tar zxvf "/tmp/release/babashka-${image_tag}-linux-amd64-static.tar.gz"
- echo "Building & pushing Docker image $image_name:$image_tag-alpine"
- docker buildx build -t "$image_name:$image_tag-alpine" --platform=linux/amd64 "${label_args[@]}" --push -f Dockerfile.alpine .
-
- if [[ $snapshot == "false" ]]; then
- echo "Building & pushing Docker image $image_name:alpine"
- docker buildx build -t "$image_name:alpine" --platform=linux/amd64 "${label_args[@]}" --push -f Dockerfile.alpine .
- fi
-else
- echo "Not publishing Docker image"
-fi
-
-exit 0;
diff --git a/.circleci/script/docker.clj b/.circleci/script/docker.clj
new file mode 100644
index 00000000..a884c893
--- /dev/null
+++ b/.circleci/script/docker.clj
@@ -0,0 +1,98 @@
+(require '[clojure.string :as str]
+ '[babashka.process :as proc]
+ '[babashka.fs :as fs])
+(import '[java.time Instant])
+
+(defn read-env
+ ([k]
+ (read-env k nil))
+ ([k default]
+ (or (System/getenv k)
+ default)))
+
+(def image-name "babashka/babashka")
+
+(def image-tag (slurp "resources/BABASHKA_VERSION"))
+
+(def latest-tag "latest")
+
+(def platforms (read-env "PLATFORMS" "linux/amd64"))
+
+(def circle-repository-url (read-env "CIRCLE_REPOSITORY_URL"))
+
+(def label-args
+ ["--label" "'org.opencontainers.image.description=Native, fast starting Clojure interpreter for scripting'"
+ "--label" "org.opencontainers.image.title=Babashka"
+ "--label" (str "org.opencontainers.image.created=" (Instant/now))
+ "--label" (str "org.opencontainers.image.url=" circle-repository-url)
+ "--label" (str "org.opencontainers.image.documentation=" circle-repository-url)
+ "--label" (str "org.opencontainers.image.source=" circle-repository-url)
+ "--label" (str "org.opencontainers.image.revision=" (read-env "CIRCLE_SHA1"))
+ "--label"
+ (format "org.opencontainers.image.ref.name=%s:%s"
+ (read-env "CIRCLE_TAG")
+ (read-env "CIRCLE_BRANCH"))
+ "--label" (str "org.opencontainers.image.version=" image-tag)])
+
+(def snapshot? (str/includes? image-tag "SNAPSHOT"))
+
+(defn exec
+ [cmd]
+ (-> cmd
+ (proc/process {:out :inherit :err :inherit})
+ (proc/check)))
+
+(defn docker-login
+ [username password]
+ (exec ["docker" "login" "-u" username "-p" password]))
+
+(defn build-push
+ [image-tag platform docker-file]
+ (println (format "Building and pushing %s Docker image(s) %s:%s"
+ platform
+ image-name
+ image-tag))
+ (let [base-cmd ["docker" "buildx" "build"
+ "-t" (str image-name ":" image-tag)
+ "--platform" platform
+ "--push"
+ "-f" docker-file]]
+ (exec (concat base-cmd label-args ["."]))))
+
+(defn build-push-images
+ []
+ (doseq [platform (str/split platforms #",")]
+ (let [tarball-platform (str/replace platform #"\/" "-")
+ tarball-platform (if (= "linux-arm64" tarball-platform)
+ "linux-aarch64"
+ tarball-platform)
+ tarball-path (format "/tmp/release/babashka-%s-%s.tar.gz"
+ image-tag
+ tarball-platform)]
+ (fs/create-dirs platform)
+ (exec ["tar" "zxvf" tarball-path "-C" platform])
+ ; this overwrites, but this is to work around having built the uberjar/metabom multiple times
+ (fs/copy (format "/tmp/release/%s-metabom.jar" tarball-platform) "metabom.jar" {:replace-existing true})))
+ (build-push image-tag platforms "Dockerfile.ci")
+ (when-not snapshot?
+ (build-push latest-tag platforms "Dockerfile.ci")))
+
+(defn build-push-alpine-images
+ "Build alpine image for linux-amd64 only (no upstream arm64 support yet)"
+ []
+ (exec ["tar" "zxvf" (str "/tmp/release/babashka-" image-tag "-linux-amd64-static.tar.gz")])
+ (build-push (str image-tag "-alpine") "linux/amd64" "Dockerfile.alpine")
+ (when-not snapshot?
+ (build-push "alpine" "linux/amd64" "Dockerfile.alpine")))
+
+(when (= *file* (System/getProperty "babashka.file"))
+ (if (and (nil? (read-env "CIRCLE_PULL_REQUEST"))
+ (= "master" (read-env "CIRCLE_BRANCH")))
+ (do
+ (if snapshot?
+ (println "This is a snapshot version")
+ (println "This is a non-snapshot version"))
+ (docker-login (read-env "DOCKERHUB_USER") (read-env "DOCKERHUB_PASS"))
+ (build-push-images)
+ (build-push-alpine-images))
+ (println "Not publishing docker image(s).")))
diff --git a/.circleci/script/short_ci.clj b/.circleci/script/short_ci.clj
new file mode 100644
index 00000000..f467f36b
--- /dev/null
+++ b/.circleci/script/short_ci.clj
@@ -0,0 +1,276 @@
+(ns short-ci
+ (:require
+ [babashka.tasks :as tasks]
+ [clj-yaml.core :as yaml]
+ [clojure.string :as str]
+ [flatland.ordered.map :refer [ordered-map]]))
+
+(defn run
+ ([cmd-name cmd]
+ (run cmd-name cmd nil))
+ ([cmd-name cmd no-output-timeout]
+ (let [base {:run {:name cmd-name
+ :command cmd}}]
+ (if no-output-timeout
+ (assoc-in base [:run :no_output_timeout] no-output-timeout)
+ base))))
+
+(defn gen-steps
+ [shorted? steps]
+ (if shorted?
+ [(run "Shorted" "echo 'Skipping Run'")]
+ steps))
+
+(defn gen-job
+ [shorted? conf]
+ (if shorted?
+ (-> conf
+ (dissoc :machine :macos)
+ (assoc :resource_class "small" :docker [{:image "ubuntu:latest"}]))
+ conf))
+
+(defn pull-submodules
+ []
+ (run "Pull Submodules" "git submodule init\ngit submodule update"))
+
+(defn deploy
+ [shorted?]
+ (gen-job shorted?
+ (ordered-map
+ :resource_class "large"
+ :docker [{:image "circleci/clojure:lein-2.9.8"}]
+ :working_directory "~/repo"
+ :environment {:LEIN_ROOT "true"}
+ :steps (gen-steps
+ shorted?
+ [:checkout
+ (pull-submodules)
+ {:restore_cache {:keys ["v1-dependencies-{{ checksum \"project.clj\" }}"
+ "v1-dependencies-"]}}
+ {:run ".circleci/script/deploy"}
+ {:save_cache {:paths ["~/.m2"]
+ :key "v1-dependencies-{{ checksum \"project.clj\" }}"}}]))))
+
+(defn docker
+ [shorted?]
+ (gen-job
+ shorted?
+ (ordered-map
+ :machine {:image "ubuntu-2004:202111-01"}
+ :steps
+ (gen-steps
+ shorted?
+ [:checkout
+ (pull-submodules)
+ "setup-docker-buildx"
+ {:attach_workspace {:at "/tmp"}}
+ (run "Build uberjar" "script/uberjar")
+ {:run
+ {:name "Build Docker image"
+ :environment {:PLATFORMS "linux/amd64,linux/arm64"}
+ :command
+ "java -jar ./target/babashka-$(cat resources/BABASHKA_VERSION)-standalone.jar .circleci/script/docker.clj"}}]))))
+
+(defn jvm
+ [shorted? graalvm-home]
+ (gen-job
+ shorted?
+ (ordered-map
+ :docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]
+ :working_directory "~/repo"
+ :environment {:LEIN_ROOT "true"
+ :BABASHKA_PLATFORM "linux"
+ :GRAALVM_VERSION "22.3.0"
+ :GRAALVM_HOME graalvm-home}
+ :resource_class "large"
+ :steps
+ (gen-steps
+ shorted?
+ [:checkout
+ (pull-submodules)
+ {:restore_cache {:keys ["v1-dependencies-{{ checksum \"project.clj\" }}-{{ checksum \"deps.edn\" }}"
+ "v1-dependencies-"]}}
+ (run "Install Clojure" "sudo script/install-clojure")
+ (run "Download GraalVM" "script/install-graalvm")
+ (run
+ "Run JVM tests"
+ "export BABASHKA_FEATURE_JDBC=true
+export BABASHKA_FEATURE_POSTGRESQL=true
+script/test\nscript/run_lib_tests")
+ (run "Run as lein command" ".circleci/script/lein")
+ (run
+ "Create uberjar"
+ "mkdir -p /tmp/release
+script/uberjar
+VERSION=$(cat resources/BABASHKA_VERSION)
+jar=target/babashka-$VERSION-standalone.jar
+cp $jar /tmp/release
+export PATH=$GRAALVM_HOME/bin:$PATH
+export JAVA_HOME=$GRAALVM_HOME
+java -jar $jar script/reflection.clj
+reflection=\"babashka-$VERSION-reflection.json\"
+java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$jar\"
+java -jar \"$jar\" --config .build/bb.edn --deps-root . release-artifact \"$reflection\"")
+ {:store_artifacts {:path "/tmp/release"
+ :destination "release"}}
+ {:save_cache {:paths ["~/.m2"]
+ :key "v1-dependencies-{{ checksum \"project.clj\" }}-{{ checksum \"deps.edn\" }}"}}]))))
+
+(defn unix
+ [shorted? static? musl? arch executor-conf resource-class graalvm-home platform]
+ (let [env {:LEIN_ROOT "true"
+ :GRAALVM_VERSION "22.3.0"
+ :GRAALVM_HOME graalvm-home
+ :BABASHKA_PLATFORM (if (= "mac" platform)
+ "macos"
+ platform)
+ :BABASHKA_TEST_ENV "native"
+ :BABASHKA_XMX "-J-Xmx6500m"}
+ env (if (= "aarch64" arch)
+ (assoc env :BABASHKA_ARCH arch)
+ env)
+ env (if static?
+ (assoc env :BABASHKA_STATIC "true")
+ env)
+ env (if musl?
+ (assoc env :BABASHKA_MUSL "true")
+ env)
+ env (if (= "mac" platform)
+ (assoc env :MACOSX_DEPLOYMENT_TARGET 10.13)
+ env)
+ base-install-cmd "sudo apt-get update\nsudo apt-get -y install build-essential zlib1g-dev"
+ cache-key (format "%s-%s{{ checksum \"project.clj\" }}-{{ checksum \".circleci/config.yml\" }}"
+ platform
+ (if (= "aarch64" arch)
+ "aarch64-"
+ ""))]
+ (gen-job shorted?
+ (merge
+ executor-conf
+ (ordered-map
+ :working_directory "~/repo"
+ :environment env
+ :resource_class resource-class
+ :steps (gen-steps shorted?
+ (filter some?
+ [:checkout
+ {:attach_workspace {:at "/tmp"}}
+ (run "Pull Submodules" "git submodule init\ngit submodule update")
+ {:restore_cache
+ {:keys [cache-key]}}
+ (run "Install Clojure" "sudo script/install-clojure")
+ (when (= "mac" platform)
+ (run "Install Leiningen" "script/install-leiningen"))
+ (when (not= "mac" platform)
+ (run "Install native dev tools"
+ (if (and static? musl? (not= "aarch64" arch))
+ (str base-install-cmd "\nsudo -E script/setup-musl")
+ base-install-cmd)))
+ (run "Download GraalVM" "script/install-graalvm")
+ (run "Build binary" "script/uberjar\nscript/compile" "30m")
+ (run "Run tests" "script/test\nscript/run_lib_tests")
+ (run "Release" ".circleci/script/release")
+ {:persist_to_workspace {:root "/tmp"
+ :paths ["release"]}}
+ {:save_cache
+ {:paths ["~/.m2" "~/graalvm-ce-java11-22.3.0"]
+ :key cache-key}}
+ {:store_artifacts {:path "/tmp/release"
+ :destination "release"}}
+ (run "Publish artifact link to Slack"
+ "./bb .circleci/script/publish_artifact.clj || true")])))))))
+
+(defn make-config
+ [shorted?]
+ (let [docker-executor-conf {:docker [{:image "circleci/clojure:openjdk-11-lein-2.9.8-bullseye"}]}
+ machine-executor-conf {:machine {:image "ubuntu-2004:202111-01"}}
+ mac-executor-conf {:macos {:xcode "14.0.0"}}
+ linux-graalvm-home "/home/circleci/graalvm-ce-java11-22.3.0"
+ mac-graalvm-home "/Users/distiller/graalvm-ce-java11-22.3.0/Contents/Home"]
+ (ordered-map
+ :version 2.1
+ :commands
+ {:setup-docker-buildx
+ {:steps
+ [{:run
+ {:name "Create multi-platform capabale buildx builder"
+ :command
+ "docker run --privileged --rm tonistiigi/binfmt --install all\ndocker buildx create --name ci-builder --use"}}]}}
+ :jobs (ordered-map
+ :jvm (jvm shorted? linux-graalvm-home)
+ :linux (unix shorted? false false "amd64" docker-executor-conf "large" linux-graalvm-home "linux")
+ :linux-static
+ (unix shorted? true true "amd64" docker-executor-conf "large" linux-graalvm-home "linux")
+ :linux-aarch64 (unix shorted?
+ false
+ false
+ "aarch64"
+ machine-executor-conf
+ "arm.large"
+ linux-graalvm-home
+ "linux")
+ :linux-aarch64-static
+ (unix shorted? true false "aarch64" machine-executor-conf "arm.large" linux-graalvm-home "linux")
+ :mac (unix shorted? false false "amd64" mac-executor-conf "large" mac-graalvm-home "mac")
+ :deploy (deploy shorted?)
+ :docker (docker shorted?))
+ :workflows (ordered-map
+ :version 2
+ :ci {:jobs ["jvm"
+ "linux"
+ "linux-static"
+ "mac"
+ "linux-aarch64"
+ "linux-aarch64-static"
+ {:deploy {:filters {:branches {:only "master"}}
+ :requires ["jvm" "linux"]}}
+ {:docker {:filters {:branches {:only "master"}}
+ :requires ["linux" "linux-static" "linux-aarch64"]}}]}))))
+
+(def skip-config
+ {:skip-if-only [#".*.md$"
+ #"^logo\/.*$"]})
+
+(defn get-changes
+ []
+ (-> (tasks/shell {:out :string} "git diff --name-only HEAD~1")
+ (:out)
+ (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]} skip-config
+ changed-files (get-changes)
+ conf (make-config (not (relevant? changed-files skip-if-only)))]
+ (println (yaml/generate-string conf
+ :dumper-options
+ {:flow-style :block}))))
+
+(when (= *file* (System/getProperty "babashka.file"))
+ (main))
+
+(comment
+ (main)
+
+ (def regexes
+ [#".*.md$"
+ #".*.clj$" ; ignore clojure files
+ #"^logo\/.*$"])
+
+ (:out (tasks/shell {:out :string} "ls"))
+
+ (irrelevant-change? "src/file.png" regexes)
+
+ (re-matches #".*.clj$" "src/file.clj.dfff")
+
+ (re-matches #"^logo\/.*$" "logo/foo/bar.jpg")
+
+ (relevant? ["src/file.clj"] regexes))
diff --git a/.cirrus.yml b/.cirrus.yml
new file mode 100644
index 00000000..34ebcced
--- /dev/null
+++ b/.cirrus.yml
@@ -0,0 +1,39 @@
+macos_instance:
+ image: ghcr.io/cirruslabs/macos-monterey-base:latest
+
+task:
+ skip: "changesIncludeOnly('logo/*', '**.md')"
+ env:
+ LEIN_ROOT: "true"
+ GRAALVM_VERSION: "22.3.0"
+ GRAALVM_HOME: ${HOME}/graalvm-ce-java11-22.3.0/Contents/Home
+ BABASHKA_PLATFORM: macos # used in release script
+ BABASHKA_ARCH: aarch64
+ BABASHKA_TEST_ENV: native
+ BABASHKA_XMX: "-J-Xmx6500m"
+ GITHUB_TOKEN: ENCRYPTED[d6ff8cdc392157f211c754fa0763875434d1bfde0c00a05e48ba9470003a76c14c9213adb80623f81e13f2f0fa8fbd57]
+ script: |
+ git submodule init
+ git submodule update
+
+ sudo script/install-clojure
+ sudo script/install-leiningen
+ script/install-graalvm
+ export PATH=$GRAALVM_HOME/bin:$PATH
+ export JAVA_HOME=$GRAALVM_HOME
+ sudo /usr/sbin/softwareupdate --install-rosetta --agree-to-license
+ java -version
+
+ script/uberjar
+ script/compile
+
+ # script/test
+ # script/run_lib_tests
+
+ VERSION=$(cat resources/BABASHKA_VERSION)
+ arch=${BABASHKA_ARCH:-amd64}
+ archive="babashka-$VERSION-$BABASHKA_PLATFORM-$arch.tar.gz"
+ tar zcvf "$archive" bb
+ ./bb --config .build/bb.edn --deps-root . release-artifact "$archive" || true
+ binaries_artifacts:
+ path: "babashka-*.tar.gz"
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn
index 2f0de4a9..2e9b6f40 100644
--- a/.clj-kondo/config.edn
+++ b/.clj-kondo/config.edn
@@ -5,4 +5,5 @@
babashka.impl.File/gen-wrapper-fn-2 clojure.core/def
babashka.impl.Pattern/gen-wrapper-fn-2 clojure.core/def
babashka.impl.Pattern/gen-constants clojure.core/declare}
- :linters {:unsorted-required-namespaces {:level :warning}}}
+ :linters {:unsorted-required-namespaces {:level :warning}}
+ :hooks {:analyze-call {clojure.core/requiring-resolve hooks.mine/req-resolve}}}
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 57b20f95..66e1f6ef 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,82 +2,77 @@ name: build
on:
push:
+ paths-ignore:
+ - "**.md"
+ - "logo/**"
+ branches:
+ - master
+ pull_request:
+ paths-ignore:
+ - "**.md"
+ - "logo/**"
branches:
- master
+# TODO: Add deploy if needed
jobs:
-
- scratch:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- runs-on: ubuntu-18.04
- steps:
- - name: Git checkout
- uses: actions/checkout@v1
- with:
- fetch-depth: 1
- submodules: 'true'
-
- - name: Scratch
- run: |
- echo "Scratch"
-
jvm:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- # ubuntu 18.04 comes with lein + java8 installed
- runs-on: ubuntu-18.04
+ if: ${{ false }} # Disabled
+ # if: "!contains(github.event.head_commit.message, 'skip ci')"
+ runs-on: ubuntu-latest
+ env:
+ LEIN_ROOT: "true"
+ BABASHKA_PLATFORM: linux # could be used in jar name
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Git checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
- name: Cache deps
- uses: actions/cache@v1
+ uses: actions/cache@v2
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
- restore-keys: |
- ${{ runner.os }}-maven-
+ restore-keys: ${{ runner.os }}-maven-
- - name: Cache GraalVM
- uses: actions/cache@v1
- id: cache-graalvm
+ - name: Prepare java
+ uses: actions/setup-java@v2
with:
- path: ~/graalvm-ce-java11-22.0.0.2
- key: ${{ runner.os }}-graalvm-22.0.0.2
- restore-keys: |
- ${{ runner.os }}-graalvm-22.0.0.2
+ distribution: 'adopt-hotspot'
+ java-version: '11'
- - name: Download GraalVM
- run: |
- cd ~
- if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
- curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- fi
-
- - name: Fetch deps
- if: steps.cache-deps.outputs.cache-hit != 'true'
- run: |
- lein deps
+ - name: Install clojure tools
+ uses: DeLaGuardo/setup-clojure@5.0
+ with:
+ cli: 1.10.3.1040
+ lein: 2.9.8
- name: Run tests
+ env:
+ BABASHKA_FEATURE_JDBC: "true"
+ BABASHKA_FEATURE_POSTGRESQL: "true"
run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
script/test
-
- - name: Test libraries
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- sudo script/install-clojure
script/run_lib_tests
+ - name: Run as lein command
+ run: echo '{:a 1}' | lein bb '(:a *in*)'
+
- name: Build uberjar
run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
+ mkdir -p /tmp/release
script/uberjar
+ VERSION=$(cat resources/BABASHKA_VERSION)
+ jar=target/babashka-$VERSION-standalone.jar
+ cp $jar /tmp/release
+ java -jar $jar script/reflection.clj
+ reflection="babashka-$VERSION-reflection.json"
+ java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$jar"
+ java -jar "$jar" --config .build/bb.edn --deps-root . release-artifact "$reflection"
- name: Babashka version
id: babashka-version
@@ -87,50 +82,76 @@ jobs:
- uses: actions/upload-artifact@v1
with:
- name: jar
+ name: babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
path: target/babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
- linux:
+ native:
if: "!contains(github.event.head_commit.message, 'skip ci')"
- needs: [jvm]
- runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ include:
+ - os: macos-12
+ name: macos
+ static: false
+ #- os: ubuntu-latest
+ # name: linux
+ # static: false
+ #- os: ubuntu-latest
+ # name: linux
+ # static: true
+ runs-on: ${{ matrix.os }}
+ env:
+ LEIN_ROOT: "true"
+ GRAALVM_VERSION: "22.3.0"
+ BABASHKA_PLATFORM: ${{ matrix.name }} # used in release script
+ BABASHKA_TEST_ENV: native
+ BABASHKA_XMX: "-J-Xmx6500m"
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Git checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
- - uses: actions/download-artifact@v1
- with:
- name: jar
- path: .
-
- name: Cache deps
- uses: actions/cache@v1
+ uses: actions/cache@v2
id: cache-deps
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
- restore-keys: |
- ${{ runner.os }}-maven-
+ restore-keys: ${{ runner.os }}-maven-
- - name: Cache GraalVM
- uses: actions/cache@v1
- id: cache-graalvm
+ - name: Setup GraalVM
+ if: "matrix.static == false"
+ uses: graalvm/setup-graalvm@v1
with:
- path: ~/graalvm-ce-java11-22.0.0.2
- key: ${{ runner.os }}-graalvm-22.0.0.2
- restore-keys: |
- ${{ runner.os }}-graalvm-22.0.0.2
+ version: '22.3.0'
+ java-version: '11'
+ components: 'native-image'
+ github-token: ${{ secrets.GITHUB_TOKEN }}
- - name: Download GraalVM
+ - name: Setup GraalVM+musl
+ if: "matrix.static == true"
+ uses: graalvm/setup-graalvm@v1
+ with:
+ version: '22.3.0'
+ java-version: '11'
+ components: 'native-image'
+ native-image-musl: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Install clojure tools
+ uses: DeLaGuardo/setup-clojure@5.0
+ with:
+ cli: 1.10.3.1040
+ lein: 2.9.8
+
+ - name: Install native dev tools
+ if: matrix.os == 'ubuntu-latest'
run: |
- cd ~
- if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
- curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- fi
+ sudo apt-get update
+ sudo apt-get -y install build-essential zlib1g-dev
- name: Babashka version
id: babashka-version
@@ -138,209 +159,50 @@ jobs:
BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
echo "##[set-output name=version;]${BABASHKA_VERSION}"
- - name: Build Linux native image
- run: |
- export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
- export BABASHKA_XMX="-J-Xmx6g"
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- script/compile
+ - name: Build uberjar
+ run: script/uberjar
- - name: Test binary
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- BABASHKA_TEST_ENV=native script/test
+ - name: Build native image
+ if: "matrix.static == false"
+ run: script/compile
- - name: Install clojure
- run: |
- sudo script/install-clojure /usr/local
-
- - name: Test libraries
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- BABASHKA_TEST_ENV=native script/run_lib_tests
-
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- path: bb
- name: babashka-${{ steps.babashka-version.outputs.version }}-linux-amd64.zip
-
- linux-static:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- needs: [jvm]
- runs-on: ubuntu-16.04
- steps:
- - name: Git checkout
- uses: actions/checkout@v1
- with:
- fetch-depth: 1
- submodules: 'true'
-
- - uses: actions/download-artifact@v1
- with:
- name: jar
- path: .
-
- - name: Cache deps
- uses: actions/cache@v1
- id: cache-deps
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
- restore-keys: |
- ${{ runner.os }}-maven-
-
- - name: Cache GraalVM
- uses: actions/cache@v1
- id: cache-graalvm
- with:
- path: ~/graalvm-ce-java11-22.0.0.2
- key: ${{ runner.os }}-graalvm-22.0.0.2
- restore-keys: |
- ${{ runner.os }}-graalvm-22.0.0.2
-
- - name: Download GraalVM
- run: |
- cd ~
- if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
- curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- tar xzf graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz
- fi
-
- - name: Babashka version
- id: babashka-version
- run: |
- BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
- echo "##[set-output name=version;]${BABASHKA_VERSION}"
-
- - name: Build Linux native image
- run: |
- export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
- export BABASHKA_XMX="-J-Xmx6g"
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- export BABASHKA_STATIC=true
- script/compile
-
- - name: Test binary
- run: |
- ./bb '(+ 1 2 3)'
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- BABASHKA_TEST_ENV=native script/test
-
- - name: Install clojure
- run: |
- sudo script/install-clojure
-
- - name: Test libraries
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2"
- BABASHKA_TEST_ENV=native script/run_lib_tests
-
- - name: Upload artifact
- uses: actions/upload-artifact@v2
- with:
- path: bb
- name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
-
- mac:
- if: "!contains(github.event.head_commit.message, 'skip ci')"
- needs: [jvm]
- runs-on: macos-latest
- steps:
- - name: Git checkout
- uses: actions/checkout@v1
- with:
- fetch-depth: 1
- submodules: 'true'
-
- - uses: actions/download-artifact@v1
- with:
- name: jar
- path: .
-
- - name: Cache GraalVM
- uses: actions/cache@v1
- id: cache-graalvm
- with:
- path: ~/graalvm-ce-java11-22.0.0.2
- key: ${{ runner.os }}-graalvm-22.0.0.2
- restore-keys: |
- ${{ runner.os }}-graalvm-22.0.0.2
-
- - name: Download GraalVM
- run: |
- cd ~
- if ! [ -d graalvm-ce-java11-22.0.0.2 ]; then
- curl -O -sL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz
- tar xzf graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz
- fi
-
- - name: Babashka version
- id: babashka-version
- run: |
- BABASHKA_VERSION=$(cat resources/BABASHKA_VERSION)
- echo "##[set-output name=version;]${BABASHKA_VERSION}"
-
- - name: Build macOS native image
- run: |
- export BABASHKA_JAR=babashka-${{ steps.babashka-version.outputs.version }}-standalone.jar
- export BABASHKA_XMX="-J-Xmx6g"
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
- script/compile
-
- - name: Test binary
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
- sudo script/install-leiningen
- BABASHKA_TEST_ENV=native script/test
-
- - name: Test libraries
- run: |
- export GRAALVM_HOME="$HOME/graalvm-ce-java11-22.0.0.2/Contents/Home"
- sudo script/install-clojure
- BABASHKA_TEST_ENV=native script/run_lib_tests
-
- - uses: actions/upload-artifact@v1
- with:
- path: bb
- name: babashka-${{ steps.babashka-version.outputs.version }}-macos-amd64.zip
-
- deploy:
- if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
- needs: [jvm, linux, linux-static, mac]
- runs-on: ubuntu-18.04
- steps:
- - name: Git checkout
- uses: actions/checkout@v1
- with:
- fetch-depth: 1
- submodules: 'true'
-
- - name: Cache deps
- uses: actions/cache@v1
- id: cache-deps
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ hashFiles('project.clj') }}
- restore-keys: |
- ${{ runner.os }}-maven-
-
- - name: Deploy
+ - name: Build static native image
+ if: "matrix.static == true"
env:
- CLOJARS_USER: "${{ secrets.CLOJARS_USER }}"
- CLOJARS_PASS: "${{ secrets.CLOJARS_PASS }}"
+ BABASHKA_STATIC: "true"
+ BABASHKA_MUSL: "true"
+ run: script/compile
+
+ - name: Test binary and libs
run: |
- .github/script/deploy
+ script/test
+ script/run_lib_tests
+
+ - name: Release
+ run: .circleci/script/release
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v2
+ with:
+ path: bb
+ name: babashka-${{ steps.babashka-version.outputs.version }}-${{ matrix.name }}-amd64
+
+ - name: Upload static artifact
+ if: "matrix.static == true"
+ uses: actions/upload-artifact@v2
+ with:
+ path: bb
+ name: babashka-${{ steps.babashka-version.outputs.version }}-${{ matrix.name }}-static-amd64
docker:
- if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
+ if: ${{ false }} # Disabled
+ # if: "!contains(github.event.head_commit.message, 'skip ci') && github.event_name == 'push' && github.ref == 'refs/heads/master'"
needs:
- - linux
- - linux-static
- runs-on: ubuntu-18.04
+ - native
+ runs-on: ubuntu-latest
steps:
- name: Git checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: 'true'
@@ -366,9 +228,16 @@ jobs:
name: babashka-${{ steps.babashka-version.outputs.version }}-linux-static-amd64.zip
path: /tmp/release-static
+ - name: Set up Docker Buildx
+ id: buildx
+ uses: docker/setup-buildx-action@v2
+
+ - name: Build uberjar
+ run: script/uberjar
+
- name: Docker build
env:
DOCKERHUB_USER: "${{ secrets.DOCKERHUB_USER }}"
DOCKERHUB_PASS: "${{ secrets.DOCKERHUB_PASS }}"
- run: |
- .github/script/docker
+ PLATFORMS: linux/amd64,linux/arm64
+ run: java -jar ./target/babashka-$(cat resources/BABASHKA_VERSION)-standalone.jar .circleci/script/docker.clj
diff --git a/.gitignore b/.gitignore
index fb29f608..284c61e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,6 @@ org_babashka*.h
.envrc
.lsp
bb.build_artifacts.txt
+target
+.nrepl-port
+.DS_Store
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4c9a92b..473540ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,241 @@ For a list of breaking changes, check [here](#breaking-changes).
A preview of the next release can be installed from
[babashka-dev-builds](https://github.com/babashka/babashka-dev-builds).
+[Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting
+
+## Unreleased
+
+- Implement `ns`, `lazy-seq` as macro
+- Support `--dev-build` flag in installation script
+- [#1451](https://github.com/babashka/babashka/issues/1451): Allow passing explicit file and line number to clojure.test ([@matthewdowney](https://github.com/matthewdowney))
+- [#1280](https://github.com/babashka/babashka/issues/1280): babashka REPL doesn't quit right after Ctrl-d ([@formerly-a-trickster](https://github.com/formerly-a-trickster) and Alice Margatroid)
+- [#1446](https://github.com/babashka/babashka/issues/1446): add `pprint/code-dispatch`
+- Update zlib to version `1.2.13` ([@thiagokokada](https://github.com/thiagokokada))
+- [#1454](https://github.com/babashka/babashka/issues/1454): Add `babashka.process` to `print-deps` output
+
+## 1.0.168 (2022-12-07)
+
+- `loop*`, `fn*` are now special forms and `loop`, `fn`, `defn`, `defmacro`, `and` and `or` are implemented as macros. This restores compatibility with [rcf](https://github.com/borkdude/hyperfiddle-rcf)
+- fs: don't touch dirs in `split-ext`
+- Update to babashka process to v0.4.13: support `(process opts? & args)` syntax everywhere
+- [#1438](https://github.com/babashka/babashka/issues/1438): expose `query-string` and `url-encode` functions from org.httpkit.client ([@bobisageek](https://github.com/bobisageek))
+- Add `java.util.InputMismatchException`
+
+## 1.0.167 (2022-11-30)
+
+- [#1433](https://github.com/babashka/babashka/issues/1433): spec source as built-in fallback. When not including the
+ [clojure.spec.alpha](https://github.com/babashka/spec.alpha) fork as a
+ library, babashka loads a bundled version, when `clojure.spec.alpha` is required.
+- [#1430](https://github.com/babashka/babashka/issues/1430): Fix issue with `bb tasks` throwing on empty display tasks list.
+- Add note about BSOD when using WSL1, see [README.md/quickstart](https://github.com/LouDnl/babashka#quickstart)
+- SCI: performance improvements
+- Better error locations for interop ([@bobisageek](https://github.com/bobisageek))
+- Fix [babashka/babashka.nrepl#59](https://github.com/babashka/babashka.nrepl/issues/59): do not output extra new line with cider pprint
+- Use `namespace-munge` instead of `munge` for doing ns -> file lookup
+
+## 1.0.166 (2022-11-24)
+
+See the [Testing babashka scripts](https://blog.michielborkent.nl/babashka-test-runner.html) blog post for how to run tests with this release.
+
+- Compatibility with Cognitest [test-runner](https://github.com/cognitect-labs/test-runner) and [tools.namespace](https://github.com/clojure/tools.namespace)
+- Add `run-test` and `run-test-var` to `clojure.test`
+- Compile distributed uberjar using GraalVM, fixes `babashka.process/exec` for Nix
+- [#1414](https://github.com/babashka/babashka/issues/1414): preserve metadata on exec task function argument map
+- [#1269](https://github.com/babashka/babashka/issues/1269): add lib tests for sluj ([@bobisageek](https://github.com/bobisageek))
+- Update nix app example in docs
+- Add `java.lang.Error` and `java.net.URLClassLoader` (only for compatibility with the `clojure.java.classpath` lib)
+- Deps.clj `deps.clj: 1.11.1.1200`
+- Upgrade timbre to `6.0.1`
+- Performance improvements in SCI
+- SCI: preserve stack information on `throw` expressions
+
+## 1.0.165 (2022-11-01)
+
+- Fix [#1401](https://github.com/babashka/babashka/issues/1401): mutation of `deftype` field should be visible in protocol method
+- Fix [#1405](https://github.com/babashka/babashka/issues/1405): drop name metadata from conditionally defined var
+- [#602](https://github.com/babashka/babashka/issues/602): add lib tests for clj-commons/fs ([@bobisageek](https://github.com/bobisageek))
+- Add `java.net.URLConnection` class
+- Add `java.time.zone.ZoneRules` class
+- Copy more docstrings for core macros and vars
+- Bump `core.async` to `1.6.673`
+- Implement `in-ns` as function, rather than special form ([@SignSpice](https://github.com/SignSpice))
+- Bump `deps.clj` to `1.11.1.1182`
+- Bump GraalVM to `22.3.0`
+- SCI: don't rely on metadata for record implementation
+
+## 1.0.164 (2022-10-17)
+
+- SCI: optimizations for `let`
+- Add single argument read method support to PipedInputStream proxy ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- feat: Honor `*print-namespace-maps*` in pprint ([@ghoseb](https://github.com/ghoseb))
+- [#1369](https://github.com/babashka/babashka/issues/1369): provide `.sha256` files for every released asset
+- [#1397](https://github.com/babashka/babashka/issues/1397): Add `clojure.lang.Namespace` as alias for `sci.lang.Namespace`, such that `(instance? clojure.lang.Namespace *ns*)` returns `true` in bb
+- [#1384](https://github.com/babashka/babashka/issues/1384): allow `.indexOf` on `LazySeq`
+- [#1330](https://github.com/babashka/babashka/issues/1330): allow `(set! *warn-on-reflection*)` in programmatic nREPL
+- Better error message when failing to load `bb.edn` ([@lispyclouds](https://github.com/lispyclouds))
+- Pods: print and flush to `*out*` and `*err*` instead of using `println` ([@justone](https://github.com/justone))
+- deps.clj: support for `CLJ_JVM_OPTS` and `JAVA_OPTS` ([@ikappaki](https://github.com/ikappaki))
+- Fix `*print-namespace-maps*` when using `clojure.pprint` ([@ghoseb](https://github.com/ghoseb))
+- Process: only slurp `*err*` when inputstream ([@ikappaki](https://github.com/ikappaki))
+- Process: add `alive?` API function ([@grzm](https://github.com/grzm))
+- Bump libraries: tools.cli, babashka.cli
+- [#1391](https://github.com/babashka/babashka/issues/1391): include raw in `hiccup2.core` ns
+- [#1391](https://github.com/babashka/babashka/issues/1391): support loading `hiccup.page` when adding hiccup to deps
+
+## 0.10.163 (2022-09-24)
+
+- [#808](https://github.com/babashka/babashka/issues/808): support `-Sdeps` option to support passing extra deps map which will be merged last
+- [#1336](https://github.com/babashka/babashka/issues/1336): tasks subcommand doesn't work with global `-Sforce` option ([@bobisageek](https://github.com/bobisageek))
+- [#1340](https://github.com/babashka/babashka/issues/1340): `defprotocol` methods are missing `:doc` metadata ([@bobisageek](https://github.com/bobisageek))
+- [#1368](https://github.com/babashka/babashka/issues/1368): `-x`: do not pick up on aliases in `user` ns
+- [#1367](https://github.com/babashka/babashka/issues/1367): Fix line number in clojure.test output ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- [#1370](https://github.com/babashka/babashka/issues/1370): Add `core.async` `to-chan!`, `to-chan!!`, `onto-chan!` ([@cap10morgan](https://github.com/cap10morgan))
+- [#1358](https://github.com/babashka/babashka/issues/1358): Expose a subset of `java.lang.ref` to enable hooking into the destruction/GC of objects ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- [#1364](https://github.com/babashka/babashka/issues/1364): Be tolerant of unknown tags in `bb.edn`
+- Add and expose `babashka.classes/all-classes` to get a list of all available classes (as `java.lang.Class` objects) ([@eerohele](https://github.com/eerohele))
+- Add more reflection class methods ([@eerohele](https://github.com/eerohele))
+- Bump `clj-yaml`
+- Add `-x` help
+- Set `TCP_NODELAY` in pods for performance
+- Expose `clojure.main/with-bindings`
+- Add `ThreadPoolExecutor` rejection policy classes ([@eerohele](https://github.com/eerohele))
+- Download but don't run pods when `os.name` / `os.arch` don't match ([@cap10morgan](https://github.com/cap10morgan))
+- Add `clojure.core.server/stop-server` ([@eerohele](https://github.com/eerohele))
+- Add `ns-unalias`
+- Add `AtomicInteger` and `AtomicLong` to full interop
+- Add `PrintWriter-on`
+- Improve `reify` error messages ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- Expose `core.async` `ManyToManyChannel`
+- fs: add `write-lines`
+- fs: add `write-bytes`
+- [#1350](https://github.com/babashka/babashka/issues/1350): map `clojure.lang.Var` to `sci.lang.Var`
+- Use temporary fork of `clj-yaml` with new `:load-all`, `:unknown-tag-fn`
+ options and preserves strings with numbers that start with zeros as strings
+ (this solves a problem when YAML 1.1 output is read as YAML 1.2.). Once
+ upstream SnakeYAML 1.33 lands, this will be used again.
+
+## 0.9.162 (2022-09-04)
+
+Check out our new project: [bbin](https://github.com/babashka/bbin): install any Babashka script or project with one command. Thanks [@rads](https://github.com/rads)!
+
+- Throw exception on attempt to reify multiple interfaces ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- Allow java.lang.Object reify with empty methods ([@retrogradeorbit](https://github.com/retrogradeorbit))
+- [#1343](https://github.com/babashka/babashka/issues/1343): Fix postgres feature
+- [#1345](https://github.com/babashka/babashka/issues/1345): add `javax.net.ssl.SSLException` and `java.net.SocketTimeoutException` classes ([@lread](https://github.com/lread))
+- Fix `satisfies?` with marker protocol (no methods)
+- Update `rewrite-clj`
+- Update `deps.clj`
+- Update `babashka.cli`
+- Update `org.clj-commons/clj-yaml`
+- `babashka.fs`: fix `expand-home` on Windows
+- `babashka.fs`: expose `:win-exts`
+- nREPL: preserve stacktrace on exception
+- Fix [#1322](https://github.com/babashka/babashka/issues/1322): improve error location
+- Fix [#1338](https://github.com/babashka/babashka/issues/1338): `add-watch` segfault
+- Fix [#1339](https://github.com/babashka/babashka/issues/1339): resolve record name ending with dot.
+
+## 0.9.161 (2022-07-31)
+
+- Fix `exec`
+
+## 0.9.160 (2022-07-29)
+
+- Breaking: change `exec`, introduced in `0.9.159` to a function instead.
+ You now write `(exec 'mynamespace.function)` instead.
+
+## 0.9.159 (2022-07-29)
+
+Read the introductory blog post about the new babashka CLI integration [here](https://blog.michielborkent.nl/babashka-tasks-meets-babashka-cli.html).
+
+- [#1324](https://github.com/babashka/babashka/issues/1324): `-x` to invoke a function with babashka CLI
+- [#1324](https://github.com/babashka/babashka/issues/1324): `babashka.tasks/exec` to invoke a function with babashka CLI in tasks
+- SCI: don't eval metatada on defn body
+- SCI issue 774: make interpreter stacktrace available to user
+- `babashka.process`: improve `tokenize`
+- Upgrade to GraalVM 22.2.0 (#1325)
+
+## 0.8.157 (2022-07-01)
+
+- Add compatibility with [`metosin/malli`](https://github.com/metosin/malli#babashka) `{:mvn/version "0.8.9"}`.
+- Expose `babashka.nrepl.server/start-server!`- and `stop-server!`-functions to support programmatically starting
+ an nrepl-server. `start-server!` is redefined to not require a sci-context as its first argument.
+- Fix misspelling in script/uberjar: `BABASHKA_FEATURE_TRANSIT`
+
+## 0.8.156 (2022-06-08)
+
+- macOS aarch64 support. Upgrading via brew or the installer script should
+ install the aarch64 version on an M1 system.
+- Support for running [prismatic/schema](https://github.com/plumatic/schema)
+ from source. There is an open PR for babashka. Until it is merged you can use
+ [this](https://github.com/borkdude/schema/tree/bb-test-suite) fork.
+- SCI: many small improvements, especially in `defrecord` (discovered while
+ trying to make `schema.core` work)
+- Switch version schema to major.minor.release_count.
+- babashka.nrepl: fix completions for static Java interop
+- `fs/read-all-lines`, support charset
+- fs: `strip` and `split-ext` are less reliant on file system and are now just
+ string operations
+- Bump cheshire
+- Add `babashka.process/exec` for exec call (replacing the current process)
+- Improve `babashka.process/tokenize`
+- [#1264](https://github.com/babashka/babashka/issues/1264): add support for calling `ScheduledExecutorService`
+- Add support for `sun.misc.SignalHandler`
+- Add `java.net.BindException`, `clojure.lang.AFunction`, `AbstractMethodError`
+- Upgrade httpkit to `2.6.0-RC1`
+- Add `process/shell`, similar to `babashka.tasks/shell` but in process ns
+- pods: fix benign socket closed exception error output
+
+## 0.8.2 (2022-05-06)
+
+- Convey `*print-length*` to pprint and allow `set!`
+- `babashka.nrepl`: support pprint length
+- SCI: support invoking field, without dash
+- Add compatibility with clojure numeric tower
+- Update deps.clj to tools jar `1.11.1.1113`
+- Compatibility with fipp and puget
+- Fix [#1233](https://github.com/babashka/babashka/issues/1233): don't print error to stdout in prepl
+- Update process with `:pre-start-fn` option
+- Update fs with `cwd` and Windows glob improvements
+- Expose edamame, fixes [#549](https://github.com/babashka/babashka/issues/549) and [#1258](https://github.com/babashka/babashka/issues/1258) (#1259)
+- Support `BABASBHKA_PODS_DIR` environment variable
+
+## 0.8.1 (2022-04-15)
+
+- Add `prepare` subcommand to download deps & pods and cache pod metadata
+- [#1041](https://github.com/babashka/babashka/issues/1041): Improve error message when regex literal in EDN config
+- [#1223](https://github.com/babashka/babashka/issues/1223): Ensure that var metadata (specifically `:name`) aligns with the var's symbol (which in turn ensures that `doc` will print the var's name)
+- [#556](https://github.com/babashka/babashka/issues/556) Add server-status to org.httpkit.server
+- [#1231](https://github.com/babashka/babashka/issues/1231): missing methods in `reify` should fall back to default interface methods
+- Fix destructuring in defrecord protocol impls
+- Support `*print-dup*`
+
+## 0.8.0 (2022-04-04)
+
+### New
+
+- [#863](https://github.com/babashka/babashka/issues/863): allow pods to be declared in `bb.edn` and load them when required. See [pod library docs](https://github.com/babashka/pods#in-a-babashka-project) and the entry in the [babashka book](https://book.babashka.org/#_pods_in_bb_edn) for details.
+
+### Enhanced
+
+- [#1216](https://github.com/babashka/babashka/issues/1216): support `core.async/alts!` using polyfill
+- [#1220](https://github.com/babashka/babashka/issues/1220): add reflection on java.util.concurrent.Future
+- [#1211](https://github.com/babashka/babashka/issues/1211): return exit code 130 on sigint
+- [#1224](https://github.com/babashka/babashka/issues/1224): add `proxy` support for `java.io.PipedInputStream` and `java.io.PipedOutputStream`. Add reflection for `java.utils.Scanner`.
+- [babashka.curl#43](https://github.com/babashka/babashka.curl/issues/43) fix: last set-cookie headers on a page overwrites the ones before
+- [#1216](https://github.com/babashka/babashka/issues/1216): fix `core.async` alts example with polyfill
+- SCI: support `let*` special form
+- Add compatibility with GraalVM 22.1
+- Bump timbre
+- Bump Clojure to 1.11.0
+- Pods: support Rosetta2 fallback
+- Process: fix for pprint
+- Fs: improvement for which: do not match on local paths
+- Proxy support for PipedInputStream and PipedOutputStream
+- Expose `java.util.Scanner` for interop
+- Bump Selmer
+- Add `->Eduction`
+- Add `*unchecked-math` for compatibility
+
## 0.7.8 (2022-03-13)
This release improves compatibility with several libraries: [loom](https://github.com/aysylu/loom), [hugsql.core](https://www.hugsql.org) and [specter](https://github.com/redplanetlabs/specter)!
@@ -12,12 +247,9 @@ This release improves compatibility with several libraries: [loom](https://githu
To use specter in babashka, use the following coordinates:
``` clojure
-{:deps {com.rpl/specter {:git/url "https://github.com/borkdude/specter"
- :git/sha "8ba809a2cd35d3b6f8c5287e6bd3b4e06e42f6dc"}}}
+{:deps {com.rpl/specter {:mvn/version "1.1.4"}}}
```
-Hopefully the compatibility commit can be upstreamed back into specter at some point.
-
- Add `clojure.data.priority-map` as built-in library - this makes babashka compatible with [aysylu/loom](https://github.com/aysylu/loom)
- Add part of `clojure.tools.reader.reader-types` to support [hugsql.core](https://www.hugsql.org)
- [#1204](https://github.com/babashka/babashka/issues/1204) add property `babashka.config` to reflect `bb.edn` location ([@mknoszlig](https://github.com/mknoszlig))
diff --git a/Dockerfile b/Dockerfile
index 8ffb784f..f9ad88b3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,10 +5,11 @@ RUN apt update
RUN apt install --no-install-recommends -yy build-essential zlib1g-dev
WORKDIR "/opt"
-ENV GRAALVM_VERSION="22.0.0.2"
+ENV GRAALVM_VERSION="22.3.0"
ARG TARGETARCH
-ENV BABASHKA_ARCH=${TARGETARCH}
-ENV GRAALVM_ARCH=${TARGETARCH}
+# Do not set those directly, use TARGETARCH instead
+ENV BABASHKA_ARCH=
+ENV GRAALVM_ARCH=
RUN if [ "${TARGETARCH}" = "" ] || [ "${TARGETARCH}" = "amd64" ]; then \
export GRAALVM_ARCH=amd64; export BABASHKA_ARCH=x86_64; \
elif [ "${TARGETARCH}" = "arm64" ]; then \
@@ -34,7 +35,7 @@ ARG BABASHKA_FEATURE_CSV=
ARG BABASHKA_FEATURE_JAVA_NET_HTTP=
ARG BABASHKA_FEATURE_JAVA_NIO=
ARG BABASHKA_FEATURE_JAVA_TIME=
-ARG BABAHSKA_FEATURE_TRANSIT=
+ARG BABASHKA_FEATURE_TRANSIT=
ARG BABASHKA_FEATURE_XML=
ARG BABASHKA_FEATURE_YAML=
ARG BABASHKA_FEATURE_HTTPKIT_CLIENT=
@@ -51,7 +52,7 @@ ENV BABASHKA_FEATURE_CSV=$BABASHKA_FEATURE_CSV
ENV BABASHKA_FEATURE_JAVA_NET_HTTP=$BABASHKA_FEATURE_JAVA_NET_HTTP
ENV BABASHKA_FEATURE_JAVA_NIO=$BABASHKA_FEATURE_JAVA_NIO
ENV BABASHKA_FEATURE_JAVA_TIME=$BABASHKA_FEATURE_JAVA_TIME
-ENV BABAHSKA_FEATURE_TRANSIT=$BABAHSKA_FEATURE_TRANSIT
+ENV BABASHKA_FEATURE_TRANSIT=$BABASHKA_FEATURE_TRANSIT
ENV BABASHKA_FEATURE_XML=$BABASHKA_FEATURE_XML
ENV BABASHKA_FEATURE_YAML=$BABASHKA_FEATURE_YAML
ENV BABASHKA_FEATURE_HTTPKIT_CLIENT=$BABASHKA_FEATURE_HTTPKIT_CLIENT
diff --git a/Dockerfile.alpine b/Dockerfile.alpine
index 091f6654..f1b10a07 100644
--- a/Dockerfile.alpine
+++ b/Dockerfile.alpine
@@ -4,9 +4,11 @@ COPY bb /bin/bb
RUN chmod +x /bin/bb
+# TODO: See https://github.com/sgerrand/alpine-pkg-glibc/issues/185 and remove the `--force-overwrite`s when resolved.
+
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
- apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
+ apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
# TODO: Run actual native tests when they are ported
@@ -21,7 +23,7 @@ FROM alpine:3
RUN apk --no-cache add curl ca-certificates tar && \
curl -Ls https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk > /tmp/glibc-2.28-r0.apk && \
- apk add --allow-untrusted /tmp/glibc-2.28-r0.apk
+ apk add --allow-untrusted --force-overwrite /tmp/glibc-2.28-r0.apk
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
COPY metabom.jar /opt/babashka-metabom.jar
diff --git a/README.md b/README.md
index ec2444a2..75a23601 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-
+[
](https://babashka.org)
[](https://circleci.com/gh/babashka/babashka/tree/master)
[](https://app.slack.com/client/T03RZGPFR/CLX41ASCS)
@@ -12,12 +12,6 @@
@laheadle on Clojurians Slack
-
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
+ +There's a link here.
+ +// Detect horizontal line block
+function isHorizontalLineBlock(block) {
+ return block === "***";
+}
+
+// Render horizontal line block
+function horizontalLineBlock(block) {
+ return `<hr>`;
+}
+
+// Compose an array of parsers
+const parsers = [{
+ matcher: isHorizontalLineBlock,
+ renderers: [horizontalLineBlock]
+}];
+
+// And finally, our parser itself
+function markdownToHTML(markdown) {
+ // Create blocks
+ const blocks = content.split(/\n\n/);
+
+ // Parse blocks
+ const parsedBlocks = blocks.map((block) => {
+ // Let's find a parser that has a matcher that matches
+ const parser = parsers.find((parser) => parser.matcher(block));
+
+ // If match was found, let's run our renderers over `block`
+ if (parser) {
+ for (const renderer of match.renderers) {
+ block = renderer(block);
+ }
+ }
+
+ return block;
+ });
+
+ // And at last, join the blocks together for one big block.
+ return parsedBlocks.join("");
+}
+
+This is bold italic text and this is also. What about italic text that has bold text?
+ +Testing paragraph right before a code block
+ +code goes here
+
+Paragraph right after heading
diff --git a/test-resources/lib_tests/clarktown/core_test.clj b/test-resources/lib_tests/clarktown/core_test.clj new file mode 100644 index 00000000..86ca1765 --- /dev/null +++ b/test-resources/lib_tests/clarktown/core_test.clj @@ -0,0 +1,15 @@ +(ns clarktown.core-test + (:require + ;; BB-TEST-PATCH: require clojure.string for split-lines patch below + [clojure.string :as str] + [clojure.test :refer [deftest testing is]] + [clojure.java.io :as io] + [clarktown.core :as core])) + + +(deftest overall-test + (testing "Overall" + ;; BB-TEST-PATCH: library uses hard-coded \n, so using split-lines for platform-agnostic testing + ;; BB-TEST-PATCH: change file paths to match bb folder structure (and copy resource files) + (is (= (str/split-lines (core/render (slurp (io/file (io/resource "clarktown/core.md"))))) + (str/split-lines (slurp (io/file (io/resource "clarktown/core_result.html")))))))) diff --git a/test-resources/lib_tests/clarktown/parsers/bold_test.clj b/test-resources/lib_tests/clarktown/parsers/bold_test.clj new file mode 100644 index 00000000..a082d418 --- /dev/null +++ b/test-resources/lib_tests/clarktown/parsers/bold_test.clj @@ -0,0 +1,18 @@ +(ns clarktown.parsers.bold-test + (:require + [clojure.test :refer [deftest testing is]] + [clarktown.parsers.bold :as bold])) + + +(deftest bold-test + (testing "Creating bold text with two surrounding asterisk characters" + (is (= "This is bold." + (bold/render "**This is bold.**" nil)))) + + (testing "Creating bold text with two surrounding underscore characters" + (is (= "This is bold." + (bold/render "__This is bold.__" nil)))) + + (testing "Creating bold text with both underscores and asterisks mixed" + (is (= "Hi, my name is John, what is your name?" + (bold/render "Hi, my name is **John**, what is __your name?__" nil))))) \ No newline at end of file diff --git a/test-resources/lib_tests/clarktown/parsers/code_block.md b/test-resources/lib_tests/clarktown/parsers/code_block.md new file mode 100644 index 00000000..8e6f863f --- /dev/null +++ b/test-resources/lib_tests/clarktown/parsers/code_block.md @@ -0,0 +1,41 @@ +```javascript +// Detect horizontal line block +function isHorizontalLineBlock(block) { + return block === "***"; +} + +// Render horizontal line block +function horizontalLineBlock(block) { + return `// Detect horizontal line block
+function isHorizontalLineBlock(block) {
+ return block === "***";
+}
+
+// Render horizontal line block
+function horizontalLineBlock(block) {
+ return `<hr>`;
+}
+
+// Compose an array of parsers
+const parsers = [{
+ matcher: isHorizontalLineBlock,
+ renderers: [horizontalLineBlock]
+}];
+
+// And finally, our parser itself
+function markdownToHTML(markdown) {
+ // Create blocks
+ const blocks = content.split(/\n\n/);
+
+ // Parse blocks
+ const parsedBlocks = blocks.map((block) => {
+ // Let's find a parser that has a matcher that matches
+ const parser = parsers.find((parser) => parser.matcher(block));
+
+ // If match was found, let's run our renderers over `block`
+ if (parser) {
+ for (const renderer of match.renderers) {
+ block = renderer(block);
+ }
+ }
+
+ return block;
+ });
+
+ // And at last, join the blocks together for one big block.
+ return parsedBlocks.join("");
+}
\ No newline at end of file
diff --git a/test-resources/lib_tests/clarktown/parsers/code_block_result.html b/test-resources/lib_tests/clarktown/parsers/code_block_result.html
new file mode 100644
index 00000000..21b92144
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/code_block_result.html
@@ -0,0 +1,39 @@
+// Detect horizontal line block
+function isHorizontalLineBlock(block) {
+ return block === "***";
+}
+
+// Render horizontal line block
+function horizontalLineBlock(block) {
+ return `<hr>`;
+}
+
+// Compose an array of parsers
+const parsers = [{
+ matcher: isHorizontalLineBlock,
+ renderers: [horizontalLineBlock]
+}];
+
+// And finally, our parser itself
+function markdownToHTML(markdown) {
+ // Create blocks
+ const blocks = content.split(/\n\n/);
+
+ // Parse blocks
+ const parsedBlocks = blocks.map((block) => {
+ // Let's find a parser that has a matcher that matches
+ const parser = parsers.find((parser) => parser.matcher(block));
+
+ // If match was found, let's run our renderers over `block`
+ if (parser) {
+ for (const renderer of match.renderers) {
+ block = renderer(block);
+ }
+ }
+
+ return block;
+ });
+
+ // And at last, join the blocks together for one big block.
+ return parsedBlocks.join("");
+}
\ No newline at end of file
diff --git a/test-resources/lib_tests/clarktown/parsers/code_block_test.clj b/test-resources/lib_tests/clarktown/parsers/code_block_test.clj
new file mode 100644
index 00000000..b965e5fa
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/code_block_test.clj
@@ -0,0 +1,18 @@
+(ns clarktown.parsers.code-block-test
+ (:require
+ ;; require clojure.string to accomodate line break hack below
+ [clojure.string :as str]
+ [clojure.test :refer [deftest testing is]]
+ [clojure.java.io :as io]
+ [clarktown.parsers.code-block :as code-block]))
+
+;; BB-TEST-PATCH: change paths to match folder structure (and copy resource files)
+;; BB-TEST-PATCH: use split-lines to make tests platform-agnostic
+(deftest code-block-test
+ (testing "Code block with language specification"
+ (is (= (str/split-lines (slurp (io/file (io/resource "clarktown/parsers/code_block_result.html"))))
+ (str/split-lines (code-block/render (slurp (io/file (io/resource "clarktown/parsers/code_block.md"))) nil)))))
+
+ (testing "Code block with NO language specification"
+ (is (= (str/split-lines (slurp (io/file (io/resource "clarktown/parsers/code_block_no_language_result.html"))))
+ (str/split-lines (code-block/render (slurp (io/file (io/resource "clarktown/parsers/code_block_no_language.md"))) nil))))))
diff --git a/test-resources/lib_tests/clarktown/parsers/empty_block_test.clj b/test-resources/lib_tests/clarktown/parsers/empty_block_test.clj
new file mode 100644
index 00000000..a8d89c48
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/empty_block_test.clj
@@ -0,0 +1,14 @@
+(ns clarktown.parsers.empty-block-test
+ (:require
+ [clojure.test :refer [deftest testing is]]
+ [clarktown.parsers.empty-block :as empty-block]))
+
+
+(deftest empty-block-test
+ (testing "Rendering an empty block"
+ (is (= (empty-block/render "" nil)
+ "")))
+
+ (testing "Checking an empty block"
+ (is (true? (empty-block/is? "")))
+ (is (true? (empty-block/is? " ")))))
diff --git a/test-resources/lib_tests/clarktown/parsers/heading_block_test.clj b/test-resources/lib_tests/clarktown/parsers/heading_block_test.clj
new file mode 100644
index 00000000..9bfff4fd
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/heading_block_test.clj
@@ -0,0 +1,44 @@
+(ns clarktown.parsers.heading-block-test
+ (:require
+ [clojure.test :refer [deftest testing is]]
+ [clarktown.parsers.heading-block :as heading-block]))
+
+
+(deftest hashbang-heading-test
+ (testing "Hashbang heading block that's a H1"
+ (is (= "This is inline code."
+ (inline-code/render "`This is inline code.`" nil))))
+
+ (testing "Creating inline-code text in the middle of regular text"
+ (is (= "This is regular text, mixed with some inline code., and it's great."
+ (inline-code/render "This is regular text, mixed with `some inline code.`, and it's great." nil)))))
\ No newline at end of file
diff --git a/test-resources/lib_tests/clarktown/parsers/italic_test.clj b/test-resources/lib_tests/clarktown/parsers/italic_test.clj
new file mode 100644
index 00000000..8ab13698
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/italic_test.clj
@@ -0,0 +1,18 @@
+(ns clarktown.parsers.italic-test
+ (:require
+ [clojure.test :refer [deftest testing is]]
+ [clarktown.parsers.italic :as italic]))
+
+
+(deftest italic-test
+ (testing "Creating italic text with one surrounding asterisk character"
+ (is (= "This is italic."
+ (italic/render "*This is italic.*" nil))))
+
+ (testing "Creating italic text with one surrounding underscore character"
+ (is (= "This is italic."
+ (italic/render "_This is italic._" nil))))
+
+ (testing "Creating italic text with both underscores and asterisks mixed"
+ (is (= "Hi, my name is John, what is your name?"
+ (italic/render "Hi, my name is *John*, what is _your name?_" nil)))))
\ No newline at end of file
diff --git a/test-resources/lib_tests/clarktown/parsers/link_and_image_test.clj b/test-resources/lib_tests/clarktown/parsers/link_and_image_test.clj
new file mode 100644
index 00000000..348a8f90
--- /dev/null
+++ b/test-resources/lib_tests/clarktown/parsers/link_and_image_test.clj
@@ -0,0 +1,23 @@
+(ns clarktown.parsers.link-and-image-test
+ (:require
+ [clojure.test :refer [deftest testing is]]
+ [clarktown.parsers.link-and-image :as link-and-image]))
+
+
+(deftest link-test
+ (testing "Creating a link"
+ (is (= (link-and-image/render "[This is a link](https://example.com)" nil)
+ "This is a link"))
+
+ (is (= (link-and-image/render "[This-is-a-link](https://example.com)" nil)
+ "This-is-a-link"))
+
+ (is (= (link-and-image/render "[x] [label](link)" nil)
+ "[x] label"))
+
+ (is (= (link-and-image/render "[ ] [label](link)" nil)
+ "[ ] label")))
+
+ (testing "Creating an image"
+ (is (= (link-and-image/render "" nil)
+ "First line\nsecond line"))) + + (testing "Checking a quote block" + (is (true? (quote-block/is? "> Test"))) + (is (true? (quote-block/is? " > Test"))) + (is (true? (quote-block/is? ">"))))) \ No newline at end of file diff --git a/test-resources/lib_tests/clarktown/parsers/strikethrough_test.clj b/test-resources/lib_tests/clarktown/parsers/strikethrough_test.clj new file mode 100644 index 00000000..fdf61888 --- /dev/null +++ b/test-resources/lib_tests/clarktown/parsers/strikethrough_test.clj @@ -0,0 +1,14 @@ +(ns clarktown.parsers.strikethrough-test + (:require + [clojure.test :refer [deftest testing is]] + [clarktown.parsers.strikethrough :as strikethrough])) + + +(deftest strikethrough-test + (testing "Creating strikethrough text" + (is (= (strikethrough/render "~~This is strikethrough text.~~" nil) + "
Test
\"\n" + (test-utils/bb nil "-m" "pod-tests.bootleg")))))) + +(deftest ^:skip-windows local-pod-test + (test-utils/with-config + (pr-str '{:paths ["test-resources"] + :pods {pod/test-pod {:path "test-resources/pod"}}}) + (is (= "42\n" (test-utils/bb nil "-m" "pod-tests.local"))))) + +(deftest tag-test + (test-utils/with-config + "{:deps {} + :aliases {:foo {:env-vars {:dude #env \"DUDE\"}}}}" + (is (= 6 (bb "-e" "(+ 1 2 3)"))))) + +(deftest merge-deps-test + (test-utils/with-config + "{:deps {}}" + (is (= {1 {:a 1}} + (bb "-Sdeps" "{:deps {medley/medley {:mvn/version \"1.4.0\"}}}" "-e" "(require 'medley.core) (medley.core/index-by :a [{:a 1}])"))))) diff --git a/test/babashka/classes_test.clj b/test/babashka/classes_test.clj new file mode 100644 index 00000000..31b7872e --- /dev/null +++ b/test/babashka/classes_test.clj @@ -0,0 +1,11 @@ +(ns babashka.classes-test + (:require [babashka.test-utils :as tu] + [clojure.edn :as edn] + [clojure.test :as t :refer [deftest is testing]])) + +(defn bb + [& args] + (edn/read-string (apply tu/bb nil (map pr-str args)))) + +(deftest all-classes-test + (is (true? (bb '(let [classes (babashka.classes/all-classes)] (and (seq classes) (every? class? classes))))))) diff --git a/test/babashka/crypto_test.clj b/test/babashka/crypto_test.clj index 08549691..48503f69 100644 --- a/test/babashka/crypto_test.clj +++ b/test/babashka/crypto_test.clj @@ -17,7 +17,10 @@ (deftest hmac-sha-256-test (let [key-s "some-key" data "some-data" - expected-sha (String. (hmac-sha-256 (.getBytes key-s) data))] + expected-sha (String. (.encode (java.util.Base64/getEncoder) + (hmac-sha-256 (.getBytes key-s) data)) + "utf-8")] + (prn expected-sha) (is (= expected-sha (bb '(do (ns net (:import (javax.crypto Mac) (javax.crypto.spec SecretKeySpec))) @@ -28,4 +31,6 @@ (.doFinal mac (.getBytes data "UTF-8")))) (let [key-s "some-key" data "some-data"] - (String. (hmac-sha-256 (.getBytes key-s) data))))))))) + (String. (.encode (java.util.Base64/getEncoder) + (hmac-sha-256 (.getBytes key-s) data)) + "utf-8")))))))) diff --git a/test/babashka/deps_test.clj b/test/babashka/deps_test.clj index 397a01f9..e130e680 100644 --- a/test/babashka/deps_test.clj +++ b/test/babashka/deps_test.clj @@ -35,6 +35,7 @@ (bb (pr-str `(do (babashka.deps/add-deps '{:deps {babashka/process {:git/url "https://github.com/babashka/process" :sha "4c6699d06b49773d3e5c5b4c11d3334fb78cc996"}}} {:force true :env {"PATH" (System/getenv "PATH") + "JAVA_HOME" (System/getenv "JAVA_HOME") "GITLIBS" ~(str libs-dir)}}) nil))) (bb (pr-str `(do (babashka.deps/add-deps '{:deps {babashka/process {:git/url "https://github.com/babashka/process" :sha "4c6699d06b49773d3e5c5b4c11d3334fb78cc996"}}} {:force true @@ -65,6 +66,14 @@ true (-> (babashka.deps/clojure [\"-M\" \"-e\" \"(+ 1 2 3)\"] {:out :string}) (p/check) :out) +")))) + (is (= "6\n" (test-utils/normalize (bb " +(require '[babashka.deps :as deps]) +(require '[babashka.process :as p]) + +(-> (babashka.deps/clojure {:out :string} \"-M\" \"-e\" \"(+ 1 2 3)\") + (p/check) + :out) ")))) (when-not test-utils/native? (is (thrown-with-msg? Exception #"Option changed" (bb " @@ -86,6 +95,7 @@ true libs-dir2 (fs/file tmp-dir ".gitlibs2") template (pr-str '(do (babashka.deps/clojure ["-Sforce" "-Spath" "-Sdeps" "{:deps {babashka/process {:git/url \"https://github.com/babashka/process\" :sha \"4c6699d06b49773d3e5c5b4c11d3334fb78cc996\"}}}"] {:out :string :env-key {"PATH" (System/getenv "PATH") + "JAVA_HOME" (System/getenv "JAVA_HOME") "GITLIBS" :gitlibs}}) nil))] (bb (-> template (str/replace ":gitlibs" (pr-str (str libs-dir))) (str/replace ":env-key" ":env"))) diff --git a/test/babashka/error_test.clj b/test/babashka/error_test.clj index fba11c14..e82a7175 100644 --- a/test/babashka/error_test.clj +++ b/test/babashka/error_test.clj @@ -1,24 +1,29 @@ (ns babashka.error-test + {:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [match?]}}}} (:require [babashka.test-utils :as tu] [clojure.java.io :as io] [clojure.string :as str] - [clojure.test :as t :refer [deftest is testing]])) + [clojure.test :as t :refer [deftest is testing]] + [matcher-combinators.test])) -(defn multiline-equals [s1 s2] - (let [lines-s1 (str/split-lines s1) - lines-s2 (str/split-lines s2) - max-lines (max (count lines-s1) (count lines-s2))] - (run! (fn [i] - (let [l1 (get lines-s1 i) - l2 (get lines-s2 i)] - (if (and l1 l2) - (is (= l1 l2) - (format "Lines did not match.\nLine: %s\nLeft: %s\nRight: %s" - i (pr-str l1) (pr-str l2))) - (is false (format "Out of lines at line: %s.\nLeft: %s\nRight: %s" - i (pr-str l1) (pr-str l2)))))) - (range max-lines)))) +(defmacro multiline-equals [s1 s2] + `(let [lines-s1# (str/split-lines ~s1) + lines-s2# (str/split-lines ~s2) + max-lines# (max (count lines-s1#) (count lines-s2#)) + lines-s1# (take max-lines# lines-s1#) + lines-s2# (take max-lines# lines-s2#)] + (is (~'match? (map str/trimr lines-s1#) (map str/trimr lines-s2#))) + #_(run! (fn [i] + (let [l1 (get lines-s1 i) + l2 (get lines-s2 i)] + (if (and l1 l2) + (is (= l1 l2) + (format "Lines did not match.\nLine: %s\nLeft: %s\nRight: %s" + i (pr-str l1) (pr-str l2))) + (is false (format "Out of lines at line: %s.\nLeft: %s\nRight: %s" + i (pr-str l1) (pr-str l2)))))) + (range max-lines)))) (deftest stacktrace-from-script-test (try (tu/bb nil (.getPath (io/file "test" "babashka" "scripts" "divide_by_zero.bb"))) @@ -122,7 +127,7 @@ Phase: macroexpand ----- Context ------------------------------------------------------------------ 1: (defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1) - ^--- + ^--- ----- Stack trace -------------------------------------------------------------- clojure.core/subs -