Skip to content

Latest commit

 

History

History
167 lines (123 loc) · 8.12 KB

CONTRIBUTING.md

File metadata and controls

167 lines (123 loc) · 8.12 KB

Contributing to Hydra

Thanks for considering contributing and help us on creating the Hydra protocols!

The best way to contribute right now is to try things out and provide feedback, but we also accept contributions to the documentation and the obviously to the code itself.

This document contains guidelines to help you get started and how to make sure your contribution gets accepted, making you our newest Hydra contributor!

Ask for help

See SUPPORT.md should you have any questions or need some help in getting set up.

Your first contribution

Contributing to the documentation, its translation, reporting bugs or proposing features are awesome ways to get started.

Documentation + translations

We host our documentation / user manual as a website here.

Each page has an "Edit this page" button which should take you to the source file containing the markup. Should you want to extend the documentation or find some errors, please file an issue pointing to the mistake or even better, create a pull request with the changes directly!

The documentation is also available in multiple languages and we can easily add more languages. If you want to extend, update or contribute a new translation make sure to check out the instructions in the docs component.

Bug reports

Submit an issue using the "Bug report 🐛" template. It's very important that you fill the template as thoroughly as possible.

Feature ideas

Feature ideas are precursors to high-level features items, which will be discussed and fleshed out to ideally become items on our feature roadmap.

We use the Ideas discussions category to discuss and vote on feature ideas, but you can also submit an issue using the "Feature idea 💭" template and we convert that to a discussion.

We expect a description of

  • why you (or the user) need/want something (e.g. problem, challenge, pain, benefit), and
  • what this is roughly about (e.g. description of a new API endpoint or message format).

Note that we do NOT require a detailed technical description, but are much more interested in why a feature is needed. This also helps in understanding the relevance and ultimately the priority of such an item.

Making changes

When contributing code, it helps to have discussed the rationale and (ideally) how something is implemented in a feature idea or bug ticket beforehand.

Building & Testing

We use and require nix to provide a consistent development environment via our flake.nix. So a simple call to nix develop should put everything in place for building, testing and general development.

Before that, make sure the following caches are listed in your nix.conf for a speedy setup and that you have activated flakes:

substituters = https://cache.iog.io https://cache.nixos.org
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
experimental-features = nix-command flakes

From there you can:

  • Build & run the hydra-node: cabal build hydra-node && cabal exec hydra-node -- --version
  • Build & run all tests: cabal test all
  • Build & run all benchmarks: cabal bench all
  • Run haskell-language-server for an IDE experience
  • Run hoogle for symbol & documentation lookup
  • Build the hydra-node using nix: nix build .#hydra-node
  • Build a statically linked hydra-node using nix: nix build .#hydra-node-static
  • Build the hydra-node docker image: nix build .#docker.hydra-node

Also, some of us use direnv and nix-direnv to automatically import the nix environment into our favorite shell or editor and not need explicit call to enter the nix shell.

Besides these general build instructions, some components might document additional steps and useful tools in their README.md files, e.g. the docs or the hydra-cluster

Coding standards

Make sure to follow our Coding Standards. It includes guidelines on Haskell code style, but also on Git commit messages and some processes (TODO: clarify separation or unify with these guidelines). To propose new standards or changes to the existing standards, file an issue.

Creating a pull request

Thank you for contributing your changes by opening a pull requests! To get something merged we usually require:

  • Description of the changes - if your commit messages are great, this is less important
  • Quality of changes is ensured - through new or updated automated tests
  • Change is related to an issue, feature (idea) or bug report - ideally discussed beforehand
  • Well-scoped - we prefer multiple PRs, rather than a big one

Updating dependencies

From Hackage

Updating package dependencies from Hackage should work like normal in a Haskell project. The most important thing to note is that we pin the index-state of the Hackage package index in cabal.project. This means that cabal will always see Hackage “as if” it was that time, ensuring reproducibility. But it also means that if you need a package version that was released after that time, you need to bump the index-state (and to run cabal update locally).

Because of how we use Nix to manage our Haskell build, whenever you do this you will also need to pull in the Nix equivalent of the newer index-state. You can do this by bumping the haskellNix to a newer tag in our default.nix.

From Cardano Haskell Packages (CHaP)

Many Cardano packages are not on Hackage and are instead in the Cardano Haskell Packages (CHaP) see the README for (lots) more information. Getting new packages from there works much like getting them from Hackage. The differences are that it has an independent index-state, and that there is the CHaP expression which you need to bump in the default.nix.

Using unreleased versions of dependencies

Sometimes we need to use an unreleased version of one of our dependencies, either to fix an issue in a package that is not under our control, or to experiment with a pre-release version of one of our own packages. You can use a source-repository-package stanza to pull in the unreleased version. Do this only for a short period of time, and try to get your changes released upstream. If that is (really) not possible, we can also release a patched version into CHap, see their README for instructions.

Versioning & Changelog

During development

  • Make sure CHANGELOG.md is kept up-to-date with high-level, technical, but user-focused list of changes according to keepachangelog
  • Bump UNRELEASED version in CHANGELOG.md according to semver
  • All hydra- packages are versioned the same, at latest on release their versions are aligned.
  • Other packages are versioned independently of hydra- packages and keep a dedicated changelog.

Releasing

To perform a release of next <version>

  • Check version to be released is also correct in software components, e.g. .cabal files.
  • Refer to <version> in deployment instructions, e.g. docker-compose.yaml files.
  • Replace UNRELEASED with a date in ISO8601
  • Create a signed, annotated git tag of the version: git tag -as <version>
    • Copy/paste this release CHANGELOG as annotation
  • Create a github release page containing
    • The released changes (formatted) and giving credit where credit is due
    • Attach static binaries to the release (or link the CI artifact)
    • Publish hydra scripts onto preview and pre-prod and include transaction ids (e.g. using the smoke test)