-
Notifications
You must be signed in to change notification settings - Fork 36
Improve release automation. #466
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
Changes from all commits
8b92690
27530f8
6bff584
3066eaa
ea1607b
01c9c4c
028c11e
84a901e
6492bc1
b505a2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| (ns ctim.change-schema-version) | ||
|
|
||
| (defn -main | ||
| [version] | ||
| (spit "./resources/ctim/version.txt" version)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1.3.30-SNAPSHOT |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| (:refer-clojure :exclude [ref uri?]) | ||
| (:require [clj-momo.lib.clj-time.coerce :refer [to-long]] | ||
| [clojure.set :refer [map-invert]] | ||
| [clojure.string :as str] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can remove requires of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what the state of things was at the time of this comment, but as it stands:
|
||
| #?(:clj [clojure.spec.alpha :as cs] | ||
| :cljs [cljs.spec.alpha :as cs]) | ||
| [clojure.zip :as z] | ||
|
|
@@ -17,15 +18,16 @@ | |
| def-enum-type | ||
| def-eq]]) | ||
| [flanders.navigation :as fn] | ||
| [flanders.predicates :as fp] | ||
| [clojure.string :as str])) | ||
| [flanders.predicates :as fp]) | ||
| (#?(:clj :require :cljs :require-macros) [ctim.version :refer [ctim-version]])) | ||
|
|
||
| (def ctim-schema-version "1.3.30") | ||
|
|
||
| (def ctim-schema-version (ctim-version)) | ||
|
|
||
| (def-eq CTIMSchemaVersion ctim-schema-version) | ||
|
|
||
| (cs/def ::ctim-schema-version | ||
| #(re-matches #"\w+.\w+\.\w+" %)) | ||
| #(re-matches #"\w+.\w+\.\w+(-SNAPSHOT)?" %)) | ||
|
|
||
| (def SchemaVersion | ||
| (f/str | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| (ns ctim.version | ||
| (:require [clojure.java.io :as io])) | ||
|
|
||
| (defmacro ctim-version | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be me misunderstanding how cljs works, but I'm unclear why this needs to be a macro
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The initial problem here was that you'd need to manually update We considered two main solutions.
This implements 2. The reason it needs to be a macro is that cljs doesn't implement
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's been a minute since I wrote this, but I think what's happening is that clojurescript needs to read the resource that holds the version at compile time, and having it as a macro allows the code to be evaluated at compile time instead of runtime.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I recall correctly, @frenchy64 and I had a lot of back-and-forth about how to keep the CTIM library and schema versions in sync, only some of which seems to be captured in the PR comments. Several ideas were considered, and the one we ended up with involves this version file and the need for the clj/cljs code to read from it to get the schema version.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I hadn't seen @frenchy64's comment. He explains it better. |
||
| "This is a macro to support cljs compile-time inlining of the version string | ||
| from the JVM resource." | ||
| [] | ||
| (slurp (io/resource "ctim/version.txt"))) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,29 @@ | ||
| (ns ctim.schemas.common-test | ||
| (:refer-clojure :exclude [ref uri?]) | ||
| (:require [ctim.schemas.common :as sut] | ||
| [flanders.schema :as fs] | ||
| [clojure.test :refer [deftest is]])) | ||
| (:require | ||
| [clojure.java.io :as io] | ||
| [clojure.test :refer [deftest is testing]] | ||
| [ctim.schemas.common :as sut] | ||
| [flanders.schema :as fs])) | ||
|
|
||
| (defn- ->swagger [dll] (:json-schema (meta (fs/->schema dll)))) | ||
|
|
||
| (deftest swagger-test | ||
| (is (= {:example {:value "1.2.3.4", :type "ip"} | ||
| :description "A simple, atomic value which has a consistent identity, and is stable enough to be attributed an intent or nature. This is the classic 'indicator' which might appear in a data feed of bad IPs, or bad Domains. These do not exist as objects within the CTIA storage model, so you never create an observable."} | ||
| (->swagger sut/Observable)))) | ||
|
|
||
| (defn lein-project-version | ||
| [] | ||
| (let [properties (with-open [pom-properties-reader (io/reader (io/resource "META-INF/maven/threatgrid/ctim/pom.properties"))] | ||
| (doto (java.util.Properties.) | ||
| (.load pom-properties-reader)))] | ||
| (if-let [ver (get properties "version")] | ||
| ver | ||
| (throw (ex-info "Unable to resolve ctim version" {}))))) | ||
|
|
||
| (deftest version-test | ||
| (testing "The lein project version and ctim schema version are in sync." | ||
| (is (re-matches #"[\d]+\.[\d]+\.[\d]+.*?" sut/ctim-schema-version) | ||
| "Version follows the expected semantic versioning pattern.") | ||
| (is (= (lein-project-version) sut/ctim-schema-version)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we always want to update the docs when we bump versions, and vice-versa.
Please redefine the
"doc"alias to do the equivalent of runningctim.change-schema-version/-mainfollowed byctim.document/-main.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done