Skip to content

Commit

Permalink
Release v0.4.1
Browse files Browse the repository at this point in the history
* Fix issue where RUST_BIGDECIMAL_DEFAULT_PRECISION envvar would always
  trigger a rebuild

* Fix issue where .neg() could be called on {signed-int}::MIN values

* Add implementions of Add/Sub/Mul/Div for primitive values

* Use 'proptest' crate to improve arithmetic testing
  • Loading branch information
akubera committed Jul 13, 2023
2 parents 2977cf9 + 1fc48f5 commit f450e54
Show file tree
Hide file tree
Showing 12 changed files with 1,020 additions and 498 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,14 @@ target
benches/test-data/

builds/

*.tgz
*.tar
*.bak
*.backup

*venv*/
.python-version
*.ipynb

proptest-regressions
202 changes: 136 additions & 66 deletions .gitlab-ci.yml 100644 → 100755
@@ -1,31 +1,98 @@
# Gitlab CI Config
# ================
#
# Defines jobs for checking/building/testing various
# configurations of the BigDecimal crate.
#
# Always tests against stable and MinimumSupportedRustVersion (1.43)
# Other random versions are available, requiring manual action to run.
#
# Most jobs are run upon custom rust containers I try to keep updated:
# https://gitlab.com/akubera/containers/-/blob/master/akubera-rust/Dockerfile.in
# https://hub.docker.com/r/akubera/rust/tags
#
# A coverage report is done via one of my rust-kcov or rust-grcov containers:
# https://gitlab.com/akubera/containers/-/blob/master/rust-kcov/Dockerfile.in
# https://gitlab.com/akubera/containers/-/blob/master/rust-grcov/Dockerfile.in
#
# A cargo:benchmark job is available, which saves a criterion report to gitlab,
# manualy activated and of dubious reliability without control of target machine.
#

#----------------------------#
# Yaml "Template" Objects #
#----------------------------#

.script:
cargo-check: &script-cargo-check
before_script:
- rustc --version && cargo --version
script:
- cargo check --tests

.script-cargo-build: &script-cargo-build
before_script:
- rustc --version && cargo --version
script:
- cargo build --tests

.script-cargo-test: &script-cargo-test
before_script:
- rustc --version && cargo --version
script:
- cargo test --verbose


.cache-cargo-registry: &cache-cargo-registry
key: cargo-registry
policy: pull
paths:
- .cargo/registry/index
- .cargo/registry/cache
- target/debug/deps

.cache-cargo-build: &cache-cargo-build
key: rustbuild-${RUST_CACHE_KEY}
policy: pull-push
paths:
- target/debug/deps
- target/debug/build

.cache-cargo-semver-check: &cache-cargo-semver-check
key: cargo-semver-checks
policy: pull-push
paths:
- target/semver-checks/cache

.rules.never-without-branch:
rules: &rules-never-without-branch
- if: '$CI_COMMIT_BRANCH == null'
when: never

.rules:always-master-otherwise-manual:
rules: &rules-always-master-otherwise-manual
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$CI_COMMIT_BRANCH == null'
when: never
- when: manual


#---------------------#
# Global Settings #
#---------------------#

cache:
- key: cargo-registry
policy: pull
paths:
- .cargo/registry/index
- .cargo/registry/cache
- target/debug/deps
# each job manually specifies its build cache - no way to automate on version
- key: rustbuild-${RUST_CACHE_KEY}
policy: pull-push
paths:
- target/debug/deps
- target/debug/build
- <<: *cache-cargo-registry
- <<: *cache-cargo-build

variables:
# store cargo registry in the project directory
# store cargo registry in the project directory (for caching)
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo

# this fixes an error when updating cargo registry
CARGO_NET_GIT_FETCH_WITH_CLI: 'true'

# default arguments to pass to cargo test
CARGO_BUILD_ARGS: ""

# default arguments to pass to cargo test
CARGO_TEST_ARGS: "--verbose"


stages:
- check
Expand All @@ -34,42 +101,24 @@ stages:
- deploy


.cargo-check-script: &cargo-check-script
script:
- rustc --version && cargo --version
- cargo check

.cargo-build-script: &cargo-build-script
script:
- rustc --version && cargo --version
- printenv CARGO_BUILD_ARGS
- cargo build $CARGO_BUILD_ARGS

.cargo-test-script: &cargo-test-script
script:
- rustc --version && cargo --version
- printenv CARGO_TEST_ARGS
- cargo test $CARGO_TEST_ARGS
#---------------------#
# CI Jobs #
#---------------------#


cargo:check:
stage: check
image: akubera/rust:stable
cache:
- key: cargo-registry
- <<: *cache-cargo-registry
policy: pull-push
paths:
- .cargo/registry/index
- .cargo/registry/cache
- target/debug/deps
- key: rustbuild-${RUST_CACHE_KEY}
policy: pull-push
paths:
- target/debug/deps
- target/debug/build
- <<: *cache-cargo-build
variables:
RUST_CACHE_KEY: "stable"
<<: *cargo-check-script
<<: *script-cargo-check
script:
# enable property tests for the stable 'pipeline'
- scripts/bigdecimal-property-tests cargo check --tests

cargo:clippy:
stage: check
Expand All @@ -79,6 +128,8 @@ cargo:clippy:
allow_failure: true
variables:
RUST_CACHE_KEY: "stable"
before_script:
- rustc --version && cargo --version && cargo clippy --version
script:
- cargo clippy -- -Dclippy::{dbg_macro,todo}

Expand All @@ -88,8 +139,11 @@ cargo:semver-checks:
needs:
- cargo:check
allow_failure: true
variables:
RUST_CACHE_KEY: "stable"
cache:
- <<: *cache-cargo-registry
- <<: *cache-cargo-semver-check
before_script:
- rustc --version && cargo --version && cargo semver-checks --version
script:
- cargo semver-checks

Expand All @@ -101,7 +155,11 @@ cargo:build-stable:
- cargo:check
variables:
RUST_CACHE_KEY: "stable"
<<: *cargo-build-script
<<: *script-cargo-build
script:
# enable property tests for the stable 'pipeline'
- scripts/bigdecimal-property-tests cargo build --tests


cargo:test-stable:
stage: test
Expand All @@ -110,7 +168,11 @@ cargo:test-stable:
- "cargo:build-stable"
variables:
RUST_CACHE_KEY: "stable"
<<: *cargo-test-script
<<: *script-cargo-test
script:
# enable property tests for the stable 'pipeline'
- scripts/bigdecimal-property-tests cargo test


cargo:build:no-std:
stage: build
Expand All @@ -119,8 +181,9 @@ cargo:build:no-std:
- cargo:check
variables:
RUST_CACHE_KEY: "stable+no_std"
CARGO_BUILD_ARGS: "--no-default-features --lib"
<<: *cargo-build-script
<<: *script-cargo-build
script:
- cargo build --no-default-features --lib

cargo:test:no-std:
stage: test
Expand All @@ -129,8 +192,9 @@ cargo:test:no-std:
- "cargo:build:no-std"
variables:
RUST_CACHE_KEY: "stable+no_std"
CARGO_TEST_ARGS: "--no-default-features --lib"
<<: *cargo-test-script
<<: *script-cargo-test
script:
- cargo test --no-default-features --lib


cargo:build-nightly:
Expand All @@ -139,7 +203,7 @@ cargo:build-nightly:
allow_failure: true
variables:
RUST_CACHE_KEY: "nightly"
<<: *cargo-build-script
<<: *script-cargo-build


cargo:test-nightly:
Expand All @@ -150,15 +214,15 @@ cargo:test-nightly:
allow_failure: true
variables:
RUST_CACHE_KEY: "nightly"
<<: *cargo-test-script
<<: *script-cargo-test


cargo:check-1.43:
stage: check
image: "akubera/rust-kcov:1.43.1-buster"
variables:
RUST_CACHE_KEY: "1.43"
<<: *cargo-check-script
<<: *script-cargo-check

cargo:build-1.43:
stage: build
Expand All @@ -167,7 +231,7 @@ cargo:build-1.43:
- "cargo:check-1.43"
variables:
RUST_CACHE_KEY: "1.43"
<<: *cargo-build-script
<<: *script-cargo-build

cargo:test-1.43:
stage: test
Expand All @@ -176,15 +240,17 @@ cargo:test-1.43:
image: "akubera/rust-kcov:1.43.1-buster"
variables:
RUST_CACHE_KEY: "1.43"
<<: *cargo-test-script
<<: *script-cargo-test


cargo:check-1.54:
stage: check
image: "akubera/rust-kcov:1.54.0-bullseye"
rules:
*rules-always-master-otherwise-manual
variables:
RUST_CACHE_KEY: "1.54"
<<: *cargo-check-script
<<: *script-cargo-check

cargo:build-1.54:
stage: build
Expand All @@ -193,7 +259,7 @@ cargo:build-1.54:
- "cargo:check-1.54"
variables:
RUST_CACHE_KEY: "1.54"
<<: *cargo-build-script
<<: *script-cargo-build

cargo:test-1.54:
stage: test
Expand All @@ -202,15 +268,17 @@ cargo:test-1.54:
image: "akubera/rust-kcov:1.54.0-bullseye"
variables:
RUST_CACHE_KEY: "1.54"
<<: *cargo-test-script
<<: *script-cargo-test


cargo:check-1.70:
stage: check
image: "akubera/rust-grcov:1.70.0-bullseye"
rules:
*rules-always-master-otherwise-manual
variables:
RUST_CACHE_KEY: "1.70"
<<: *cargo-check-script
<<: *script-cargo-check

cargo:build-1.70:
stage: build
Expand All @@ -219,7 +287,7 @@ cargo:build-1.70:
- "cargo:check-1.70"
variables:
RUST_CACHE_KEY: "1.70"
<<: *cargo-build-script
<<: *script-cargo-build

cargo:test-1.70:
stage: test
Expand All @@ -228,7 +296,7 @@ cargo:test-1.70:
image: "akubera/rust-grcov:1.70.0-bullseye"
variables:
RUST_CACHE_KEY: "1.70"
<<: *cargo-test-script
<<: *script-cargo-test


coverage-test:
Expand All @@ -246,8 +314,9 @@ coverage-test:
CARGO_INCREMENTAL: "0"

coverage: '/Code Coverage: \d+\.\d+/'
script:
before_script:
- rustc --version && cargo --version
script:
- cargo test
- ls -l target/coverage
- grcov target/coverage --binary-path target/debug -s . --keep-only 'src/*' -tcobertura -o cobertura.xml
Expand All @@ -270,6 +339,7 @@ cargo:benchmark:
image: "akubera/bigdecimal-benchmark-base:1.70.0-bullseye"
when: manual
allow_failure: true
# No cache as benchmark-image stores registry in different location
cache: []
variables:
RUST_CACHE_KEY: "1.70"
Expand Down

0 comments on commit f450e54

Please sign in to comment.