Skip to content

Commit 4444335

Browse files
authored
Add some contribution docs (#1214)
1 parent 90a7cea commit 4444335

3 files changed

Lines changed: 83 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Contributing to nu_scripts
2+
3+
Thanks for your interest in contributing to nu_scripts!
4+
5+
## Getting Started
6+
7+
1. **Fork** the repository on GitHub.
8+
2. **Clone** your fork locally.
9+
3. Create a **new branch** for your changes.
10+
11+
## Development Tools
12+
13+
We provide a `toolkit.nu` module to help with development and validation. You can load it in your shell:
14+
15+
```nu
16+
use toolkit.nu
17+
```
18+
19+
### validating your changes
20+
21+
Before submitting a Pull Request, please run the `check pr` command. This ensures your changes meet our standards and pass all tests.
22+
23+
```nu
24+
toolkit check pr
25+
```
26+
27+
By default, this command acts on **changed files only** (files different from `origin/main`).
28+
29+
### Linting
30+
31+
You can run the linter separately if needed:
32+
33+
```nu
34+
toolkit lint
35+
```
36+
37+
#### check options
38+
39+
Both `check pr` and `lint` support the following flags:
40+
41+
- `--full`: Check **all** files in the repository, not just changed ones.
42+
- `--and-exit`: Exit with a non-zero exit code if errors are found (useful for CI scripts).
43+
44+
## Testing
45+
46+
While `toolkit check pr` performs linting, it does not currently run logic tests (`toolkit test` is not yet implemented).
47+
48+
If your contribution involves complex logic (e.g., parsing helpers, new modules), we encourage you to create a test script to verify it. You can use the standard library's `std/assert` module for this.
49+
50+
**Note**: Functions and aliases in `.nu` files are not added to the global namespace unless explicitly `source`d or `use`d, so adding test files is safe.
51+
52+
Example `modules/my_feature/tests/test_my_feature.nu`:
53+
```nu
54+
use std/assert
55+
use ../my_feature.nu
56+
57+
#[test]
58+
def "feature works as expected" [] {
59+
assert equal (my_feature "input") "expected output"
60+
}
61+
```
62+
63+
You can run these tests manually:
64+
```nu
65+
nu modules/my_feature/tests/test_my_feature.nu
66+
```
67+
68+
## Submitting a Pull Request
69+
70+
1. Push your changes to your fork.
71+
2. Open a Pull Request against the `main` branch of `nushell/nu_scripts`.
72+
3. Ensure the CI checks pass.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This is a place to share Nushell scripts with each other. If you'd like to share your scripts, fork this repository, and [create a PR](https://github.com/nushell/nu_scripts/compare) that adds it to the repo.
44

5+
Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to test and validate your changes before sending a PR.
6+
57
## Sections
68

79
- [aliases](./aliases/)

toolkit.nu

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ export def "check pr" [
3434
}
3535
}
3636

37+
38+
3739
# View subcommands.
40+
#
41+
# Available subcommands:
42+
# check pr - Run all the necessary checks and tests to submit a perfect PR.
43+
# lint - Check that all the files parse.
44+
# test - Check that all the tests pass.
3845
export def main []: nothing -> string {
3946
help toolkit
4047
}
@@ -66,10 +73,10 @@ def "with files" [
6673
}
6774
}
6875

69-
export def "lint check" []: path -> int {
76+
def "lint check" []: path -> int {
7077
let file = $in
7178
let test_methodology = $env.TEST_METHOD? | default "import-or-source"
72-
const current_path = (path self)
79+
7380

7481
let diagnostics = match $test_methodology {
7582
"ide-check" => {

0 commit comments

Comments
 (0)