Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate release cycle #13

Merged
merged 7 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 136 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,155 @@
version: 2.1

orbs:
github-cli: circleci/github-cli@1.0
tools: replikativ/clj-tools@0

jobs:
setup:
executor: tools/clojurecli
parameters:
setup_cljs:
type: boolean
default: false
steps:
- restore_cache:
keys:
- source-{{ .Branch }}-{{ .Revision }}
- source-{{ .Branch }}
- source-
- checkout
- save_cache:
key: source-{{ .Branch }}-{{ .Revision }}
paths:
- .git
- restore_cache:
keys:
- deps-{{ checksum "deps.edn" }}
- deps-
- run:
name: resolve deps
command: clojure -P
- save_cache:
key: deps-{{ checksum "deps.edn" }}
paths:
- /home/circleci/.m2
- when:
condition: <<parameters.setup_cljs>>
steps:
- restore_cache:
keys:
- npm-{{ checksum "package-lock.json" }}
- npm-
- run: npm ci
- save_cache:
key: npm-{{ checksum "package-lock.json" }}
paths:
- /home/circleci/.npm
- persist_to_workspace:
root: /home/circleci/
paths:
- .m2
- .npm
- replikativ
build:
executor: tools/clojurecli
parameters:
build_cljs:
type: boolean
default: false
steps:
- attach_workspace:
at: /home/circleci
- run:
name: clean
command: clojure -Sthreads 1 -T:build clean
- run:
name: jar
command: clojure -Sthreads 1 -T:build jar
- when:
condition: <<parameters.build_cljs>>
steps:
- run:
name: compile_cljs
command: npx shadow-cljs compile ci
no_output_timeout: 5m
- persist_to_workspace:
root: /home/circleci/
paths:
- .m2
- replikativ

test:
executor: tools/clojurecli
parameters:
test_cljs:
type: boolean
default: false
steps:
- attach_workspace:
at: /home/circleci
- run:
name: test
command: clojure -Sthreads 1 -T:build test
no_output_timeout: 5m
- when:
condition: <<parameters.test_cljs>>
steps:
- run:
name: karma_test
command: ./bin/run-cljstests
no_output_timeout: 5m
deploy:
executor: tools/clojurecli
steps:
- attach_workspace:
at: /home/circleci
- run:
name: deploy
command: clojure -Sthreads 1 -T:build deploy
release:
executor: tools/clojurecli
steps:
- attach_workspace:
at: /home/circleci
- run:
name: deploy
command: clojure -Sthreads 1 -T:build release


workflows:
build-test-and-deploy:
jobs:
- tools/setup
- tools/format:
requires:
- tools/setup
- tools/unittest:
- setup:
context: clojars-deploy
setup_cljs: true
- build:
context: clojars-deploy
build_cljs: true
requires:
- tools/setup
- tools/cljstest:
- setup
- tools/format:
context: clojars-deploy
requires:
- tools/setup
- tools/build:
jarname: "incognito"
- setup
- test:
context: clojars-deploy
test_cljs: true
requires:
- tools/setup
- tools/deploy-snapshot:
jarname: "incognito"
- build
- deploy:
context: clojars-deploy
filters:
branches:
only: development
only: main
requires:
- tools/setup
- tools/format
- tools/unittest
- tools/cljstest
- tools/build
- tools/deploy-release:
jarname: "incognito"
context: clojars-deploy
- test
- release:
context:
- github-token
filters:
branches:
only: master
only: main
requires:
- tools/setup
- tools/format
- tools/unittest
- tools/cljstest
- tools/build
- deploy
59 changes: 59 additions & 0 deletions build.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(ns build
(:refer-clojure :exclude [test])
(:require [clojure.tools.build.api :as b]
[borkdude.gh-release-artifact :as gh]
[org.corfield.build :as bb]))

(def lib 'io.replikativ/incognito)
(def version (format "0.3.%s" (b/git-count-revs nil)))
(def class-dir "target/classes")
(def basis (b/create-basis {:project "deps.edn"}))
(def jar-file (format "target/%s-%s.jar" (name lib) version))

(defn clean
[_]
(b/delete {:path "target"}))

(defn jar
[opts]
(-> opts
(assoc :class-dir class-dir
:src-pom "./template/pom.xml"
:lib lib
:version version
:basis basis
:jar-file jar-file
:src-dirs ["src"])
bb/jar))

(defn test "Run the tests." [opts]
(bb/run-tests opts))

(defn ci "Run the CI pipeline of tests (and build the JAR)." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/run-tests)
(bb/clean)
(bb/jar)))

(defn install "Install the JAR locally." [opts]
(-> opts
jar
bb/install))

(defn deploy "Deploy the JAR to Clojars." [opts]
(-> opts
(assoc :lib lib :version version)
(bb/deploy)))

(defn release
[_]
(-> (gh/overwrite-asset {:org "replikativ"
:repo (name lib)
:tag version
:commit (gh/current-commit)
:file jar-file
:content-type "application/java-archive"})
:url
println))

45 changes: 27 additions & 18 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/clojurescript {:mvn/version "1.10.764"}
org.clojure/data.fressian {:mvn/version "0.2.1"}
com.cognitect/transit-clj {:mvn/version "0.8.319"}
com.cognitect/transit-cljs {:mvn/version "0.8.256"}
fress/fress {:mvn/version "0.3.2"}}
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.10.21"}
binaryage/devtools {:mvn/version "1.0.2"}}
:extra-paths ["test"]}
:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.641"}}
:extra-paths ["test"]}
:jar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.116"}}
:main-opts ["-m" "hf.depstar.jar" "replikativ-incognito.jar"]}
:deploy {:extra-deps {slipset/deps-deploy {:mvn/version "0.1.0"}}
:main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "replikativ-incognito.jar"]}
:format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.7.0"}}
:main-opts ["-m" "cljfmt.main" "check"]}}}
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
org.clojure/clojurescript {:mvn/version "1.11.4"}
org.clojure/data.fressian {:mvn/version "1.0.0"}
com.cognitect/transit-clj {:mvn/version "1.0.329"}
com.cognitect/transit-cljs {:mvn/version "0.8.269"}
fress/fress {:mvn/version "0.3.3"}
org.clojure/tools.cli {:mvn/version "1.0.206"}}
:aliases {:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.17.0"}
binaryage/devtools {:mvn/version "1.0.4"}}
:extra-paths ["test"]}
:test {:extra-deps {lambdaisland/kaocha {:mvn/version "1.62.993"}
io.github.cognitect-labs/test-runner {:git/tag "v0.5.0"
:git/sha "48c3c67"}}
:extra-paths ["test"]}
:build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.6.7"
:git/sha "22c2d09"}
borkdude/gh-release-artifact {:git/url "https://github.com/borkdude/gh-release-artifact"
:sha "a83ee8da47d56a80b6380cbb6b4b9274048067bd"}
babashka/babashka.curl {:mvn/version "0.1.1"}
babashka/fs {:mvn/version "0.1.2"}
cheshire/cheshire {:mvn/version "5.10.2"}}
:ns-default build}
:format {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}
:main-opts ["-m" "cljfmt.main" "check"]}
:ffix {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}
:main-opts ["-m" "cljfmt.main" "fix"]}}}
Loading