A GitHub Action for running cargo-semver-checks
Find a file
Mieszko Grodzicki 461983b3bb
Add test for baseline caching (#33)
* Cache test

* Baseline caching - initial work

* Add comment explaining the change of CARGO_TARGET_DIR.

* Update README.md

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* Refactor getRustcVersion and getCargoSemverChecksVersion

* Move helper functions outside RustdocCache class.

* cachePath passed in constructor

* workspaceRoot as constructor argument

* Inline getManifestDir

* Change target to semver-checks/target

* Fix missing hash-files

* Add workflow testing caching

* New line

* Add checking the updated cache

* Missing semicolon

* Bad job name in cache key

* Upload cache if its hash changes

* Test options cache-key and prefix-key

* Need to use restore-keys

* Is path a problem?

* Absolute path

* Move

* Fix restore inputs

* Verify

* Revert debug

* Rustc and semver-checks versions should not be fixed!

* debug test

* key not being a prefix

* Missing outputs

* Revert letter change in hash

* Update CI README

* TODO comments, shorter names

* Better names

* check the key

* Missing '

* Remove space

* Missing outputs

* Remove hash check

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>

* Remove inconsistent newlines from workflows README

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
2023-04-07 10:54:46 -04:00
.github Add test for baseline caching (#33) 2023-04-07 10:54:46 -04:00
dist Remove temporary fix for Windows machines. (#32) 2023-04-05 15:19:29 -04:00
src Remove temporary fix for Windows machines. (#32) 2023-04-05 15:19:29 -04:00
.eslintrc.cjs Add eslint and prettier (#10) 2023-02-27 16:42:26 -05:00
.gitignore brand-new action in node.js (#4) 2023-02-27 16:42:26 -05:00
.npmrc brand-new action in node.js (#4) 2023-02-27 16:42:26 -05:00
.prettierrc.json Add eslint and prettier (#10) 2023-02-27 16:42:26 -05:00
action.yml Baseline rustdoc caching (#29) 2023-04-04 09:26:44 -04:00
LICENSE Initial commit 2022-07-20 18:45:54 -04:00
package-lock.json Baseline rustdoc caching (#29) 2023-04-04 09:26:44 -04:00
package.json Baseline rustdoc caching (#29) 2023-04-04 09:26:44 -04:00
README.md Baseline rustdoc caching (#29) 2023-04-04 09:26:44 -04:00
tsconfig.json Add ending newlines 2023-02-27 16:42:26 -05:00

cargo-semver-checks-action

Lint your crate API changes for semver violations.

This is the work-in-progress v2 version of this action. Find the docs for the stable v1 action here.

- name: Check semver
  uses: obi1kenobi/cargo-semver-checks-action@v2
- name: Publish to crates.io
  run: # your `cargo publish` code here

Input options

Every argument is optional.

Input Description Default
package The package 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.
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 path.
verbose Enables verbose output of cargo-semver-checks. false
cache-key Rustdoc baseline is cached separately for runs that differ in at least one of the following: runner OS, rustc version, cargo-semver-checks version, or any of the Cargo.lock files in the current workspace. This input might be used to further separate the caches by providing the unique key (by default the job name) for each of them. ${{ github.job }}
prefix-key Additional prefix of the cache key, can be set to start a new cache manually.
github-token The GITHUB_TOKEN secret used to download precompiled binaries from GitHub API. If not specified, the automatic GitHub token provided to the workflow will be used. The token may be alternatively passed in an environment variable GITHUB_TOKEN. ${{ github.token }}

Use in workspaces with a single crate

The action will work out-of-the-box if it is run inside the package root directory. When the package location is different, you have to specify the path to its Cargo.toml file:

- name: Check semver for my-crate
  uses: obi1kenobi/cargo-semver-checks-action@v2
  with:
    manifest-path: semver/my-crate/Cargo.toml  # or just semver/my-crate/
- name: Publish my-crate to crates.io
  run: # your `cargo publish` code here

Use in workspaces with more than one crate

By default, if workspace contains multiple crates, all of them are checked for semver violations. You can specify a single crate to be checked instead using package or manifest-path.

For example, this will check my-crate:

- name: Check semver for my-crate from the current workspace
  uses: obi1kenobi/cargo-semver-checks-action@v2
  with:
    package: my-crate
- name: Publish my-crate to crates.io
  run: # your `cargo publish` code here

If the action is not run inside the workspace root directory, you again have to specify the path to its Cargo.toml file:

- name: Check semver for all crates from my-workspace
  uses: obi1kenobi/cargo-semver-checks-action@v2
  with:
    manifest-path: semver/my-workspace/Cargo.toml  # or just semver/my-workspace/
- name: Publish my-workspace to crates.io
  run: # your `cargo publish` code here

The two above might be also used together:

- name: Check semver for my-crate from my-workspace
  uses: obi1kenobi/cargo-semver-checks-action@v2
  with:
    manifest-path: semver/my-workspace/Cargo.toml  # or just semver/my-workspace/
    package: my-crate
- name: Publish my-crate to crates.io
  run: # your `cargo publish` code here