From 67da71681c5f95c29c8161c887f0eb4e63acecc6 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 5 Nov 2024 10:14:42 +0000 Subject: [PATCH 1/2] docs: add development doc --- DEVELOPMENT.md | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ justfile | 2 +- 2 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 000000000..956ba5ed8 --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,152 @@ +# Development Guide + +This guide will help you set up your development environment for working with the CDK repository. + +## Prerequisites + +Before you begin, ensure you have: +- Git installed on your system +- GitHub account +- Basic familiarity with command line operations + +## Initial Setup + +### 1. Fork and Clone the Repository + +1. Navigate to the CDK repository on GitHub +2. Click the "Fork" button in the top-right corner +3. Clone your forked repository: +```bash +git clone https://github.com/YOUR-USERNAME/cdk.git +cd cdk +``` + +### 2. Install Nix + + + +CDK uses [Nix](https://nixos.org/explore.html) for building, CI, and managing dev environment. +Note: only `Nix` (the language & package manager) and not the NixOS (the Linux distribution) is needed. +Nix can be installed on any Linux distribution and macOS. + +While it is technically possible to not use Nix, it is highly recommended as +it ensures consistent and reproducible environment for all developers. + +### Install Nix + +You have 2 options to install nix: + +* **RECOMMENDED:** The [Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer) +* [The official installer](https://nixos.org/download.html) + +Example: + +``` +> nix --version +nix (Nix) 2.9.1 +``` + +The exact version might be different. + +### Enable nix flakes + +If you installed Nix using the "determinate installer" you can skip this step. If you used the "official installer", edit either `~/.config/nix/nix.conf` or `/etc/nix/nix.conf` and add: + +``` +experimental-features = nix-command flakes +``` + +If the Nix installation is in multi-user mode, don’t forget to restart the nix-daemon. + +## Use Nix Shell + +```sh + nix develop -c $SHELL +``` + +## Common Development Tasks + +### Building the Project +```sh +just build +``` + +### Running Unit Tests +```bash +just test +``` + +### Running Integration Tests +```bash +just itest REDB/SQLITE/MEMEORY +``` + +### Running Format +```bash +just format +``` + + +### Running Clippy +```bash +just clippy +``` + +### Running final check before commit +```sh +just final-check +``` + + +## Best Practices + +1. **Branch Management** + - Create feature branches from `main` + - Use descriptive branch names: `feature/new-feature` or `fix/bug-description` + +2. **Commit Messages** + - Follow conventional commits format + - Begin with type: `feat:`, `fix:`, `docs:`, `chore:`, etc. + - Provide clear, concise descriptions + +3. **Testing** + - Write tests for new features + - Ensure all tests pass before submitting PR + - Include integration tests where applicable + +## Troubleshooting + +### Common Issues + +1. **Development Shell Issues** + - Clean Nix store: `nix-collect-garbage -d` + - Remove and recreate development shell + +### Getting Help + +- Open an issue on GitHub +- Check existing issues for similar problems +- Include relevant error messages and system information +- Reach out in Discord [Invite link](https://discord.gg/tUxMKd5YjN) + +## Contributing + +1. Create a feature branch +2. Make your changes +3. Run tests and formatting +4. Submit a pull request +5. Wait for review and address feedback + +## Additional Resources + +- [Nix Documentation](https://nixos.org/manual/nix/stable/) +- [Contributing Guidelines](CONTRIBUTING.md) + +## License + +Refer to the LICENSE file in the repository for terms of use and distribution. diff --git a/justfile b/justfile index 552d46e68..4e36977ed 100644 --- a/justfile +++ b/justfile @@ -45,7 +45,7 @@ test: build if [ ! -f Cargo.toml ]; then cd {{invocation_directory()}} fi - cargo test + cargo test --lib # run `cargo clippy` on everything clippy *ARGS="--locked --offline --workspace --all-targets": From 2f7e99f0e6d6f5a3cd555a3568af531efcfd3edf Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 5 Nov 2024 10:19:29 +0000 Subject: [PATCH 2/2] docs: Update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 174184b22..47eb1b770 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ The project is split up into several crates in the `crates/` directory: | [16][16] | Animated QR codes | :x: | | [17][17] | WebSocket subscriptions | :construction: | -MSRV ## Bindings @@ -75,6 +74,9 @@ All contributions welcome. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions. +Please see the [development guide](DEVELOPMENT.md). + + [00]: https://github.com/cashubtc/nuts/blob/main/00.md [01]: https://github.com/cashubtc/nuts/blob/main/01.md [02]: https://github.com/cashubtc/nuts/blob/main/02.md