Skip to content

Latest commit

 

History

History
195 lines (123 loc) · 10.1 KB

CONTRIBUTING.md

File metadata and controls

195 lines (123 loc) · 10.1 KB

Contributing

Hi! Thanks for considering contributing to ckanext-nhm. 🦕

We welcome suggestions, bug reports, and code or documentation changes. This document will give you a quick overview of how to make one of these contributions.

If you're completely new to Git, GitHub, or contributing to open source, you might find it helpful to read some other material first, like W3's Git Tutorial, GitHub Quickstart, or How to Contribute to Open Source. This document does assume some familiarity with these concepts for brevity, but we're happy to help anyone who's new or needs further clarification.

Quick links

Table of contents

  1. Introduction
  2. Questions
  3. Suggestions and bug reports
  4. Commits and pull requests
    1. Commits
    2. Code changes and style guide
    3. Documentation changes

Introduction

Code of Conduct

We have a Code of Conduct, which all contributors and community participants are expected to adhere to.

About this repository

This repository contains the code for an extension/plugin for a larger system called CKAN; it is not a standalone project.

Official maintainers

This extension and several others are maintained by the Data Portal team at the Natural History Museum, London. This is a very small team, so contributions are very welcome!

The current core team consists of:

Questions

Before asking your question, have you checked:

If none of those answer your question, try contacting us before raising it as an issue on GitHub. You can find places to contact us in SUPPORT.md.

Suggestions and bug reports

Suggestions, feature requests, and bug reports are all submitted as GitHub issues.

See GitHub's documentation for the basics on how to create an issue. Before you create an issue, please check the existing issues to see if it's already been raised.

Good bug reports

We've provided a template for bug reports. It's not 100% necessary to follow this template exactly, but it does demonstrate the kind of information that will be useful to anyone trying to fix the problem. The most key information is anything that will allow someone to try and recreate your issue on their own system.

Good feature suggestions

We've also provided a template for feature suggestions. This is fairly sparse, and again isn't completely necessary to follow exactly. Please just try to provide as much information about your idea as possible.

Commits and pull requests

If you want to contribute a change to any of the files in the repository, whether it's code, documentation, or repository meta files like .gitignore, you'll need to make commits and pull requests.

The process is generally as follows:

  1. Fork the repository.
  2. Create a new branch to work on by branching off dev. We name ours in the format user/feature-name, e.g. ginger/deprecate-ckanpackager. Try to only work on one topic (e.g. implementing one feature, or fixing a couple of related bugs) per branch.
  3. Make your changes, and commit often; each commit should only contain one change. See below for specifics on how to word your commits.
  4. Push your changes back to your fork.
  5. Open a pull request in this repository, with the base branch set to dev and the compare branch set to your new branch. Provide a summary of your changes in the description.
  6. If the automatic tests fail (these may take a while), please go back to your code and try to make them pass. You may have to update the tests themselves. You don't have to close the pull request while you're doing this; it'll update as you add further commits.
  7. Wait for feedback from one of the core maintainers. If it's been a week or so and we haven't responded, we may not have seen it. You can find other places to contact us in SUPPORT.md.

Commits

Our commits follow the Conventional Commits style for consistency and to make it easy to generate changelogs. Please follow this style when you make your commits. We have our own slightly tweaked version of the default style called cz-nhm. It's very similar with just a few additions.

Commits are formatted as follows - not every line is required:

<type>(<scope>): <subject>
<BLANK LINE>
BREAKING CHANGE: <subject>
<BLANK LINE>
<body>
<BLANK LINE>
Closes: <issues>

e.g.

fix(actions): write a short lowercase description of what you did

Give a bit more context or detail about the changes.

Closes: #1, #3

Or, a very basic but still completely valid commit:

feat: add an exciting new feature

The tools described below are very useful for generating these messages and sticking to the structure, so we highly recommend using them.

Tools

We use a few tools to help us with code standardisation and keeping to the conventional commits style. When making a commit, the two key tools to know about are:

  1. commitizen
  2. pre-commit

Both tools are Python-based and can be installed with pip. You'll probably want to use something like pipx or venv instead of installing them globally, but for simplicity, the instructions below are just for pip.

commitizen

commitizen is a CLI tool for creating commits in the conventional commits style.

To install with pip:

# NB: cz-nhm must be installed in the same environment as commitizen
pip install commitizen cz-nhm

Then to make a commit:

cz c
# and follow the prompts
pre-commit

pre-commit is a tool that runs a variety of checks and modifications before a commit is made. You can check the .pre-commit-config.yaml file to see eaxtly what it's currently configured to do for this repository, but of particular note:

  • reformats Python code with Black
  • reformats JavaScript and stylesheets with Prettier
  • reformats docstrings with docformatter
  • checks your commit message is correcly formatted

To install with pip:

pip install pre-commit

When installed, the checks will be run on all staged files when you try to make a commit. If any of them fail or make any modifications, the commit will be abandoned and you will have to write the message again. Because of this, it's probably best to run the checks on the staged files manually before you even attempt a commit:

pre-commit run

Don't forget to stage any modifications that it makes! Once it runs without failing, then you can make your commit.

Something to remember is that empty docstrings will cause conflicts between Black and docformatter and the checks will fail repeatedly - so don't leave your docstrings empty!

Code changes and style guide

We generally use external style guides and tools to help us maintain standardised code. Black and Prettier will be run with pre-commit.

Python

We follow the Black style, with the notable exception that we use single quotes.

We also mostly use CKAN's style, with the following exceptions:

  • prefer f'' strings over .format()
  • don't use u'' strings
  • use double quotes for docstrings, not single quotes

JavaScript and stylesheets (CSS, LESS, etc)

We use Prettier to format these files.

Accessibility

Particularly if you're making frontend changes such as modifying HTML, please make sure your changes meet level AA of the Web Content Accessibility Guidelines (WCAG).

Documentation changes

Our documentation is generated using MkDocs, then hosted on Read the Docs. You can view the current documentation for this repository at ckanext-nhm.readthedocs.io.

Most of the documentation for this repository is generated automatically by pulling docstrings from the Python code. This documentation is placed in the "API" subfolder in the rendered output.

There are also a few pages written as standalone .md files, e.g. configuration.md, or as a subfolder, e.g. usage. You can also edit these or create new pages. In most of our extensions these are still very sparse or automatically generated from content in the README, but the extension ckanext-versioned-datastore has a good example of more complex documentation.

Once you've made your changes, follow the commit and pull request guidelines as you would for a code change. You will almost certainly be using the docs: commit prefix.