From 8f13bf4e25c707ded5197fdb48b48f95b9a23e93 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Fri, 13 Sep 2024 09:44:04 -0400 Subject: [PATCH] chore: use commitizen to aid with releases --- .pre-commit-config.yaml | 5 ++ CONTRIBUTING.md | 105 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 5 ++ 3 files changed, 115 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1c5fb8..59c5103 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,3 +45,8 @@ repos: args: - --fix - --exit-non-zero-on-fix + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.4.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..e7afc9d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,105 @@ +Contributing to Simple Github +============================= + +Thanks for your interest in simple-github! To participate in this community, please +review our [code of conduct][0]. + +[0]: https://github.com/taskcluster/taskgraph/blob/main/CODE_OF_CONDUCT.md + +Clone the Repo +-------------- + +To contribute to simple-github, you'll need to clone the repository: + +``` +# first fork taskgraph +git clone https://github.com//simple-github +cd simple-github +git remote add upstream https://github.com/mozilla-releng/simple-github +``` + +Setting Up the Environment +-------------------------- + +We use a tool called [uv][1] to manage Taskgraph and its dependencies. First, +follow the [installation instructions][2]. + +Then run: + +``` +uv sync +``` + +This does several things: + +1. Creates a virtualenv for the project in a ``.venv`` directory (if necessary). +2. Syncs the project's dependencies as pinned in ``uv.lock`` (if necessary). +3. Installs ``simple-github`` as an editable package (if necessary). + +Now you can prefix commands with `uv run` and they'll have access to this +environment. + +[1]: https://docs.astral.sh/uv/ +[2]: https://docs.astral.sh/uv/getting-started/installation/ + +Running Tests +------------- + +Tests are run with the [pytest][3] framework: + +``` +uv run pytest +``` + +[3]: https://docs.pytest.org + +Running Checks +-------------- + +Linters and formatters are run via [pre-commit][4]. To install the hooks, run: + +``` +pre-commit install -t pre-commit -t commit-msg +``` + +Now checks will automatically run on every commit. If you prefer to run checks +manually, you can use: + +``` +pre-commit run +``` + +Most of the checks we enforce are done with [ruff][5]. See +[pre-commit-config.yaml][6] for a full list of linters and formatters. + +[4]: https://pre-commit.com/ +[5]: https://docs.astral.sh/ruff/ +[6]: https://github.com/taskcluster/taskgraph/blob/main/.pre-commit-config.yaml + +Releasing +--------- + +A tool called [commitizen][7] can be used to assist with releasing the package. First +install it with: + +``` +uv tool install commitizen +``` + +Then create the version bump commit: + +``` +cz changelog +cz bump +git show +``` + +Create a pull request and get the commit merged into `main`. Once merged, make sure +your tag is pushed upstream: + +``` +git push upstream --tags +``` + +Finally, create a release in Github, choosing the tag that you just pushed. +This will trigger the `pypi-publish` workflow and upload the package to pypi. diff --git a/pyproject.toml b/pyproject.toml index 8c0c7ff..b19edca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,11 @@ dev-dependencies = [ "tox~=4.11", ] +[tool.commitizen] +bump_message = "chore: version bump $new_version" +changelog_incremental = true +version_provider = "pep621" + [tool.black] line-length = 88