Skip to content

Commit

Permalink
Merge branch 'release-1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
greglook committed Sep 12, 2019
2 parents 8344359 + c1ef978 commit bc2289b
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 135 deletions.
72 changes: 50 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,65 @@
version: 2
version: 2.1

jobs:
build:
working_directory: ~/project
# Common executor configuration
executors:
clojure:
docker:
- image: circleci/clojure:lein-2.8.1
- image: circleci/clojure:lein-2.9.1
working_directory: ~/repo


# Job definitions
jobs:
style:
executor: clojure
steps:
- checkout
- run:
name: Install cljfmt CLI
command: "wget https://github.com/greglook/cljfmt/releases/download/0.8.1/cljfmt_0.8.1_linux.tar.gz && tar -xzf cljfmt_0.8.1_linux.tar.gz"
- run:
name: Check source formatting
command: "./cljfmt check --stats style-stats.tsv"
- store_artifacts:
path: style-stats.tsv
destination: style

test:
executor: clojure
steps:
- checkout
- restore_cache:
keys:
- v1-{{ checksum "project.clj" }}
- v1-
- v1-test-{{ checksum "project.clj" }}
- v1-test-
- run: lein deps
- save_cache:
paths:
- ~/.m2
key: v1-{{ checksum "project.clj" }}
- run: lein check
- run: lein test
# FIXME: Currently fails in CI with:
# clojure.lang.ArityException: Wrong number of args (2) passed to: reader/read
# Possibly due to wrong clojure version (1.4.0?) getting pulled in
#- run: lein cloverage --codecov
- save_cache:
key: v1-test-{{ checksum "project.clj" }}
paths:
- ~/.m2
key: v1-{{ checksum "project.clj" }}
#- store_artifacts:
# path: target/coverage
# destination: coverage
#- run:
# name: Publish Coverage
# command: "bash <(curl -s https://codecov.io/bash) -f target/coverage/codecov.json"

examples:
executor: clojure
steps:
- checkout
- restore_cache:
keys:
- v1-test-{{ checksum "project.clj" }}
- v1-test-
- run:
name: Run Example Tests
command: ./test/example-tests.sh


# Workflow definitions
workflows:
version: 2
build:
jobs:
- style
- test
- examples:
requires:
- test
8 changes: 8 additions & 0 deletions .cljfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; Clojure formatting rules
;; vim: filetype=clojure
{:file-ignore #{"checkouts" "target"}
:padding-lines 2
:max-consecutive-blank-lines 3
:single-import-break-width 30
:indents {config/debug-profile [[:block 1]]
d/future-with [[:block 1]]}}
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

...

## [1.2.2] - 2019-09-11

### Fixed
- Ensure projects are not initialized concurrently to guard against "unbound fn"
errors.
[#15](https://github.com/amperity/lein-monolith/issues/15)
[#48](https://github.com/amperity/lein-monolith/pull/48)

### Changed
- Adopted cljfmt style rules and added CI style checks.

## [1.2.1] - 2019-04-25

### Added
Expand Down Expand Up @@ -174,7 +187,8 @@ instead of loading them all before running any commands.

Initial project release

[Unreleased]: https://github.com/amperity/lein-monolith/compare/1.2.1...HEAD
[Unreleased]: https://github.com/amperity/lein-monolith/compare/1.2.2...HEAD
[1.2.2]: https://github.com/amperity/lein-monolith/compare/1.2.1...1.2.2
[1.2.1]: https://github.com/amperity/lein-monolith/compare/1.2.0...1.2.1
[1.2.0]: https://github.com/amperity/lein-monolith/compare/1.1.0...1.2.0
[1.1.0]: https://github.com/amperity/lein-monolith/compare/1.0.1...1.1.0
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2016 Amperity, Inc.
Copyright 2016-2019 Amperity, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
1 change: 1 addition & 0 deletions example/apps/app-a/src/project_a/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns project-a.core)


(defn foo
"I don't do a whole lot."
[x]
Expand Down
5 changes: 3 additions & 2 deletions example/apps/app-a/test/project_a/core_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns project-a.core-test
(:require [clojure.test :refer :all]
[project-a.core :refer :all]))
(:require
[clojure.test :refer :all]
[project-a.core :refer :all]))


(deftest a-app-test
Expand Down
1 change: 1 addition & 0 deletions example/libs/lib-a/src/lib_a/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns lib-a.core)


(defn foo
"I don't do a whole lot."
[x]
Expand Down
5 changes: 3 additions & 2 deletions example/libs/lib-a/test/lib_a/core_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns lib-a.core-test
(:require [clojure.test :refer :all]
[lib-a.core :refer :all]))
(:require
[clojure.test :refer :all]
[lib-a.core :refer :all]))


(deftest a-code-test
Expand Down
1 change: 1 addition & 0 deletions example/libs/lib-b/src/lib_b/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns lib-b.core)


(defn foo
"I don't do a whole lot."
[x]
Expand Down
5 changes: 3 additions & 2 deletions example/libs/lib-b/test/lib_b/core_test.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns lib-b.core-test
(:require [clojure.test :refer :all]
[lib-b.core :refer :all]))
(:require
[clojure.test :refer :all]
[lib-b.core :refer :all]))


(deftest b-code-test
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject lein-monolith "1.2.1"
(defproject lein-monolith "1.2.2"
:description "Leiningen plugin for managing subrojects within a monorepo."
:url "https://github.com/amperity/lein-monolith"
:license {:name "Apache License 2.0"
Expand Down
20 changes: 10 additions & 10 deletions src/lein_monolith/config.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(ns lein-monolith.config
(:require
[clojure.java.io :as io]
(leiningen.core
[main :as lein]
[project :as project])
[lein-monolith.dependency :as dep])
[lein-monolith.dependency :as dep]
[leiningen.core.main :as lein]
[leiningen.core.project :as project])
(:import
java.io.File))

Expand Down Expand Up @@ -81,13 +80,14 @@
[^File file]
(cond
(.isDirectory file)
[file]
[file]

(and (= "*" (.getName file)) (.isDirectory (.getParentFile file)))
(->> (.getParentFile file)
(.listFiles)
(filter #(.isDirectory ^File %)))
:else
nil))
(->> (.getParentFile file)
(.listFiles)
(filter #(.isDirectory ^File %)))

:else nil))


(defn- read-subproject
Expand Down
28 changes: 18 additions & 10 deletions src/lein_monolith/dependency.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@
[project-names sym]
(let [valid-keys (set project-names)]
(cond
(valid-keys sym) sym
(valid-keys (condense-name sym)) (condense-name sym)
(valid-keys sym)
sym

(valid-keys (condense-name sym))
(condense-name sym)

(nil? (namespace sym))
(let [candidates (filter #(= (name %) (name sym)) valid-keys)]
(if (= 1 (count candidates))
(first candidates)
(seq candidates)))
(let [candidates (filter #(= (name %) (name sym)) valid-keys)]
(if (= 1 (count candidates))
(first candidates)
(seq candidates)))

:else nil)))


Expand All @@ -53,10 +58,12 @@
(let [result (resolve-name project-names sym)]
(cond
(nil? result)
(lein/abort "Could not resolve" sym "to any monolith subproject!")
(lein/abort "Could not resolve" sym "to any monolith subproject!")

(coll? result)
(lein/abort "Name" sym "resolves to multiple monolith subprojects:"
(str/join " " (sort result)))
(lein/abort "Name" sym "resolves to multiple monolith subprojects:"
(str/join " " (sort result)))

:else result)))


Expand Down Expand Up @@ -124,7 +131,8 @@
"Returns a set of the keys which are downstream of a given node in the
dependency map. Includes the root value itself."
[dependencies root]
(let [deps-on (fn deps-on [n]
(let [deps-on (fn deps-on
[n]
(set (keep (fn [[k deps]] (when (deps n) k))
dependencies)))]
(loop [result #{}
Expand Down
29 changes: 13 additions & 16 deletions src/lein_monolith/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
(:require
[clojure.java.io :as jio]
[clojure.string :as str]
(leiningen.core
[main :as lein]
[project :as project])
(lein-monolith
[config :as config]
[dependency :as dep])
[lein-monolith.config :as config]
[lein-monolith.dependency :as dep]
[leiningen.core.main :as lein]
[leiningen.core.project :as project]
[puget.color.ansi :as ansi]
[puget.printer :as puget]))

Expand Down Expand Up @@ -62,24 +60,23 @@
(cond
; Don't inherit anything
(not setting)
nil
nil

; Inherit the base properties specified in the parent.
(true? setting)
; TODO: instead of select-keys, could do reducing get-in/assoc-in
(select-keys monolith base-properties)
(select-keys monolith base-properties)

; Provide additional properties to inherit, or replace if metadata is set.
(vector? setting)
(->> (if (:replace (meta setting))
setting
(distinct (concat base-properties setting)))
(select-keys monolith))
(->> (if (:replace (meta setting))
setting
(distinct (concat base-properties setting)))
(select-keys monolith))

:else
(throw (ex-info (str "Unknown value type for monolith inherit setting: "
(pr-str setting))
{:inherit setting})))))
(throw (ex-info (str "Unknown value type for monolith inherit setting: "
(pr-str setting))
{:inherit setting})))))


(defn build-inherited-profiles
Expand Down
25 changes: 13 additions & 12 deletions src/lein_monolith/task/checkouts.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
(:require
[clojure.java.io :as io]
[clojure.string :as str]
[leiningen.core.main :as lein]
[lein-monolith.dependency :as dep]
[lein-monolith.task.util :as u])
[lein-monolith.task.util :as u]
[leiningen.core.main :as lein])
(:import
(java.io
File)
java.io.File
(java.nio.file
Files
LinkOption
Expand Down Expand Up @@ -63,16 +62,18 @@
selected-names (into #{}
(map (partial dep/resolve-name! (keys dep-map)))
project-names)
projects-to-link (cond->> (map (comp dep/condense-name first)
(:dependencies project))
(or (:deep opts) (seq project-names))
projects-to-link (->
(map (comp dep/condense-name first)
(:dependencies project))
(cond->>
(or (:deep opts) (seq project-names))
(mapcat (partial dep/upstream-keys dep-map))
true

(seq selected-names)
(filter selected-names))
(->>
(distinct)
(seq selected-names)
(filter selected-names)
true
(keep subprojects))
(keep subprojects)))
checkouts-dir (io/file (:root project) "checkouts")]
(when (empty? projects-to-link)
(lein/abort (str "Couldn't find any projects to link matching: "
Expand Down

0 comments on commit bc2289b

Please sign in to comment.