Skip to content
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

Support mocking binary files, upgrade dependencies #7

Merged
merged 9 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 18 additions & 30 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,33 @@ name: Clojure CI

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:
test-using-java-8:
name: 'Test using Java 8'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 8

- name: Print java version
run: java -version
test-clojure:

- name: Install dependencies
run: lein deps
strategy:
matrix:
java-version: [11, 17, 21]

- name: Run clj tests
run: lein test

test-using-java-11:
name: 'Test using Java 11'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java-version }}

- name: Print java version
run: java -version
- name: Print java version
run: java -version

- name: Install dependencies
run: lein deps
- name: Install dependencies
run: lein deps

- name: Run clj tests
run: lein test
- name: Run clj tests
run: lein test
50 changes: 18 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,36 @@ on:
- '*'

jobs:
test-using-java-8:
name: 'Test using Java 8'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: 8
test-clojure:
strategy:
matrix:
java-version: [11, 17, 21]

- name: Print java version
run: java -version

- name: Install dependencies
run: lein deps

- name: Run clj tests
run: lein test

test-using-java-11:
name: 'Test using Java 11'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java-version }}

- name: Print java version
run: java -version
- name: Print java version
run: java -version

- name: Install dependencies
run: lein deps
- name: Install dependencies
run: lein deps

- name: Run clj tests
run: lein test
- name: Run clj tests
run: lein test

release:
name: 'Publish on Clojars'
runs-on: ubuntu-latest
needs: [test-using-java-11, test-using-java-8]
needs: [test-clojure]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.2.2

- name: Install dependencies
run: lein deps
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.3.0
- Correctly handle binary files in create-blob! and get-blob operations
- Fix reflective accesses in clj-github-mock.impl.jgit
- Remove base64-clj dependency
- Bump dependencies
- org.eclipse.jgit/org.eclipse.jgit from 5.11.0 to 6.10.0
- metosin/reitit-ring from 0.5.13 to 0.7.2
- datascript from 1.1.0 to 1.7.3

## 0.2.0
- Bump some libs

Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Releasing

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:
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:

```bash
git checkout master
git switch main
git pull
```

Expand Down
39 changes: 17 additions & 22 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject dev.nubank/clj-github-mock "0.2.0"
(defproject dev.nubank/clj-github-mock "0.3.0"
:description "An emulator of the github api"
:url "https://github.com/nubank/clj-github-mock"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand All @@ -9,32 +9,27 @@
:password :env/clojars_passwd
:sign-releases false}]]

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

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

:profiles {:dev {:plugins [[lein-project-version "0.1.0"]]
:dependencies [[clj-http "3.12.1"]
[clj-http-fake "1.0.3"]
[org.clojure/test.check "1.1.0"]
[nubank/matcher-combinators "3.1.4"]
[metosin/malli "0.4.0"]
[lambdaisland/regal "0.0.97"]
[juji/editscript "0.5.7"]
[reifyhealth/specmonstah "2.0.0"]
[medley "1.3.0"]]}}
:dependencies [[org.clojure/test.check "1.1.1"]
[nubank/matcher-combinators "3.9.1"]
[metosin/malli "0.16.4"]
[lambdaisland/regal "0.1.175"]
[juji/editscript "0.6.4"]
[reifyhealth/specmonstah "2.1.0"]
[medley "1.4.0"]]}}

:aliases {"coverage" ["cloverage" "-s" "coverage"]
"lint" ["do" ["cljfmt" "check"] ["nsorg"]]
Expand Down
30 changes: 30 additions & 0 deletions src/clj_github_mock/impl/base64.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(ns clj-github-mock.impl.base64
(:import (java.nio.charset StandardCharsets)
(java.util Base64 Base64$Decoder Base64$Encoder)))

(set! *warn-on-reflection* true)

(def ^:private ^Base64$Encoder base64-encoder (Base64/getEncoder))
(def ^:private ^Base64$Decoder base64-decoder (Base64/getDecoder))

(defn encode-bytes->str
"Encodes the given byte array to its Base64 representation."
^String [^bytes bs]
(let [data (.encode base64-encoder bs)]
(String. data StandardCharsets/UTF_8)))

(defn encode-str->str
"Encodes the given String to its Base64 representation using UTF-8."
^String [^String s]
(encode-bytes->str (.getBytes s StandardCharsets/UTF_8)))

(defn decode-str->bytes
"Decodes the given Base64 String to a byte array."
^bytes [^String s]
(let [bs (.getBytes s StandardCharsets/UTF_8)]
(.decode base64-decoder bs)))

(defn decode-str->str
"Decodes the given Base64 String to a new String using UTF-8."
^String [^String s]
(String. (decode-str->bytes s) StandardCharsets/UTF_8))
Loading
Loading