mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge DEVELOPER_INSTRUCTIONS into CONTRIBUTING
This commit is contained in:
parent
1d24c94341
commit
de1f0ef315
2 changed files with 96 additions and 78 deletions
106
CONTRIBUTING.md
106
CONTRIBUTING.md
|
@ -30,13 +30,81 @@ If you have any questions, feel free to ask them in the issues or on
|
||||||
|
|
||||||
## Platforms
|
## Platforms
|
||||||
|
|
||||||
We take pride in supporting many operating systems and architectures.
|
We take pride in supporting many operating systems and architectures. Any code
|
||||||
|
you contribute must at least compile without warnings for all platforms in the
|
||||||
|
CI. However, you can use `#[cfg(...)]` attributes to create platform dependent features.
|
||||||
|
|
||||||
**Tip:**
|
**Tip:** For Windows, Microsoft provides some images (VMWare, Hyper-V,
|
||||||
For Windows, Microsoft provides some images (VMWare, Hyper-V, VirtualBox and Parallels)
|
VirtualBox and Parallels) for development:
|
||||||
for development:
|
|
||||||
<https://developer.microsoft.com/windows/downloads/virtual-machines/>
|
<https://developer.microsoft.com/windows/downloads/virtual-machines/>
|
||||||
|
|
||||||
|
## Tools
|
||||||
|
|
||||||
|
We have an extensive CI that will check your code before it can be merged. This
|
||||||
|
section explains how to run those checks locally to avoid waiting for the CI.
|
||||||
|
|
||||||
|
### pre-commit hooks
|
||||||
|
|
||||||
|
A configuration for `pre-commit` is provided in the repository. It allows
|
||||||
|
automatically checking every git commit you make to ensure it compiles, and
|
||||||
|
passes `clippy` and `rustfmt` without warnings.
|
||||||
|
|
||||||
|
To use the provided hook:
|
||||||
|
|
||||||
|
1. [Install `pre-commit`](https://pre-commit.com/#install)
|
||||||
|
1. Run `pre-commit install` while in the repository directory
|
||||||
|
|
||||||
|
Your git commits will then automatically be checked. If a check fails, an error
|
||||||
|
message will explain why, and your commit will be canceled. You can then make
|
||||||
|
the suggested changes, and run `git commit ...` again.
|
||||||
|
|
||||||
|
### clippy
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cargo clippy --all-targets --all-features
|
||||||
|
```
|
||||||
|
|
||||||
|
The `msrv` key in the clippy configuration file `clippy.toml` is used to disable
|
||||||
|
lints pertaining to newer features by specifying the minimum supported Rust
|
||||||
|
version (MSRV).
|
||||||
|
|
||||||
|
### rustfmt
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cargo fmt --all
|
||||||
|
```
|
||||||
|
|
||||||
|
### cargo-deny
|
||||||
|
|
||||||
|
This project uses [cargo-deny](https://github.com/EmbarkStudios/cargo-deny/) to
|
||||||
|
detect duplicate dependencies, checks licenses, etc. To run it locally, first
|
||||||
|
install it and then run with:
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo deny --all-features check all
|
||||||
|
```
|
||||||
|
|
||||||
|
### Markdown linter
|
||||||
|
|
||||||
|
We use [markdownlint](https://github.com/DavidAnson/markdownlint) to lint the
|
||||||
|
Markdown files in the repository.
|
||||||
|
|
||||||
|
### Spell checker
|
||||||
|
|
||||||
|
We use `cspell` as spell checker for all files in the project. If you are using
|
||||||
|
VS Code, you can install the
|
||||||
|
[code spell checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
|
||||||
|
extension to enable spell checking within your editor. Otherwise, you can
|
||||||
|
install [cspell](https://cspell.org/) separately.
|
||||||
|
|
||||||
|
If you want to make the spell checker ignore a word, you can add
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// spell-checker:ignore word_to_ignore
|
||||||
|
```
|
||||||
|
|
||||||
|
at the top of the file.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Testing can be done using either Cargo or `make`.
|
Testing can be done using either Cargo or `make`.
|
||||||
|
@ -225,15 +293,33 @@ uutils: add new utility
|
||||||
gitignore: add temporary files
|
gitignore: add temporary files
|
||||||
```
|
```
|
||||||
|
|
||||||
## cargo-deny
|
## Code coverage
|
||||||
|
|
||||||
This project uses [cargo-deny](https://github.com/EmbarkStudios/cargo-deny/) to
|
<!-- spell-checker:ignore (flags) Ccodegen Coverflow Cpanic Zinstrument Zpanic -->
|
||||||
detect duplicate dependencies, checks licenses, etc. To run it locally, first
|
|
||||||
install it and then run with:
|
|
||||||
|
|
||||||
|
Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov).
|
||||||
|
|
||||||
|
### Using Nightly Rust
|
||||||
|
|
||||||
|
To generate [gcov-based](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project) coverage report
|
||||||
|
|
||||||
|
```shell
|
||||||
|
export CARGO_INCREMENTAL=0
|
||||||
|
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
|
||||||
|
export RUSTDOCFLAGS="-Cpanic=abort"
|
||||||
|
cargo build <options...> # e.g., --features feat_os_unix
|
||||||
|
cargo test <options...> # e.g., --features feat_os_unix test_pathchk
|
||||||
|
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/
|
||||||
|
# open target/debug/coverage/index.html in browser
|
||||||
```
|
```
|
||||||
cargo deny --all-features check all
|
|
||||||
```
|
if changes are not reflected in the report then run `cargo clean` and run the above commands.
|
||||||
|
|
||||||
|
### Using Stable Rust
|
||||||
|
|
||||||
|
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
|
||||||
|
then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above.
|
||||||
|
|
||||||
|
|
||||||
## Other implementations
|
## Other implementations
|
||||||
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
# Documentation
|
|
||||||
|
|
||||||
The source of the documentation is available on:
|
|
||||||
|
|
||||||
<https://uutils.github.io/dev/coreutils/>
|
|
||||||
|
|
||||||
The documentation is updated everyday on this repository:
|
|
||||||
|
|
||||||
<https://github.com/uutils/uutils.github.io/>
|
|
||||||
|
|
||||||
## Running GNU tests
|
|
||||||
|
|
||||||
<!-- spell-checker:ignore gnulib -->
|
|
||||||
|
|
||||||
- Check out <https://github.com/coreutils/coreutils> next to your fork as gnu
|
|
||||||
- Check out <https://github.com/coreutils/gnulib> next to your fork as gnulib
|
|
||||||
- Rename the checkout of your fork to uutils
|
|
||||||
|
|
||||||
At the end you should have uutils, gnu and gnulib checked out next to each other.
|
|
||||||
|
|
||||||
- Run `cd uutils && ./util/build-gnu.sh && cd ..` to get everything ready (this may take a while)
|
|
||||||
- Finally, you can run tests with `bash uutils/util/run-gnu-test.sh <tests>`. Instead of `<tests>` insert the tests you want to run, e.g. `tests/misc/wc-proc.sh`.
|
|
||||||
|
|
||||||
## Code Coverage Report Generation
|
|
||||||
|
|
||||||
<!-- spell-checker:ignore (flags) Ccodegen Coverflow Cpanic Zinstrument Zpanic -->
|
|
||||||
|
|
||||||
Code coverage report can be generated using [grcov](https://github.com/mozilla/grcov).
|
|
||||||
|
|
||||||
### Using Nightly Rust
|
|
||||||
|
|
||||||
To generate [gcov-based](https://github.com/mozilla/grcov#example-how-to-generate-gcda-files-for-a-rust-project) coverage report
|
|
||||||
|
|
||||||
```shell
|
|
||||||
export CARGO_INCREMENTAL=0
|
|
||||||
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
|
|
||||||
export RUSTDOCFLAGS="-Cpanic=abort"
|
|
||||||
cargo build <options...> # e.g., --features feat_os_unix
|
|
||||||
cargo test <options...> # e.g., --features feat_os_unix test_pathchk
|
|
||||||
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/
|
|
||||||
# open target/debug/coverage/index.html in browser
|
|
||||||
```
|
|
||||||
|
|
||||||
if changes are not reflected in the report then run `cargo clean` and run the above commands.
|
|
||||||
|
|
||||||
### Using Stable Rust
|
|
||||||
|
|
||||||
If you are using stable version of Rust that doesn't enable code coverage instrumentation by default
|
|
||||||
then add `-Z-Zinstrument-coverage` flag to `RUSTFLAGS` env variable specified above.
|
|
||||||
|
|
||||||
## pre-commit hooks
|
|
||||||
|
|
||||||
A configuration for `pre-commit` is provided in the repository. It allows automatically checking every git commit you make to ensure it compiles, and passes `clippy` and `rustfmt` without warnings.
|
|
||||||
|
|
||||||
To use the provided hook:
|
|
||||||
|
|
||||||
1. [Install `pre-commit`](https://pre-commit.com/#install)
|
|
||||||
1. Run `pre-commit install` while in the repository directory
|
|
||||||
|
|
||||||
Your git commits will then automatically be checked. If a check fails, an error message will explain why, and your commit will be canceled. You can then make the suggested changes, and run `git commit ...` again.
|
|
||||||
|
|
||||||
## Using Clippy
|
|
||||||
|
|
||||||
The `msrv` key in the clippy configuration file `clippy.toml` is used to disable lints pertaining to newer features by specifying the minimum supported Rust version (MSRV). However, this key is only supported on `nightly`. To invoke clippy without errors, use `cargo +nightly clippy`. In order to also check tests and non-default crate features, use `cargo +nightly clippy --all-targets --all-features`.
|
|
||||||
|
|
||||||
## Markdown linter
|
|
||||||
|
|
||||||
We use <https://github.com/DavidAnson/markdownlint> to lint the Markdown files.
|
|
Loading…
Add table
Add a link
Reference in a new issue