From 95b563bbe83920ebbe3b906faa04ef8a9aa25eaf Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Thu, 18 Jun 2026 23:34:01 +0900 Subject: [PATCH 1/6] Add failing tests for regression --- test/clj_github/state_flow_helper_test.clj | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/clj_github/state_flow_helper_test.clj diff --git a/test/clj_github/state_flow_helper_test.clj b/test/clj_github/state_flow_helper_test.clj new file mode 100644 index 0000000..7e6a21f --- /dev/null +++ b/test/clj_github/state_flow_helper_test.clj @@ -0,0 +1,31 @@ +(ns clj-github.state-flow-helper-test + (:require [cheshire.core :as json] + [clj-github.httpkit-client :as httpkit-client] + [clj-github.state-flow-helper :as sfh] + [clojure.test :refer [deftest is]] + [matcher-combinators.test] + [state-flow.api :as flow] + [state-flow.core :as state-flow])) + +(defn- init-system [] + {:system {:github-client (httpkit-client/new-client {:token-fn (constantly "token")})}}) + +(defn- run-flow [a-flow] + (state-flow/run* {:init init-system} a-flow)) + +(deftest mock-github-flow-honors-responses + (let [response-body (json/generate-string {:id 1 :mergeable_state "clean"}) + [result _] (run-flow + (sfh/mock-github-flow + {:initial-state {:orgs [{:name "nubank" + :repos [{:name "dummy-lib" + :default_branch "main"}]}]} + :responses [{:path "/repos/nubank/dummy-lib/pulls/1" :method :get} + {:status 200 + :body response-body}]} + (sfh/with-github-client + (fn [client] + (httpkit-client/request client {:path "/repos/nubank/dummy-lib/pulls/1"})))))] + (is (match? {:status 200 + :body {:id 1 :mergeable_state "clean"}} + result)))) From fea14a9361b668b3d797efb99a61a0c8902dc3ae Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Fri, 19 Jun 2026 01:04:24 +0900 Subject: [PATCH 2/6] Restore clj-github.test-helpers/build-spec behavior `build-spec` was changed to return quoted forms instead of plain data, which breaks some use cases (such as `clj-github.state-flow-helper`). This reverts `build-spec` to its old behavior, fixing breakage in `clj-github.state-flow-helper` as well as some direct calls from clients (now documented as not recommended). --- src/clj_github/test_helpers.clj | 73 ++++++++-------------- test/clj_github/state_flow_helper_test.clj | 1 - 2 files changed, 25 insertions(+), 49 deletions(-) diff --git a/src/clj_github/test_helpers.clj b/src/clj_github/test_helpers.clj index ece2490..c83d10e 100644 --- a/src/clj_github/test_helpers.clj +++ b/src/clj_github/test_helpers.clj @@ -4,53 +4,29 @@ [org.httpkit.fake :as fake]) (:import (java.util.regex Pattern))) - -(defn- spec-type [spec] +(defn- request-spec [request] (cond - (-> spec meta :path) :path - (string? spec) :string - (map? spec) :map - (instance? Pattern spec) :pattern - :else :form)) - -(defmulti spec-builder spec-type) - -(defmethod spec-builder :string [request] - (str github-url request)) - -(defmethod spec-builder :map [request] - (if (:path request) - `(let [request# ~request - path# (:path request#)] - (assoc request# :url (str github-url path#))) - request)) - -(defmethod spec-builder :form [request] - request) - -(defmethod spec-builder :path [form] - `(spec-builder ~form)) - -(defmethod spec-builder :pattern [pattern] - {:url pattern}) - -(defn -add-default-content-type - [response] - (assoc-in response [:headers :content-type] "application/json")) - -(defn add-default-content-type [response] - `(let [responder# (fake/responder ~response)] - (fn [origin-fn# opts# callback#] - ((or callback# identity) - (responder# origin-fn# opts# -add-default-content-type))))) - -(defn build-spec [spec] - (reduce (fn [processed-fakes [request response]] - (-> processed-fakes - (conj (spec-builder request)) - (conj (add-default-content-type response)))) - [(str github-url "app/installations") "{}"] - (partition 2 spec))) + (string? request) (str github-url request) + (instance? Pattern request) {:url request} + (and (map? request) (:path request)) (assoc request :url (str github-url (:path request))) + :else request)) + +(defn- response-spec [response] + (let [responder (fake/responder response) + force-json #(assoc-in % [:headers :content-type] "application/json")] + (fn [orig-fn opts callback] + ((or callback identity) + (responder orig-fn opts force-json))))) + +(defn ^:internal build-spec + "Converts a `with-fake-github`-style spec (a sequence of request/response + pairs) into a value suitable for `org.httpkit.fake/with-fake-http`. + + Do not call directly." + [spec] + (into [(str github-url "app/installations") "{}"] + (mapcat (fn [[req resp]] [(request-spec req) (response-spec resp)])) + (partition 2 spec))) (defmacro with-fake-github "A wrapper around `with-fake-http` that sets up some defaults for GitHub access. @@ -67,5 +43,6 @@ However, the response Content-Type header is forced to \"application/json\", so the body (if provided) must be a JSON value encoded as string." [spec & body] - `(fake/with-fake-http ~(build-spec spec) - ~@body)) + `(fake/with-fake-http + (build-spec ~(mapv #(if (-> % meta :path) `{:path ~%} %) spec)) + ~@body)) diff --git a/test/clj_github/state_flow_helper_test.clj b/test/clj_github/state_flow_helper_test.clj index 7e6a21f..34f7145 100644 --- a/test/clj_github/state_flow_helper_test.clj +++ b/test/clj_github/state_flow_helper_test.clj @@ -4,7 +4,6 @@ [clj-github.state-flow-helper :as sfh] [clojure.test :refer [deftest is]] [matcher-combinators.test] - [state-flow.api :as flow] [state-flow.core :as state-flow])) (defn- init-system [] From 3f507839a1f47335cff5a37213f015b32f59183c Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Fri, 19 Jun 2026 01:05:01 +0900 Subject: [PATCH 3/6] Version 0.9.1-beta1 --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index e341b04..fcd4792 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject dev.nubank/clj-github "0.9.0" +(defproject dev.nubank/clj-github "0.9.1-beta1" :description "A Clojure library for interacting with the github developer API" :url "https://github.com/nubank/clj-github" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" From f9f1fe72c3cc3d853d88b870cf107fef0268b6fa Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Fri, 19 Jun 2026 01:20:08 +0900 Subject: [PATCH 4/6] Fix `/app/installations` mock in test-helpers It was missing the leading slash in the mocked URL (no it was not actually mocked by default). --- src/clj_github/test_helpers.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clj_github/test_helpers.clj b/src/clj_github/test_helpers.clj index c83d10e..4dc5525 100644 --- a/src/clj_github/test_helpers.clj +++ b/src/clj_github/test_helpers.clj @@ -24,7 +24,7 @@ Do not call directly." [spec] - (into [(str github-url "app/installations") "{}"] + (into [(str github-url "/app/installations") "{}"] (mapcat (fn [[req resp]] [(request-spec req) (response-spec resp)])) (partition 2 spec))) From 8b17771ac8ea472bcf16b24c971ce27b3486a9e5 Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Fri, 19 Jun 2026 17:11:20 +0900 Subject: [PATCH 5/6] Version 0.9.1 --- CHANGELOG.md | 5 +++++ project.clj | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f68cdf..b4fede8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.9.1 + +- Fix regression in `clj-github.test-helpers/build-spec`, restoring its behavior to pre-0.8.0 (return plain data, not quoted forms) +- Fix bug in default `/app/installations` mock + ## 0.9.0 - Add function to create releases for repositories diff --git a/project.clj b/project.clj index fcd4792..73649fe 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject dev.nubank/clj-github "0.9.1-beta1" +(defproject dev.nubank/clj-github "0.9.1" :description "A Clojure library for interacting with the github developer API" :url "https://github.com/nubank/clj-github" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" From a8993d63190015e4bae17229abc5480e7852ec28 Mon Sep 17 00:00:00 2001 From: Marco Biscaro Date: Fri, 19 Jun 2026 17:12:29 +0900 Subject: [PATCH 6/6] Remove workflows from public repo --- .nu/workflows/moriarty.yaml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .nu/workflows/moriarty.yaml diff --git a/.nu/workflows/moriarty.yaml b/.nu/workflows/moriarty.yaml deleted file mode 100644 index c0f7119..0000000 --- a/.nu/workflows/moriarty.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: workflows.dev/v1alpha1 -kind: TemplateInstance -metadata: - namespace: pipelines -spec: - templateName: moriarty-pr