Skip to content

Commit dd264a7

Browse files
Merge pull request #7 from nubank/upgrade-deps
Support mocking binary files, upgrade dependencies
2 parents 64e509c + 051bc6d commit dd264a7

File tree

9 files changed

+149
-126
lines changed

9 files changed

+149
-126
lines changed

.github/workflows/clojure.yml

+18-30
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,33 @@ name: Clojure CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
10-
test-using-java-8:
11-
name: 'Test using Java 8'
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v2
15-
16-
- uses: actions/setup-java@v1
17-
with:
18-
java-version: 8
1910

20-
- name: Print java version
21-
run: java -version
11+
test-clojure:
2212

23-
- name: Install dependencies
24-
run: lein deps
13+
strategy:
14+
matrix:
15+
java-version: [11, 17, 21]
2516

26-
- name: Run clj tests
27-
run: lein test
28-
29-
test-using-java-11:
30-
name: 'Test using Java 11'
3117
runs-on: ubuntu-latest
18+
3219
steps:
33-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
3421

35-
- uses: actions/setup-java@v1
36-
with:
37-
java-version: 11
22+
- uses: actions/setup-java@v4
23+
with:
24+
distribution: temurin
25+
java-version: ${{ matrix.java-version }}
3826

39-
- name: Print java version
40-
run: java -version
27+
- name: Print java version
28+
run: java -version
4129

42-
- name: Install dependencies
43-
run: lein deps
30+
- name: Install dependencies
31+
run: lein deps
4432

45-
- name: Run clj tests
46-
run: lein test
33+
- name: Run clj tests
34+
run: lein test

.github/workflows/release.yml

+18-32
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,36 @@ on:
66
- '*'
77

88
jobs:
9-
test-using-java-8:
10-
name: 'Test using Java 8'
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v2
14-
15-
- uses: actions/setup-java@v1
16-
with:
17-
java-version: 8
9+
test-clojure:
10+
strategy:
11+
matrix:
12+
java-version: [11, 17, 21]
1813

19-
- name: Print java version
20-
run: java -version
21-
22-
- name: Install dependencies
23-
run: lein deps
24-
25-
- name: Run clj tests
26-
run: lein test
27-
28-
test-using-java-11:
29-
name: 'Test using Java 11'
3014
runs-on: ubuntu-latest
15+
3116
steps:
32-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
3318

34-
- uses: actions/setup-java@v1
35-
with:
36-
java-version: 11
19+
- uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: ${{ matrix.java-version }}
3723

38-
- name: Print java version
39-
run: java -version
24+
- name: Print java version
25+
run: java -version
4026

41-
- name: Install dependencies
42-
run: lein deps
27+
- name: Install dependencies
28+
run: lein deps
4329

44-
- name: Run clj tests
45-
run: lein test
30+
- name: Run clj tests
31+
run: lein test
4632

4733
release:
4834
name: 'Publish on Clojars'
4935
runs-on: ubuntu-latest
50-
needs: [test-using-java-11, test-using-java-8]
36+
needs: [test-clojure]
5137
steps:
52-
- uses: actions/checkout@v2
38+
- uses: actions/checkout@v4.2.2
5339

5440
- name: Install dependencies
5541
run: lein deps

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 0.3.0
4+
- Correctly handle binary files in create-blob! and get-blob operations
5+
- Fix reflective accesses in clj-github-mock.impl.jgit
6+
- Remove base64-clj dependency
7+
- Bump dependencies
8+
- org.eclipse.jgit/org.eclipse.jgit from 5.11.0 to 6.10.0
9+
- metosin/reitit-ring from 0.5.13 to 0.7.2
10+
- datascript from 1.1.0 to 1.7.3
11+
312
## 0.2.0
413
- Bump some libs
514

RELEASING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Releasing
22

3-
Anybody with write access to this repository can release a new version and deploy it to Clojars. To do this, first make sure your local master is sync'd with master on github:
3+
Anybody with write access to this repository can release a new version and deploy it to Clojars. To do this, first make sure your local main is sync'd with main on github:
44

55
```bash
6-
git checkout master
6+
git switch main
77
git pull
88
```
99

project.clj

+17-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject dev.nubank/clj-github-mock "0.2.0"
1+
(defproject dev.nubank/clj-github-mock "0.3.0"
22
:description "An emulator of the github api"
33
:url "https://github.com/nubank/clj-github-mock"
44
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
@@ -9,32 +9,27 @@
99
:password :env/clojars_passwd
1010
:sign-releases false}]]
1111

12-
:plugins [[lein-cljfmt "0.7.0" :exclusions [org.clojure/clojure]]
13-
[lein-cloverage "1.0.13" :exclusions [org.clojure/clojure]]
14-
[lein-vanity "0.2.0" :exclusions [org.clojure/clojure]]
15-
[lein-kibit "0.1.7" :exclusions [org.clojure/clojure]]
16-
[lein-nsorg "0.3.0" :exclusions [org.clojure/clojure]]
17-
[s3-wagon-private "1.3.2" :exclusions [commons-logging org.apache.httpcomponents/httpclient]]
18-
[lein-ancient "0.6.14" :exclusions [commons-logging com.fasterxml.jackson.core/jackson-databind com.fasterxml.jackson.core/jackson-core]]]
12+
:plugins [[lein-cljfmt "0.9.2"]
13+
[lein-cloverage "1.2.4"]
14+
[lein-vanity "0.2.0"]
15+
[lein-nsorg "0.3.0"]]
1916

20-
:dependencies [[org.clojure/clojure "1.10.3"]
21-
[org.eclipse.jgit/org.eclipse.jgit "5.11.0.202103091610-r"]
22-
[metosin/reitit-ring "0.5.13"]
23-
[base64-clj "0.1.1"]
17+
:dependencies [[org.clojure/clojure "1.12.0"]
18+
; NOTE: can't upgrade to 7.X because it doesn't support JDK 11 anymore
19+
[org.eclipse.jgit/org.eclipse.jgit "6.10.0.202406032230-r"]
20+
[metosin/reitit-ring "0.7.2"]
2421
[ring/ring-json "0.5.1"]
2522
[ring/ring-mock "0.4.0"]
26-
[datascript "1.1.0"]]
23+
[datascript "1.7.3"]]
2724

2825
:profiles {:dev {:plugins [[lein-project-version "0.1.0"]]
29-
:dependencies [[clj-http "3.12.1"]
30-
[clj-http-fake "1.0.3"]
31-
[org.clojure/test.check "1.1.0"]
32-
[nubank/matcher-combinators "3.1.4"]
33-
[metosin/malli "0.4.0"]
34-
[lambdaisland/regal "0.0.97"]
35-
[juji/editscript "0.5.7"]
36-
[reifyhealth/specmonstah "2.0.0"]
37-
[medley "1.3.0"]]}}
26+
:dependencies [[org.clojure/test.check "1.1.1"]
27+
[nubank/matcher-combinators "3.9.1"]
28+
[metosin/malli "0.16.4"]
29+
[lambdaisland/regal "0.1.175"]
30+
[juji/editscript "0.6.4"]
31+
[reifyhealth/specmonstah "2.1.0"]
32+
[medley "1.4.0"]]}}
3833

3934
:aliases {"coverage" ["cloverage" "-s" "coverage"]
4035
"lint" ["do" ["cljfmt" "check"] ["nsorg"]]

src/clj_github_mock/impl/base64.clj

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(ns clj-github-mock.impl.base64
2+
(:import (java.nio.charset StandardCharsets)
3+
(java.util Base64 Base64$Decoder Base64$Encoder)))
4+
5+
(set! *warn-on-reflection* true)
6+
7+
(def ^:private ^Base64$Encoder base64-encoder (Base64/getEncoder))
8+
(def ^:private ^Base64$Decoder base64-decoder (Base64/getDecoder))
9+
10+
(defn encode-bytes->str
11+
"Encodes the given byte array to its Base64 representation."
12+
^String [^bytes bs]
13+
(let [data (.encode base64-encoder bs)]
14+
(String. data StandardCharsets/UTF_8)))
15+
16+
(defn encode-str->str
17+
"Encodes the given String to its Base64 representation using UTF-8."
18+
^String [^String s]
19+
(encode-bytes->str (.getBytes s StandardCharsets/UTF_8)))
20+
21+
(defn decode-str->bytes
22+
"Decodes the given Base64 String to a byte array."
23+
^bytes [^String s]
24+
(let [bs (.getBytes s StandardCharsets/UTF_8)]
25+
(.decode base64-decoder bs)))
26+
27+
(defn decode-str->str
28+
"Decodes the given Base64 String to a new String using UTF-8."
29+
^String [^String s]
30+
(String. (decode-str->bytes s) StandardCharsets/UTF_8))

0 commit comments

Comments
 (0)