Skip to content

Commit 6db9025

Browse files
committedJan 1, 2025
[ci] Mirror testing setup to Orchard's
This includes testing Java source interaction in all JDKs 11+.
1 parent 1ec91b6 commit 6db9025

File tree

6 files changed

+64
-118
lines changed

6 files changed

+64
-118
lines changed
 

‎.circleci/config.yml

+25-42
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,30 @@ commands:
7979
paths:
8080
- ~/.m2
8181
- .cpcache
82-
- base-src.zip
82+
- base-src-jdk11.zip
83+
- base-src-jdk17.zip
84+
- base-src-jdk21.zip
85+
- base-src-jdk23.zip
8386
key: clojure-<< parameters.cache_version >>-{{ checksum "/tmp/clojure_cache_seed" }}
8487

8588
# The jobs are relatively simple. One runs utility commands against
8689
# latest stable JDK + Clojure, the other against specified versions
8790

8891
jobs:
8992

90-
util_job:
93+
lint:
9194
description: |
92-
Running utility commands/checks (linter etc.)
95+
Running linters
9396
parameters:
9497
steps:
9598
type: steps
96-
executor: jdk11
99+
executor: jdk21
97100
environment:
98-
CLOJURE_VERSION: "1.11.4"
101+
CLOJURE_VERSION: "1.12"
99102
steps:
100103
- checkout
101104
- with_cache:
102-
cache_version: "util_v3_1.11.4"
105+
cache_version: "lint_v3_1.12"
103106
steps: << parameters.steps >>
104107

105108
deploy:
@@ -126,19 +129,15 @@ jobs:
126129
clojure_version:
127130
description: Version of Clojure to test against
128131
type: string
129-
parser_target:
130-
description: The Orchard Java parser to be exercised
131-
type: string
132-
default: parser
133132
executor: << parameters.jdk_version >>
134133
environment:
135134
CLOJURE_VERSION: << parameters.clojure_version >>
136-
PARSER_TARGET: << parameters.parser_target >>
135+
JDK_SRC_VERSION: << parameters.jdk_version >>
137136
PROJECT_VERSION: 999.99.9
138137
steps:
139138
- checkout
140139
- with_cache:
141-
cache_version: "test_code_v3_<< parameters.clojure_version >>"
140+
cache_version: "test_code_v4_<< parameters.clojure_version >>_<< parameters.jdk_version >>"
142141
steps:
143142
- run:
144143
name: Running tests with inlined deps
@@ -152,9 +151,12 @@ jobs:
152151
# - run tests against the target matrix
153152
# - linter, eastwood and cljfmt
154153

155-
tags_filter: &tags_filter
156-
tags:
157-
only: /^v\d+\.\d+\.\d+(-alpha\d*)?(-beta\d*)?$/
154+
run_always: &run_always
155+
filters:
156+
branches:
157+
only: /.*/
158+
tags:
159+
only: /.*/
158160

159161
workflows:
160162
version: 2.1
@@ -168,29 +170,9 @@ workflows:
168170
alias: "test"
169171
parameters:
170172
clojure_version: ["1.10", "1.11", "1.12"]
171-
jdk_version: [jdk8, jdk11, jdk17, jdk23]
172-
filters:
173-
branches:
174-
only: /.*/
175-
<<: *tags_filter
176-
- test:
177-
# We have source for JDK21, so with this JDK version we also perform
178-
# Java parser tests.
179-
matrix:
180-
alias: "test_with_sources"
181-
parameters:
182-
clojure_version: ["1.10", "1.11", "1.12"]
183-
jdk_version: [jdk21]
184-
filters:
185-
branches:
186-
only: /.*/
187-
<<: *tags_filter
188-
- util_job:
189-
name: Code Linting
190-
filters:
191-
branches:
192-
only: /.*/
193-
<<: *tags_filter
173+
jdk_version: [jdk8, jdk11, jdk17, jdk21, jdk23]
174+
<<: *run_always
175+
- lint:
194176
steps:
195177
- run:
196178
name: Running cljfmt
@@ -205,12 +187,13 @@ workflows:
205187
name: Running Eastwood
206188
command: |
207189
make eastwood
190+
<<: *run_always
208191
- deploy:
209192
requires:
210-
- "test"
211-
- "test_with_sources"
212-
- "Code Linting"
193+
- test
194+
- lint
213195
filters:
214196
branches:
215197
ignore: /.*/
216-
<<: *tags_filter
198+
tags:
199+
only: /^v\d+\.\d+\.\d+(-alpha\d+)?$/

‎.clj-kondo/config.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
:type-mismatch {:level :off}
2525
:unresolved-namespace {:exclude [clojure.main nrepl.transport js]}}
2626
:output {:progress true
27-
:exclude-files ["data_readers" "tasks" "base-src.zip"]}}
27+
:exclude-files ["data_readers" "tasks"]}}

‎Makefile

+23-40
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
.PHONY: test quick-test eastwood cljfmt cljfmt-fix install fast-install smoketest deploy clean detect_timeout lein-repl repl lint light-kondo docs test_impl
1+
.PHONY: test quick-test eastwood cljfmt cljfmt-fix install fast-install smoketest deploy clean detect_timeout lint light-kondo docs test_impl
22
.DEFAULT_GOAL := quick-test
33

4-
CLOJURE_VERSION ?= 1.11
5-
6-
# The Lein profiles that will be selected for `lein-repl`.
7-
# Feel free to upgrade this, or to override it with an env var named LEIN_PROFILES.
8-
# Expected format: "+dev,+test"
9-
# Don't use spaces here.
10-
LEIN_PROFILES ?= "+dev,+test"
11-
12-
TEST_PROFILES ?= "-user,-dev,+test"
13-
14-
# The enrich-classpath version to be injected.
15-
# Feel free to upgrade this.
16-
ENRICH_CLASSPATH_VERSION="1.18.2"
17-
184
# Set bash instead of sh for the @if [[ conditions,
195
# and use the usual safety flags:
206
SHELL = /bin/bash -Ee
217

8+
CLOJURE_VERSION ?= 1.12
9+
TEST_PROFILES ?= "-user,-dev,+test"
10+
2211
# We need Java sources to test Java parsing functionality, but the Docker images
2312
# we use on CircleCI doesn't include src.zip. So we have to download them from
2413
# Github and repackage in a form that is resemblant to src.zip from normal
2514
# distributions.
26-
base-src.zip:
27-
wget https://github.com/adoptium/jdk21u/archive/refs/tags/jdk-21.0.5+3.zip -O full-src.zip
28-
unzip -q full-src.zip
29-
cp -r jdk21u-*/src/java.base/share/classes java.base
30-
cp -r jdk21u-*/src/java.desktop/share/classes java.desktop
31-
zip -qr base-src.zip java.base java.desktop
32-
rm -rf java.base java.desktop jdk21u-* full-src.zip
15+
base-src-jdk8.zip:
16+
# echo 'Placeholder. We dont parse sources on JDK8.'
17+
touch $@
18+
19+
base-src-jdk11.zip:
20+
bash download-jdk-sources.sh https://github.com/adoptium/jdk11u/archive/refs/tags/jdk-11.0.25+9.zip jdk11 $@
21+
22+
base-src-jdk17.zip:
23+
bash download-jdk-sources.sh https://github.com/adoptium/jdk17u/archive/refs/tags/jdk-17.0.13+11.zip jdk17 $@
24+
25+
base-src-jdk21.zip:
26+
bash download-jdk-sources.sh https://github.com/adoptium/jdk21u/archive/refs/tags/jdk-21.0.5+3.zip jdk21 $@
27+
28+
base-src-jdk23.zip:
29+
bash download-jdk-sources.sh https://github.com/adoptium/jdk23u/archive/refs/tags/jdk-23.0.1+11.zip jdk23 $@
30+
31+
copy-sources-to-jdk: base-src-$(JDK_SRC_VERSION).zip
32+
mkdir -p $(JAVA_HOME)/lib && cp base-src-$(JDK_SRC_VERSION).zip $(JAVA_HOME)/lib/src.zip
3333

3434
dump-version:
3535
echo '"$(PROJECT_VERSION)"' > resources/cider/nrepl/version.edn
@@ -39,7 +39,7 @@ target/srcdeps: project.clj
3939
# Remove cljfmt.main because it depends on tools.cli which we explicitly removed.
4040
rm -f target/srcdeps/cider/nrepl/inlined/deps/cljfmt/*/cljfmt/main.clj
4141

42-
test_impl: base-src.zip
42+
test_impl: copy-sources-to-jdk
4343
lein with-profile $(TEST_PROFILES),+$(CLOJURE_VERSION) test
4444

4545
test: target/srcdeps
@@ -115,22 +115,5 @@ clean:
115115
lein with-profile -user clean
116116
cd test/smoketest && lein with-profile -user clean
117117

118-
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
119-
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
120-
.enrich-classpath-lein-repl: Makefile project.clj $(wildcard checkouts/*/project.clj) $(wildcard deps.edn) $(wildcard $(HOME)/.clojure/deps.edn) $(wildcard profiles.clj) $(wildcard $(HOME)/.lein/profiles.clj) $(wildcard $(HOME)/.lein/profiles.d) $(wildcard /etc/leiningen/profiles.clj)
121-
bash 'lein' 'update-in' ':plugins' 'conj' "[mx.cider/lein-enrich-classpath \"$(ENRICH_CLASSPATH_VERSION)\"]" '--' 'with-profile' $(LEIN_PROFILES) 'update-in' ':middleware' 'conj' 'cider.enrich-classpath.plugin-v2/middleware' '--' 'repl' | grep " -cp " > $@
122-
123-
# Launches a repl, falling back to vanilla lein repl if something went wrong during classpath calculation.
124-
lein-repl: .enrich-classpath-lein-repl
125-
@if grep --silent " -cp " .enrich-classpath-lein-repl; then \
126-
export YOURKIT_SESSION_NAME="$(basename $(PWD))"; \
127-
eval "$$(cat .enrich-classpath-lein-repl) --interactive"; \
128-
else \
129-
echo "Falling back to lein repl... (you can avoid further falling back by removing .enrich-classpath-lein-repl)"; \
130-
lein with-profiles $(LEIN_PROFILES) repl; \
131-
fi
132-
133-
repl: lein-repl
134-
135118
docs:
136119
lein docs

‎README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,12 @@ guidelines](.github/CONTRIBUTING.md).
6262

6363
### Local development
6464

65-
Local development tasks, like firing up a repl, running the tests or locally installing cider-nrepl are offered by our Makefile.
65+
Local development tasks, like running the tests or locally installing cider-nrepl are offered by our Makefile.
6666
We recommend using it, since some aspects can be intricate to newcomers.
6767

6868
These are its main tasks for local development:
6969

7070
```
71-
# Fire up a repl and nrepl server you can cider-connect to:
72-
make repl
73-
7471
# Run tests, using mranderson (slower but more realistic)
7572
make test
7673

‎download-jdk-sources.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
URL="$1"
3+
QUALIFIER=$2
4+
DEST=$3
5+
6+
# Download JDK sources from Github and repackage in the same fashion as src.zip
7+
# that is normally distributed with JDK.
8+
wget "$URL" -O full-src.zip
9+
unzip -q full-src.zip
10+
cp -r "$QUALIFIER"u-*/src/java.base/share/classes java.base
11+
cp -r "$QUALIFIER"u-*/src/java.desktop/share/classes java.desktop
12+
zip -qr $DEST java.base java.desktop
13+
rm -rf java.base java.desktop "$QUALIFIER"u- full-src.zip

‎project.clj

+1-31
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
11
(def fipp-version "0.6.26")
2-
(def jdk8? (= (System/getProperty "java.specification.version") "1.8"))
3-
(def jdk21? (= (System/getProperty "java.specification.version") "21"))
4-
5-
;; Needed to be added onto classpath to test Java parser functionality.
6-
(def jdk-21-sources-archive
7-
(delay
8-
(let [src-zip (clojure.java.io/file "base-src.zip")]
9-
(if (.exists src-zip)
10-
(do (println "Found JDK sources:" src-zip)
11-
[src-zip])
12-
(do (println "base-src.zip not found. Run `make base-src.zip` to properly run all the tests.")
13-
nil)))))
14-
15-
;; Needed to run tests on JDK8.
16-
(def tools-jar
17-
(delay
18-
(let [java-home (System/getProperty "java.home")
19-
tools-jar-paths [(clojure.java.io/file java-home "tools.jar")
20-
(clojure.java.io/file java-home "lib" "tools.jar")
21-
(clojure.java.io/file java-home ".." "tools.jar")
22-
(clojure.java.io/file java-home ".." "lib" "tools.jar")]
23-
tools-jar (some #(when (.exists %) %) tools-jar-paths)]
24-
(assert tools-jar (str "tools.jar was not found in " java-home))
25-
(println "Found tools.jar:" tools-jar)
26-
(str tools-jar))))
272

283
(def dev-test-common-profile
294
{:dependencies '[[org.clojure/clojurescript "1.11.60" :scope "provided"]
@@ -32,12 +7,7 @@
327
[org.clojure/test.check "1.1.1"]
338
[cider/piggieback "0.6.0"]
349
[nubank/matcher-combinators "3.9.1"]]
35-
:source-paths (cond-> ["test/src"]
36-
;; We only include sources with JDK21 because we only
37-
;; repackage sources for that JDK. Sources from one JDK are
38-
;; not compatible with other JDK for our test purposes.
39-
jdk21? (into @jdk-21-sources-archive)
40-
jdk8? (conj @tools-jar))
10+
:source-paths ["test/src"]
4111
:global-vars {'*assert* true}
4212
:java-source-paths ["test/java"]
4313
:jvm-opts ["-Djava.util.logging.config.file=test/resources/logging.properties"]

0 commit comments

Comments
 (0)
Please sign in to comment.