Skip to content

๐Ÿ› ๏ธ Contributing

Build Lint and Test codecov dependency status

The usual process to make a contribution is to:

  1. Check for existing related issues on GitHub
  2. Fork the repository and create a new branch
  3. Make your changes
  4. Make sure formatting, linting and tests passes.
  5. Add tests if possible to cover the lines you added.
  6. Commit, and send a Pull Request.

๐Ÿ“ฅ๏ธ Clone the repository

Clone the nanopub-rs repository, and cd into it:

git clone https://github.com/vemonet/nanopub-rs.git
cd nanopub-rs

โš™๏ธ Install dependencies

Rust, Python, and NodeJS are required for development.

Install development dependencies:

./scripts/install-dev.sh

๐Ÿงช Run tests

๐Ÿฆ€ Test Rust crate

Run tests for the rust crate:

cargo test

More options

Display prints:

cargo test -- --nocapture

Run a specific test:

cargo test sign_nanopub_blank -- --nocapture

If tests panic without telling on which test it failed:

cargo test -- --test-threads=1

Test the nanopub crate with code coverage (much slower):

cargo tarpaulin -p nanopub --out html

๐Ÿ Test Python package

Build the pip package and run pytest tests:

./scripts/test-python.sh

Or just run the tests:

source .venv/bin/activate
cd python
pytest

๐ŸŸจ Test JavaScript package

Build the npm package and run jest tests:

./scripts/test-js.sh

Start a web server to access the dev webpage:

python -m http.server 3000 --directory ./js

Open localhost:3000 in your web browser.

โŒจ๏ธ Test CLI

Test signing a nanopublication with the commandline interface:

cd cli
cargo run -- sign ../lib/tests/resources/nanopub_test_blank.trig

๐ŸŒˆ Run all tests

./scripts/test-all.sh

๐Ÿงผ Format & lint

Automatically format the codebase using rustfmt:

cargo fmt

Lint with clippy:

cargo clippy --all --all-targets --all-features

๐Ÿ“– Generate docs

Start docs website locally with mkdocs:

./scripts/docs.sh

๐ŸŽญ๏ธ Work on the demo webpage

Start a web server at localhost:3000/playground.html

python -m http.server 3000 --directory ./lib/docs

๏ธโ›“๏ธ Check supply chain

Check the dependency supply chain: licenses (only accept dependencies with OSI or FSF approved licenses), and vulnerabilities (CVE advisories).

cargo deny check

Make sure dependencies have been updated:

cargo update
cargo outdated

๐Ÿท๏ธ Publish a new release

Building and publishing artifacts will be done by the build.yml GitHub actions workflow, make sure you have set the following tokens as secrets for this repository: PYPI_TOKEN, NPM_TOKEN, CRATES_IO_TOKEN, CODECOV_TOKEN

Then just run the release script providing the new version following semantic versioning, it will bump the version in the Cargo.toml files, generate the changelog from commit messages, create a new tag, and push to GitHub:

./scripts/release.sh 0.0.2

Automated release

The build.yml workflow will automatically build artifacts (binaries, pip wheels, npm package), create a new release on GitHub, and add the generated artifacts to the new release.