Skip to content

Commit

Permalink
build: update build tool to poetry and use ruff for linting (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
aj3sh authored Feb 27, 2025
1 parent 02e7ff4 commit 94575ce
Show file tree
Hide file tree
Showing 11 changed files with 615 additions and 401 deletions.
40 changes: 7 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8']
python-version: ['3.10']

steps:
- uses: actions/checkout@v4
Expand All @@ -24,48 +24,22 @@ jobs:
- name: Install Pipenv
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
python -m pip install poetry
- name: Install dependencies
run: |
pipenv install --dev
poetry install
- name: Run Lint
uses: astral-sh/ruff-action@v3

- name: Run tests with coverage
run: |
pipenv run coverage-xml
poetry run pytest --cov=src/ --cov-report=xml --no-cov-on-fail
- name: Send coverage to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true

linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'

- name: Install lint dependencies
run: pip install flake8 mypy isort

- name: flake8
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: flake8
run: flake8 --max-line-length=88 --ignore=E203,W503 src/
- name: mypy
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: mypy
run: mypy --strict --show-column-numbers src/
- name: isort
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: isort
run: isort --line-length=88 --check --profile black src/
23 changes: 6 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
hooks:
- id: run-tests
name: Run tests
entry: pipenv run test
entry: poetry run pytest
language: system
pass_filenames: false

Expand All @@ -24,20 +24,9 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/akaihola/darker
rev: 1.7.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: darker
args:
- --isort
- --flynt
- --lint=flake8 --max-line-length=88 --ignore=E203,W503
- --lint=mypy --strict
- --lint=pylint --max-line-length=88 --disable=W0511
additional_dependencies:
- black==23.3.0
- flake8==5.0.4
- flynt==0.77
- isort==5.12.0
- mypy==1.8.0
- pylint==2.17.4
- id: ruff
args: [ --fix ]
- id: ruff-format
112 changes: 90 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,111 @@
# How to Contribute
# Contributing Guide

## Install Development Dependencies (Using Pipenv)
Thank you for your interest in contributing to the **commitlint** project!
Your contributions will help improve and enhance this tool.
Please take a moment to review the following guidelines before getting started.

All the dependencies are managed by Pipenv. Please install Pipenv on your system first by following the instructions at [https://pipenv.pypa.io/en/latest/installation.html](https://pipenv.pypa.io/en/latest/installation.html).
## Prerequisites

Once Pipenv is installed, you can install the development dependencies by running the following command:
Before contributing, ensure that you have the following:

- **Python 3.10 or higher** installed. Download it from the [official Python website](https://www.python.org/downloads/).
- **Poetry** installed for dependency management. Follow the [Poetry installation guide](https://python-poetry.org/docs/#installation).

## Getting Started

To set up the project on your local machine, follow these steps:

1. **Fork** the repository on GitHub.
2. **Clone** the forked repository to your local machine:

```bash
git clone https://github.com/<your-username>/commitlint.git
cd commitlint
```

3. **Install dependencies**:

```bash
poetry install
```

4. **Verify your setup**:

```bash
poetry run commitlint --version
```

## Tests

Run tests

```bash
pipenv install --dev
poetry run pytest
```

## Install pre-commit hooks
Run tests with coverage

```bash
poetry run pytest --cov=src
```

To install pre-commit and commit-msg hook for this project, run the following command:
Generate html coverage

```bash
pipenv run install-hooks
poetry run pytest --cov=src/ --cov-report=html
```

## Run tests
## Use pre-commit hook

Run the tests using the below command:
Install pre-commit hook using the command below.

```bash
pipenv run test
poetry run pre-commit install --hook-type pre-commit --hook-type commit-msg
```

## Before submitting
## Pull Requests

We welcome and appreciate pull requests from the community. To contribute:

1. **Fork** the repository and create a new branch based on the `main` branch:

```bash
git checkout -b <your-branch-name>
```

2. **Write tests** for your changes if applicable.
3. **Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** for commit messages.
Examples:

- `feat: add commit message validation`
- `fix(parser): resolve message parsing issue`

4. **Push** your branch to your forked repository:

```bash
git push origin <your-branch-name>
```

5. **Create a Pull Request**:

- Open a pull request from your branch to the `main` branch of the original repository.
- Provide a clear and concise description of the changes, along with relevant context.

6. **Review & Feedback**:

- Participate in the code review process and address any feedback promptly.

## License

By contributing to this project, you agree that your contributions will be licensed under the **GPL-3.0 License**.
Refer to the [LICENSE](./LICENSE) file for more details.

Before submitting your Pull Request, please do the following steps:
## Other Ways to Contribute

1. Add any changes you want.
1. Add tests for the new changes.
1. Edit documentation (`README.md`) if you have changed something significant.
1. Commit your changes using [semantic commit message](https://seesparkbox.com/foundry/semantic_commit_messages).
Examples: `"fix: Fixed foobar bug"`, `"feat(accounts): Added foobar feature on accounts"`.
Even if you don’t contribute code, you can still help:

## Other help
- **Spread the word** about this tool.
- Write a blog or article about how you use this project.
- Share your best practices, examples, or ideas with us.

You can contribute by spreading a word about this library.
It would also be a huge contribution to write a short article on how you are using this project.
You can also share your best practices with us.
Thank you for contributing to **commitlint**! 🎉
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

Loading

0 comments on commit 94575ce

Please sign in to comment.