Support specifying features to test. (#49)

This commit is contained in:
Predrag Gruevski 2023-06-06 14:49:48 -04:00 committed by GitHub
parent 651743decf
commit 06053f9c6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View file

@ -92,6 +92,17 @@ jobs:
uses: ./action/ uses: ./action/
with: with:
exclude: rio_testsuite exclude: rio_testsuite
- name: Run with only default features
uses: ./action/
with:
package: rio_api, rio_turtle
feature-group: default-features
- name: Run with explicit features only
uses: ./action/
with:
package: rio_api, rio_turtle
feature-group: only-explicit-features
feature: generalized
test-exclude: test-exclude:
name: Test input exclude name: Test input exclude

View file

@ -43,6 +43,8 @@ Every argument is optional.
| `package` | Comma-separated list of the packages whose API to check for semver (in Package Id Specification format, see https://doc.rust-lang.org/cargo/reference/pkgid-spec.html for reference). If not set, all packages defined in the Cargo.toml file are processed. | | | `package` | Comma-separated list of the packages whose API to check for semver (in Package Id Specification format, see https://doc.rust-lang.org/cargo/reference/pkgid-spec.html for reference). If not set, all packages defined in the Cargo.toml file are processed. | |
| `exclude` | Comma-separated list of the packages that will be excluded from being processed. Has effect only if the input `package` is not specified. | | | `exclude` | Comma-separated list of the packages that will be excluded from being processed. Has effect only if the input `package` is not specified. | |
| `manifest-path` | Path to Cargo.toml of crate or workspace to check. If not specified, the action assumes the manifest is under the default [`GITHUB_WORKSPACE`](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) path. | | | `manifest-path` | Path to Cargo.toml of crate or workspace to check. If not specified, the action assumes the manifest is under the default [`GITHUB_WORKSPACE`](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) path. | |
| `feature-group` | Which [feature group](https://github.com/obi1kenobi/cargo-semver-checks#what-features-does-cargo-semver-checks-enable-in-the-tested-crates) to enable. When not set, the action heuristically enables all features that are not unstable, nightly, or internal-only. Possible values: `all-features`, `default-features`, `only-explicit-features`. | |
| `feature` | Explicitly enable a list of features when checking. Corresponds to [the tool's `--feature` flag](https://github.com/obi1kenobi/cargo-semver-checks#what-features-does-cargo-semver-checks-enable-in-the-tested-crates). | |
| `verbose` | Enables verbose output of `cargo-semver-checks`. | `false` | | `verbose` | Enables verbose output of `cargo-semver-checks`. | `false` |
| `release-type` | Sets the release type instead of deriving it from the version number specified in the `Cargo.toml` file. Possible values are `major`, `minor`, `patch`. | | | `release-type` | Sets the release type instead of deriving it from the version number specified in the `Cargo.toml` file. Possible values are `major`, `minor`, `patch`. | |
| `rust-toolchain` | Rust toolchain name to use, e.g. `stable`, `nightly` or `1.68.0`. It will be installed if necessary and used regardless of local overrides and the `rust-toolchain.toml` file. However, if the input is set to `manual`, the action assumes some Rust toolchain is already installed and uses the default one. | `stable` | | `rust-toolchain` | Rust toolchain name to use, e.g. `stable`, `nightly` or `1.68.0`. It will be installed if necessary and used regardless of local overrides and the `rust-toolchain.toml` file. However, if the input is set to `manual`, the action assumes some Rust toolchain is already installed and uses the default one. | `stable` |

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View file

@ -22,10 +22,27 @@ function getCheckReleaseArguments(): string[] {
optionFromList("--exclude", rustCore.input.getInputList("exclude")), optionFromList("--exclude", rustCore.input.getInputList("exclude")),
optionIfValueProvided("--manifest-path", rustCore.input.getInput("manifest-path")), optionIfValueProvided("--manifest-path", rustCore.input.getInput("manifest-path")),
optionIfValueProvided("--release-type", rustCore.input.getInput("release-type")), optionIfValueProvided("--release-type", rustCore.input.getInput("release-type")),
getFeatureGroup(rustCore.input.getInput("feature-group")),
optionFromList("--feature", rustCore.input.getInputList("feature")),
rustCore.input.getInputBool("verbose") ? ["--verbose"] : [], rustCore.input.getInputBool("verbose") ? ["--verbose"] : [],
].flat(); ].flat();
} }
function getFeatureGroup(name = ""): string[] {
switch (name) {
case "all-features":
return ["--all-features"];
case "default-features":
return ["--default-features"];
case "only-explicit-features":
return ["--only-explicit-features"];
case "":
return [""];
default:
throw new Error(`Unsupported feature group: ${name}`);
}
}
function getGitHubToken(): string { function getGitHubToken(): string {
const token = process.env["GITHUB_TOKEN"] || rustCore.input.getInput("github-token"); const token = process.env["GITHUB_TOKEN"] || rustCore.input.getInput("github-token");
if (!token) { if (!token) {