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

reliable :and generator #23

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
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
62 changes: 49 additions & 13 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:

jobs:
build-clj:
timeout-minutes: 5

strategy:
matrix:
# Supported Java versions: LTS releases and latest
jdk: [8, 11, 17, 21]
clojure: [11, 12]

name: Clojure ${{ matrix.clojure }} (Java ${{ matrix.jdk }})
name: Java ${{ matrix.jdk }}

runs-on: ubuntu-latest

Expand All @@ -26,23 +28,34 @@ jobs:
with:
distribution: zulu
java-version: ${{ matrix.jdk }}
- uses: actions/cache@v4
- uses: actions/cache/restore@v4
id: cache-restore
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ matrix.clojure }}-${{ matrix.jdk }}
key: ${{ runner.os }}-build-clj-${{ hashFiles('**/deps.edn') }}-${{ matrix.jdk }}
restore-keys: |
${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ matrix.clojure }}-
${{ runner.os }}-test-deps-
${{ runner.os }}-build-clj-${{ hashFiles('**/deps.edn') }}-
${{ runner.os }}-build-clj-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: latest
- name: Run tests
run: CLOJURE_ALIAS=clojure-${{ matrix.clojure }} bin/kaocha
run: bin/kaocha
- name: Always Save Cache
id: cache-save
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: |
~/.m2/repository
~/.gitlibs

build-cljs:
timeout-minutes: 5
name: ClojureScript
strategy:
matrix:
Expand All @@ -56,14 +69,15 @@ jobs:
with:
distribution: zulu
java-version: 11
- uses: actions/cache@v4
- uses: actions/cache/restore@v4
id: cache-restore
with:
path: |
~/.m2/repository
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}
key: ${{ runner.os }}-build-cljs-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-test-deps-
${{ runner.os }}-build-cljs-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
Expand All @@ -72,12 +86,23 @@ jobs:
uses: actions/setup-node@v4.1.0
with:
node-version: 16
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests on ${{ matrix.mode }}
run: bin/node ${{ matrix.mode }}
- name: Always Save Cache
id: cache-save
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: |
~/.m2/repository
~/.gitlibs

build-bb:
timeout-minutes: 5
name: Babashka

runs-on: ubuntu-latest
Expand All @@ -88,20 +113,31 @@ jobs:
with:
distribution: zulu
java-version: 11
- uses: actions/cache@v4
- uses: actions/cache/restore@v4
id: cache-restore
with:
path: |
~/.m2/repository
~/.deps.clj
~/.gitlibs
key: ${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-${{ hashFiles('**/bb.edn') }}
key: ${{ runner.os }}-build-bb-${{ hashFiles('**/deps.edn') }}-${{ hashFiles('**/bb.edn') }}
restore-keys: |
${{ runner.os }}-test-deps-${{ hashFiles('**/deps.edn') }}-
${{ runner.os }}-test-deps-
${{ runner.os }}-build-bb-${{ hashFiles('**/deps.edn') }}-
${{ runner.os }}-build-bb-
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@master
with:
cli: latest
bb: latest
- name: Run tests
run: bb test-bb
- name: Always Save Cache
id: cache-save
if: always() && steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
path: |
~/.m2/repository
~/.deps.clj
~/.gitlibs
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ Malli is in well matured [alpha](README.md#alpha).
* previous behavior defaulted to a `nil`-returning generator, even if the schema doesn't accept `nil`
* use `:gen/return nil` property to restore this behavior
* FIX: `malli.registry/{mode,type}` not respected in Babashka [#1124](https://github.com/metosin/malli/issues/1124)
* Change `:and` generator to be more reliable
* new function `malli.solver/solve` returns descriptions of values that satisfy schemas
* new approach: `[:and s1 s2]` generates `s1` with `(solve s2)` narrowing `s1`'s generator by changing the arguments passed to test.check
* e.g., `[:and [:<= 5] [:>= 5]]` combines `(gen/double* {:max 5})` with solution `{:min-number 5}` giving `(gen/double* {:min 5 :max 5})`
* extend `malli.solver/-solve` to extend solver to new schemas
* mechanism for adding new solution constraints tbd
* note: will change seeds for some `:and` generators
* those that used to be prone to certain `gen/such-that` failures
* `pos?`/`neg?` generators now generate from the closest double up/down from zero
* note: will change seeds
* `[:> n]`/`[:< n]` generators now generate from the closest double up/down from n
* throws if resulting numbers are infinite or NaN
* note: will change seeds
* FIX: `[:> Double/MAX_VALUE]` generates `Double/MAX_VALUE` [#1035](https://github.com/metosin/malli/issues/1035)
* FIX: `:seqable`/`:every` generates `nil` when `:min` is positive [#1121](https://github.com/metosin/malli/issues/1121)
* Updated dependencies:

```
Expand Down
2 changes: 1 addition & 1 deletion bin/kaocha
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
# Should work if the env var is empty
clojure -A:$CLOJURE_ALIAS -M:test -m kaocha.runner "$@"
clojure -M:test -m kaocha.runner "$@"
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
org.clojure/test.check {:mvn/version "1.1.1"}
;; pretty errors, optional deps
fipp/fipp {:mvn/version "0.6.27"}
mvxcvi/arrangement {:mvn/version "2.1.0"}}
mvxcvi/arrangement {:mvn/version "2.1.0"}
org.clojure/math.combinatorics {:mvn/version "0.1.6"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {com.gfredericks/test.chuck {:mvn/version "0.2.14"}
lambdaisland/kaocha {:mvn/version "1.91.1392"}
Expand Down
Loading
Loading