Clojure
Clojure is JVM based dynamic, general-purpose programming language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.
This guide provides a walkthrough of .razorops.yaml
for a typical Clojure-based application based.
Example project¶
See the Example Project on GitHub for a demonstration and use the full configuration file as a template for your own projects.
The pipeline performs the following tasks:
- Downloads the dependencies using
lein
and cache them - Builds the artifact (uberjar)
- Executes the unit tests
Choosing Clojure version¶
You can choose the Java compiler version based on the build environment. Common build tools like leiningen
, maven
, sbt
, ant
and gradle
are pre-installed in the environment. The version of Clojure will be inferred from the contents of project.clj
file via Leiningen.
For Docker environment, Razorops provides convenience container images for various programming languages. You can use an appropriate image tag to control Java compiler version.
global:
runner: razorci/openjdk:11-buster
...
tasks:
build-deps:
runner: razorci/openjdk:11-buster
...
You can additionally provide environment variables and provide service dependencies to run your test suite.
For Linux-VM environment, we infer the Clojure version from project.clj
at the root of the your repository.
Downloading dependencies¶
Downloading third-party packages/dependencies from the internet can be time-consuming, you can greatly speed up this process by caching it using an unique key. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote (Sbt, Gradle etc) repositories. For more information, see Caching dependencies.
- cache/pull: lein-{{ checksum "project.clj" }}
...
- cache/push:
key: lein-{{ checksum "project.clj" }}
paths:
- ~/.m2
- ~/.lein
Executing tests¶
You can use the same commands that you use locally to test your code and generate JUnit reports to tell how much of your application is tested.
steps:
...
- name: Run unit test
run: lein test
Managing artifacts¶
You can compile and build the jars just like you do locally and optionally upload to our artifact storage to use them after the workflow completes. For more information, see "Persisting workflow data using artifacts.".
steps:
...
- commands:
- lein uberjar
...
- artifacts/push:
name: demo-x.x.x.jar
paths: [target/uberjar/clojure-guestbook-demo.jar] # replace x with right jar name