Add manifest-path option

This commit is contained in:
Mieszko Grodzicki 2023-01-03 20:39:25 +01:00 committed by Predrag Gruevski
parent 18ce3d76fa
commit a754e4ed0a
2 changed files with 11 additions and 9 deletions

View file

@ -15,6 +15,7 @@ Every argument is optional.
| Input | Description | Default | | Input | Description | Default |
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------|---------| |--------------------|-----------------------------------------------------------------------------------------------------------------------------------|---------|
| crate-name | The crate whose API to check for semver. If not set, all crates in the workspace are processed. | | | crate-name | The crate whose API to check for semver. If not set, all crates in the workspace are processed. | |
| manifest-path | Path to Cargo.toml of crate or workspace to check. Has an effect only if `crate-name` is not specified. | |
# Scenarios # Scenarios
@ -22,7 +23,7 @@ Every argument is optional.
## Use in workspaces with more than one crate ## Use in workspaces with more than one crate
By default, if workspace contains multiple crates, all of them are checked against semver violations. You can specify single crate to be checked instead using `crate-name`. By default, if workspace contains multiple crates, all of them are checked against semver violations. You can specify single crate to be checked instead using `crate-name` or `manifest-path`.
For example, this will check `my-crate`: For example, this will check `my-crate`:
```yaml ```yaml

View file

@ -8,6 +8,10 @@ inputs:
description: 'The crate whose API to check for semver. If not set, all crates in the workspace are processed.' description: 'The crate whose API to check for semver. If not set, all crates in the workspace are processed.'
required: false required: false
default: '' default: ''
manifest-path:
description: 'Path to Cargo.toml of crate or workspace to check. Has an effect only if crate-name is not specified.'
required: false
default: ''
runs: runs:
using: "composite" using: "composite"
steps: steps:
@ -24,14 +28,11 @@ runs:
# Colorize output, since GitHub Actions terminals support color. # Colorize output, since GitHub Actions terminals support color.
export CARGO_TERM_COLOR=always export CARGO_TERM_COLOR=always
# If crate to check is specified, pass it to cargo-semver-checks, export CRATE_NAME="${{ inputs.crate-name }}"
# otherwise use `--workspace` option. export MANIFEST_PATH="${{ inputs.manifest-path }}"
if [[ "${{ inputs.crate-name }}" == '' ]]; then
export PACKAGE_OPTION="--workspace" export SEMVER_CHECKS_OPTIONS="${CRATE_NAME:+"--package $CRATE_NAME"} ${MANIFEST_PATH:+"--manifest-path $MANIFEST_PATH"}"
else
export PACKAGE_OPTION="--package ${{ inputs.crate-name }}"
fi
# Check for semver violations. # Check for semver violations.
cargo install cargo-semver-checks --locked cargo install cargo-semver-checks --locked
cargo semver-checks check-release $PACKAGE_OPTION cargo semver-checks check-release $SEMVER_CHECKS_OPTIONS