Skip to content

Commit

Permalink
Fix mock for the replace-only function (#56)
Browse files Browse the repository at this point in the history
* Fix mock for the `replace-only` function.

- It should throw an AerospikeException when the item doesn't exist.
- Current it replaces the underlying data with an AerospikeException type object.

* Pin the clj-kondo version

* PR #56 code review comments [1]

* Don't use `clojure-lint-action`, run `lein lint` instead

* Add missing distribution

* Using `8` instead of `1.8` in java-version

* Use a pinned Aerospike version in the CI

* Run on latest ubuntu LTS version
  • Loading branch information
evg-tso authored Jul 27, 2022
1 parent d669b64 commit 060f2cb
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 61 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/build_test_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,29 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Validate SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
Expand All @@ -35,16 +42,17 @@ jobs:
echo "Version isn't a SNAPSHOT version:" $VERSION
exit 0
fi
- name: Lint
- name: Run linters
run: lein lint

test:
needs: build
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
Expand All @@ -54,17 +62,24 @@ jobs:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and integration tests
run: lein test :all
63 changes: 41 additions & 22 deletions .github/workflows/ci_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Validate SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
Expand All @@ -36,20 +43,17 @@ jobs:
echo "Version isn't a SNAPSHOT version:" $VERSION
exit 0
fi
- name: Lint
uses: DeLaGuardo/clojure-lint-action@v1
with:
clj-kondo-args: --lint src test --cache false
check-name: clj-kondo liniting report
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run linters
run: lein lint

test:
needs: build
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
Expand All @@ -59,20 +63,28 @@ jobs:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and Integration tests
run: lein eftest :all

- name: Publish unit and integration test results
uses: EnricoMi/[email protected]
if: always()
Expand All @@ -82,22 +94,29 @@ jobs:

deploy:
needs: test
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
Expand Down
63 changes: 41 additions & 22 deletions .github/workflows/ci_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@ on:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Validate SNAPSHOT version
env:
SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$
Expand All @@ -36,20 +43,17 @@ jobs:
echo "Version isn't a SNAPSHOT version:" $VERSION
exit 0
fi
- name: Lint
uses: DeLaGuardo/clojure-lint-action@v1
with:
clj-kondo-args: --lint src test --cache false
check-name: clj-kondo liniting report
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run linters
run: lein lint

test:
needs: build
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
services:
aerospike-test:
image: aerospike
image: aerospike:4.9.0.11
ports:
- 3000:3000
- 3001:3001
Expand All @@ -59,20 +63,28 @@ jobs:
AEROSPIKE_HOST: localhost
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Unit and Integration tests
run: lein eftest :all

- name: Publish unit and integration test results
uses: EnricoMi/[email protected]
if: always()
Expand All @@ -82,22 +94,29 @@ jobs:

deploy:
needs: test
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Set up JDK 8
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: corretto
java-version: 8

- name: Restore local Maven repository from cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }}
restore-keys: |
${{ runner.os }}-maven-
- name: Deploy release version
env:
RELEASE_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}$
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ aerospike-clj.iml
target
.nrepl-port
.lsp
/.clj-kondo/.cache
.java-version
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## This library follows [Semantic Versioning](https://semver.org).
## This CHANGELOG follows [keepachangelog](https://keepachangelog.com/en/1.0.0/).

### VERSION 2.0.2
#### Changed
* The behavior of the mocked `replace-only`.
It should throw an AerospikeException when the item doesn't exist.

### VERSION 2.0.1
#### Updated
* Links in README and CI config.
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.appsflyer/aerospike-clj "2.0.1"
(defproject com.appsflyer/aerospike-clj "2.0.2-SNAPSHOT"
:description "An Aerospike Clojure client."
:url "https://github.com/AppsFlyer/aerospike-clj"
:license {:name "Eclipse Public License"
Expand All @@ -24,7 +24,7 @@
[cheshire "5.10.0"]
[danlentz/clj-uuid "0.1.9"]
[com.fasterxml.jackson.core/jackson-databind "2.11.2"]
[clj-kondo "RELEASE"]]
[clj-kondo "2021.01.20"]]
:aliases {"clj-kondo" ["run" "-m" "clj-kondo.main"]
"lint" ["run" "-m" "clj-kondo.main" "--lint" "src" "test"]}
:global-vars {*warn-on-reflection* true}
Expand Down
6 changes: 3 additions & 3 deletions src/main/clojure/aerospike_clj/mock_client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
(let [transcoder (get-transcoder conf)
new-record (create-record (transcoder data) expiration)]
(set-record current-state new-record set-name k))
(AerospikeException.
ResultCode/KEY_NOT_FOUND_ERROR
(str "Call to `replace-only` on non-existing key '" k "'"))))]
(throw (AerospikeException.
ResultCode/KEY_NOT_FOUND_ERROR
(str "Call to `replace-only` on non-existing key '" k "'")))))]
(do-swap state swap-fn)))

(update [this k set-name new-record generation new-expiration]
Expand Down
Loading

0 comments on commit 060f2cb

Please sign in to comment.