feat(core): range constraints for internal dependencies#181
Open
goulvenclech wants to merge 11 commits intomainfrom
Open
feat(core): range constraints for internal dependencies#181goulvenclech wants to merge 11 commits intomainfrom
goulvenclech wants to merge 11 commits intomainfrom
Conversation
🧭 Changeset detectedMerging this PR will release the following updates: sampo (Cargo) — minor version bumpMinor changes
sampo-core (Cargo) — minor version bumpMinor changes
sampo-github-action (Cargo) — minor version bumpMinor changes
|
Member
Author
|
Open questions :
|
Contributor
The usual way to install |
74bf19f to
6c36c8d
Compare
aaaba36 to
e495da6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #175 . Sampo no longer overwrites range constraints for internal dependencies (or skips them silently in some cases). During release planning, if a planned version bump doesn't satisfy a range constraint (e.g. bumping
footo2.0.0when another package requiresfoo = "^1.0"), you'll get either an error (for packages infixedorlinkedgroups) or a warning, instead of silently skipping. Pinned versions (e.g.foo = "1.2.3") are still bumped automatically.What has changed?
crates/sampo-core/src/adapters/cargo.rs:check_dependency_constraint()usingVersionReq,should_update_dependency_version()to preserve ranges and update pinned versions,ManifestMetadatahelpers for constraint extraction.crates/sampo-core/src/adapters/npm.rs: Full npm semver constraint checker (hand-rolled, no external deps). Reads constraints frompackage.json, supports caret, tilde, comparators, x-ranges, hyphen ranges, OR groups. Skips workspace/file/link/git protocols and pre-release versions.crates/sampo-core/src/adapters/hex.rs: Full Hex constraint checker (hand-rolled, no external deps). Supports pessimistic operator (~>), comparators (==,>=,<=,>,<), andand/orconjunctions. Skips pinned versions and pre-release versions (consistent with npm behaviour). The evaluation logic is Hex-generic and reusable for future Erlang (rebar3) and Gleam support.crates/sampo-core/src/adapters/packagist.rs: Full Composer constraint checker (hand-rolled, no external deps). Reads constraints fromcomposer.json, supports caret, tilde, comparators (>=,>,<=,<,!=), wildcards (*,1.*,1.0.*), AND (comma/space-separated), OR (||). Skips stability flags, pinned versions, and pre-release versions.crates/sampo-core/src/adapters/pypi.rs+pip.rs: Full PEP 440 constraint checker (hand-rolled, no external deps). Reads constraints frompyproject.toml, supports compatible release (~=), comparators (==,!=,>=,<=,>,<), wildcards (==1.2.*,!=1.*), compound AND (comma-separated). Handles extras, environment markers, URL dependencies, and PEP 503 name normalization. Skips pinned versions and pre-release versions.crates/sampo-core/src/release.rs:validate_dependency_constraints()— validates range constraints during release planning, errors for fixed/linked groups, warnings otherwise.crates/sampo-core/src/types.rs:ConstraintCheckResultenum,ConstraintViolationstruct.crates/sampo-core/src/errors.rs:ConstraintViolationerror variant.crates/sampo-core/src/adapters.rs:check_dependency_constraintdispatch onPackageAdapter.How is it tested?
cargo_tests.rs: 22 constraint validation tests + 10 range preservation tests (all dep formats).npm_tests.rs: 40+ tests covering caret, tilde, comparators, AND/OR ranges, x-ranges, hyphen ranges, whitespace normalisation, protocol skipping, pinned/pre-release skipping, all dependency sections.hex_tests.rs: Tests covering pessimistic operator (~>), comparators,and/orconjunctions, pinned/pre-release skipping.packagist_tests: 37 tests covering caret, tilde, comparators, AND (comma/space), OR, wildcards, whitespace tolerance, pinned/pre-release/stability-flag skipping, dev-deps lookup.pip_tests.rs: 32 tests covering compatible release, comparators, wildcards, compound constraints, extras/markers stripping, PEP 503 normalization, optional dependencies, post-release handling, pinned/pre-release skipping.release_tests.rs: 4 integration tests (range preserved, pinned updated, violation blocks fixed groups, violation warns without groups).types.rs: Unit tests forConstraintCheckResultandConstraintViolation.How is it documented?
crates/sampo/README.md: Added note about range constraint support in internal dependencies.