Skip to content

Commit afed6d5

Browse files
committed
Maintenance pass
Highlights: - now release to org.cljdoc/cljdoc-exerciser (formerly lread/cljdoc-exerciser) - release now handled by GitHub Actions (tweaks may be necessary) - moved to babashka tasks - moved to clojure tools build - added bb task to for cljdoc preview
1 parent c6910df commit afed6d5

24 files changed

+670
-135
lines changed

.clj-kondo/babashka/fs/config.edn

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:lint-as {babashka.fs/with-temp-dir clojure.core/let}}

.clj-kondo/config.edn

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{:config-paths ^:replace ["lread/status-line"]
2+
:linters {:unsorted-required-namespaces {:level :warning}}}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{:lint-as {lread.status-line/line clojure.tools.logging/infof
2+
lread.status-line/die clojure.tools.logging/infof}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{:lint-as
2+
{rewrite-clj.zip/subedit-> clojure.core/->
3+
rewrite-clj.zip/subedit->> clojure.core/->>
4+
rewrite-clj.zip/edit-> clojure.core/->
5+
rewrite-clj.zip/edit->> clojure.core/->>}}

.github/workflows/release.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'latest'
6+
7+
jobs:
8+
release:
9+
environment: 'release'
10+
11+
runs-on: 'ubuntu-latest'
12+
13+
steps:
14+
- name: Checkout - with tag support
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup git user - so that we can later tag
20+
uses: fregante/[email protected]
21+
22+
- name: Clojure deps cache
23+
uses: actions/cache@v2
24+
with:
25+
path: |
26+
~/.m2/repository
27+
~/.gitlibs
28+
key: $${ runner.os }}-cljdeps-release-${{ hashFiles('deps.edn') }}
29+
restore-keys: $${ runner.os }}-cljdeps-release-
30+
31+
- name: Setup Java
32+
uses: actions/setup-java@v2
33+
with:
34+
distribution: 'temurin'
35+
java-version: '11'
36+
37+
- name: Install Babashka
38+
run: curl -s https://raw.githubusercontent.com/borkdude/babashka/master/install | sudo bash
39+
40+
- name: Install Clojure
41+
run: curl -s https://download.clojure.org/install/linux-install-1.10.3.1075.sh | sudo bash
42+
43+
- name: Tools Versions
44+
run: |
45+
echo "bb --version"
46+
bb --version
47+
echo "node --version"
48+
node --version
49+
echo "java -version"
50+
java -version
51+
echo "clojure -Sdescribe"
52+
clojure -Sdescribe
53+
54+
- name: Jar
55+
run: bb jar
56+
57+
- name: Add Version Tag
58+
run: bb -ci-version
59+
60+
- name: Deploy
61+
env:
62+
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }}
63+
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }}
64+
run: bb -ci-deploy

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
/.cpcache
3-
/target
3+
/target
4+
/.lsp
5+
/.clj-kondo/.cache

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# cljdoc-exerciser
22

3-
[![cljdoc badge](https://cljdoc.org/badge/lread/cljdoc-exerciser)](https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT)
3+
[![cljdoc badge](https://cljdoc.org/badge/org.cljdoc/cljdoc-exerciser)](https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT)
44

55
This is a test project to exercise various cljdoc features and formatting.
66

77
It should be extended as the cljdoc community sees fit.
88

99
## Building & Releasing
1010

11-
| Run | To |
12-
| :------------------- | :----------------------------------------------------- |
13-
| [script/install](script/install) | install to local maven repository, for testing |
14-
| [script/update-pom](script/update-pom) | update pom to reflect current version and scm revision |
15-
| [script/release](script/release) | build and deploy to clojars |
11+
This project uses babashka tasks.
1612

17-
Version scheme is defined in [script/generate-version](script/generate-version)
13+
To see available tasks, run:
14+
```
15+
bb tasks
16+
```
17+
18+
Version scheme is `<major>.<minor>.<commit count>`.
19+
20+
Current release is also tagged with `latest`.

bb.edn

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{:paths ["script"]
2+
:deps {lread/status-line {:git/url "https://github.com/lread/status-line.git"
3+
:sha "35ed39645038e81b42cb15ed6753b8462e60a06d"}
4+
dev.nubank/docopt {:mvn/version "0.6.1-fix7"}
5+
version-clj/version-clj {:mvn/version "2.0.2"}}
6+
:tasks {;; setup
7+
:requires ([babashka.fs :as fs]
8+
[clojure.string :as string]
9+
[helper.shell :as shell]
10+
[lread.status-line :as status])
11+
:enter (let [{:keys [name accepts-args?]} (current-task)]
12+
(when-not (string/starts-with? name "-")
13+
(status/line :head "TASK %s %s" name (string/join " " *command-line-args*))))
14+
:leave (let [{:keys [name]} (current-task)]
15+
(when-not (string/starts-with? name "-")
16+
(status/line :detail "\nTASK %s done." name)))
17+
18+
;; commands
19+
clean {:doc "Delete any build work"
20+
:task (when (fs/exists? "target")
21+
(fs/delete-tree "target"))}
22+
23+
cljdoc-preview {:doc "Preview what docs will look like on cljdoc, use --help for args"
24+
:task cljdoc-preview/-main}
25+
26+
jar {:doc "Create jar"
27+
:task (shell/command "clojure -T:build jar")}
28+
29+
release {:doc "Tell CI to release to clojars"
30+
:task release/-main}
31+
32+
outdated {:doc "Check for outdated dependencies"
33+
:task (shell/command {:continue true} "clojure -M:outdated")}
34+
35+
-ci-version {:doc "Called by GitHub Action"
36+
:task (shell/command "clojure -T:build ci-version-tag")}
37+
38+
-ci-deploy {:doc "Called by GitHub Action"
39+
:task (shell/command "clojure -T:build ci-deploy")}}}

build.clj

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
(ns build
2+
(:require [clojure.edn :as edn]
3+
[clojure.java.io :as io]
4+
[clojure.tools.build.api :as b]
5+
[deps-deploy.deps-deploy :as dd]))
6+
7+
(def lib 'org.cljdoc/cljdoc-exerciser)
8+
(def version (let [version-template (-> "version.edn" slurp edn/read-string)
9+
patch (b/git-count-revs nil)]
10+
(str (:major version-template) "."
11+
(:minor version-template) "."
12+
patch
13+
(when (:qualifier version-template) (str "-")))))
14+
(def class-dir "target/classes")
15+
(def basis (b/create-basis {:project "deps.edn"}))
16+
(def jar-file (format "target/%s.jar" (name lib)))
17+
(def built-jar-version-file "target/built-jar-version.txt")
18+
19+
(defn jar
20+
"Build library jar file.
21+
We use the optional :version-suffix to distinguish local installs from production releases.
22+
For example, when preview for cljdoc, we use the suffix: cjdoc-preview."
23+
[{:keys [version-suffix]}]
24+
(b/delete {:path class-dir})
25+
(b/delete {:path jar-file})
26+
(let [version (if version-suffix (format "%s-%s" version version-suffix)
27+
version)]
28+
(b/write-pom {:class-dir class-dir
29+
:lib lib
30+
:version version
31+
:scm {:tag (format "v%s" version)}
32+
:basis basis
33+
:src-dirs ["src"]})
34+
(b/copy-dir {:src-dirs ["src" "resources"]
35+
:target-dir class-dir})
36+
(b/jar {:class-dir class-dir
37+
:jar-file jar-file})
38+
(spit built-jar-version-file version)))
39+
40+
(defn- built-version* []
41+
(when (not (.exists (io/file built-jar-version-file)))
42+
(throw (ex-info (str "Built jar version file not found: " built-jar-version-file) {})))
43+
(slurp built-jar-version-file))
44+
45+
(defn built-version
46+
;; NOTE: Used by release script and github workflow
47+
"Spit out version of jar built (with no trailing newline).
48+
A separate task because I don't know what build.tools might spit to stdout."
49+
[_]
50+
(print (built-version*))
51+
(flush))
52+
53+
54+
(defn install
55+
"Install built jar to local maven repo"
56+
[_]
57+
(b/install {:class-dir class-dir
58+
:lib lib
59+
:version (built-version*)
60+
:basis basis
61+
:jar-file jar-file}))
62+
63+
(defn project-lib
64+
"Returns project groupid/artifactid"
65+
[_]
66+
(println lib))
67+
68+
;;
69+
;; GitHub Actions deploy support, called from action only
70+
;;
71+
72+
;; a request to release is done by tagging with "latest"
73+
(defn ci-release? []
74+
(and (= "tag" (System/getenv "GITHUB_REF_TYPE"))
75+
(= "latest" (System/getenv "GITHUB_REF_NAME"))))
76+
77+
(defn ci-deploy [_]
78+
(if (ci-release?)
79+
(do
80+
(println "Releasing to clojars...")
81+
(dd/deploy {:installer :remote
82+
:artifact jar-file
83+
:pom-file (b/pom-path {:lib lib :class-dir class-dir})}))
84+
(println "Not on CI service, skipping deploy")))
85+
86+
(defn ci-version-tag [_]
87+
(if (ci-release?)
88+
(let [tag-version (built-version*)]
89+
(b/git-process {:git-args (format "git tag -a %s -m Release %s" tag-version tag-version)})
90+
(b/git-process {:git-args (format "git push origin %s" tag-version)}))
91+
(println "Not on CI service, skipping version tagging")))

deps.edn

+9-21
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
{:paths ["src"]
2-
:deps {org.clojure/clojure {:mvn/version "1.10.1"}}
2+
:deps {org.clojure/clojure {:mvn/version "1.10.3"}}
33

44
:aliases
5-
{:jar
6-
{:extra-deps {seancorfield/depstar {:mvn/version "1.1.116"}}
7-
:main-opts ["-m" "hf.depstar.jar"]}
8-
9-
:update-pom
10-
{:extra-deps {com.workframe/garamond {:mvn/version "0.4.0"}}
11-
:main-opts ["-m" "garamond.main" "--pom" "--force-version"]}
12-
13-
:install-local
14-
{:extra-deps {slipset/deps-deploy {:mvn/version "0.1.0"}
15-
org.slf4j/slf4j-simple {:mvn/version "1.7.30"} }
16-
:main-opts ["-m" "deps-deploy.deps-deploy" "install"]}
17-
18-
;; environment variables must be set for deploy to clojars:
19-
;; - CLOJARS_USERNAME=username
20-
;; - CLOJARS_PASSWORD=clojars-token
21-
:deploy-to-clojars
22-
{:extra-deps {slipset/deps-deploy {:mvn/version "0.1.0"}
23-
org.slf4j/slf4j-simple {:mvn/version "1.7.30"}}
24-
:main-opts ["-m" "deps-deploy.deps-deploy" "deploy"]}}}
5+
{:build {:deps {io.github.clojure/tools.build {:git/tag "v0.7.5" :git/sha "34727f7"}
6+
io.github.slipset/deps-deploy {:sha "d1fac08888ec8beda0579d3071bb9f804a1d446c"}}
7+
:ns-default build}
8+
9+
:outdated {:extra-deps {com.github.liquidz/antq {:mvn/version "1.5.0"}
10+
org.slf4j/slf4j-simple {:mvn/version "1.7.36"} ;; to rid ourselves of logger warnings
11+
}
12+
:main-opts ["-m" "antq.core" "--ignore-locals"]}}}

doc/tests/adoc-features.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ Wikilinks are only for CommonMark in docstrings.
205205

206206
Let's try referencing our APIs via fully qualified links:
207207

208-
1. https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core#exercise3[A link to cljdoc-exerciser.core/excercise3]
209-
2. https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core[A link to cljdoc-exerciser.core]
208+
1. https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core#exercise3[A link to cljdoc-exerciser.core/excercise3]
209+
2. https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core[A link to cljdoc-exerciser.core]
210210

211211
== Headings
212212
=== Level 3

doc/tests/md-features.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This document exists to compare basic features with AsciiDoctor. If you edit
77
this doc please also edit its [AsciiDoctor counterpart](adoc-features.adoc).
88

99
CommonMark is also supported in docstrings, have a look at [cljdoc-exerciser
10-
namespace on cljdoc.org](https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core)
10+
namespace on cljdoc.org](https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core)
1111
for some more examples.
1212

1313
## Formatting marks
@@ -122,8 +122,8 @@ Note: WikiLinks to api functions do not work here, they only work in docstrings.
122122
123123
Let's try referencing our APIs via fully qualified links:
124124
125-
1. [A link to cljdoc-exerciser.core/excercise3](https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core#exercise3)
126-
2. [A link to cljdoc-exerciser.core](https://cljdoc.org/d/lread/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core)
125+
1. [A link to cljdoc-exerciser.core/excercise3](https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core#exercise3)
126+
2. [A link to cljdoc-exerciser.core](https://cljdoc.org/d/org.cljdoc/cljdoc-exerciser/CURRENT/api/cljdoc-exerciser.core)
127127
128128
## Headings
129129
### Level 3

pom.xml

+17-27
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,35 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>lread</groupId>
4+
<groupId>org.cljdoc</groupId>
55
<artifactId>cljdoc-exerciser</artifactId>
6-
<version>1.0.57</version>
76
<name>cljdoc-exerciser</name>
8-
<dependencies>
9-
<dependency>
10-
<groupId>org.clojure</groupId>
11-
<artifactId>clojure</artifactId>
12-
<version>1.10.1</version>
13-
</dependency>
14-
</dependencies>
15-
<properties>
16-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
</properties>
18-
<build>
19-
<sourceDirectory>src</sourceDirectory>
20-
<resources>
21-
<resource>
22-
<directory>src</directory>
23-
</resource>
24-
</resources>
25-
</build>
7+
<url>https://github.com/cljdoc/cljdoc-exerciser</url>
8+
<licenses>
9+
<license>
10+
<name>Eclipse Public License</name>
11+
<url>http://www.eclipse.org/legal/epl-v10.html</url>
12+
</license>
13+
</licenses>
2614
<scm>
15+
<url>[email protected]:cljdoc/cljdoc-exerciser</url>
2716
<connection>scm:git:[email protected]:cljdoc/cljdoc-exerciser.git</connection>
2817
<developerConnection>scm:git:[email protected]:cljdoc/cljdoc-exerciser.git</developerConnection>
29-
<tag>f6071a876ab6f2062024ae93d96e303ec352fad7</tag>
30-
<url>[email protected]:cljdoc/cljdoc-exerciser</url>
3118
</scm>
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
</properties>
3222
<repositories>
3323
<repository>
3424
<id>clojars</id>
3525
<url>https://repo.clojars.org/</url>
3626
</repository>
3727
</repositories>
3828
<distributionManagement>
39-
<repository>
40-
<id>clojars</id>
41-
<name>Clojars repository</name>
42-
<url>https://clojars.org/repo</url>
43-
</repository>
29+
<repository>
30+
<id>clojars</id>
31+
<name>Clojars repository</name>
32+
<url>https://clojars.org/repo</url>
33+
</repository>
4434
</distributionManagement>
4535
</project>

0 commit comments

Comments
 (0)