Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d5808a4

Browse files
committedFeb 19, 2025··
build: update build tool to poetry and use ruff for linting
1 parent 02e7ff4 commit d5808a4

12 files changed

+572
-406
lines changed
 

‎.github/workflows/ci.yaml

+8-34
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Github CI
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: ['main', 'poetry']
66
pull_request:
77

88
jobs:
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ['3.8']
14+
python-version: ['3.10']
1515

1616
steps:
1717
- uses: actions/checkout@v4
@@ -24,48 +24,22 @@ jobs:
2424
- name: Install Pipenv
2525
run: |
2626
python -m pip install --upgrade pip
27-
python -m pip install pipenv
27+
python -m pip install poetry
2828
2929
- name: Install dependencies
3030
run: |
31-
pipenv install --dev
31+
poetry install
32+
33+
- name: Run Lint
34+
uses: astral-sh/ruff-action@v3
3235

3336
- name: Run tests with coverage
3437
run: |
35-
pipenv run coverage-xml
38+
poetry run pytest --cov=src/ --cov-report=xml --no-cov-on-fail
3639
3740
- name: Send coverage to CodeCov
3841
uses: codecov/codecov-action@v3
3942
with:
4043
token: ${{ secrets.CODECOV_TOKEN }}
4144
fail_ci_if_error: false
4245
verbose: true
43-
44-
linting:
45-
runs-on: ubuntu-latest
46-
steps:
47-
- uses: actions/checkout@v4
48-
49-
- name: Set up Python
50-
uses: actions/setup-python@v5
51-
with:
52-
python-version: '3.8'
53-
54-
- name: Install lint dependencies
55-
run: pip install flake8 mypy isort
56-
57-
- name: flake8
58-
uses: liskin/gh-problem-matcher-wrap@v3
59-
with:
60-
linters: flake8
61-
run: flake8 --max-line-length=88 --ignore=E203,W503 src/
62-
- name: mypy
63-
uses: liskin/gh-problem-matcher-wrap@v3
64-
with:
65-
linters: mypy
66-
run: mypy --strict --show-column-numbers src/
67-
- name: isort
68-
uses: liskin/gh-problem-matcher-wrap@v3
69-
with:
70-
linters: isort
71-
run: isort --line-length=88 --check --profile black src/

‎.github/workflows/commitlint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Commitlint
22

33
on:
44
push:
5-
branches: ['main']
5+
branches: ['main', 'poetry']
66
pull_request:
77

88
jobs:

‎.pre-commit-config.yaml

+6-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
hooks:
44
- id: run-tests
55
name: Run tests
6-
entry: pipenv run test
6+
entry: poetry run pytest
77
language: system
88
pass_filenames: false
99

@@ -24,20 +24,9 @@ repos:
2424
- id: end-of-file-fixer
2525
- id: trailing-whitespace
2626

27-
- repo: https://github.com/akaihola/darker
28-
rev: 1.7.1
27+
- repo: https://github.com/astral-sh/ruff-pre-commit
28+
rev: v0.9.6
2929
hooks:
30-
- id: darker
31-
args:
32-
- --isort
33-
- --flynt
34-
- --lint=flake8 --max-line-length=88 --ignore=E203,W503
35-
- --lint=mypy --strict
36-
- --lint=pylint --max-line-length=88 --disable=W0511
37-
additional_dependencies:
38-
- black==23.3.0
39-
- flake8==5.0.4
40-
- flynt==0.77
41-
- isort==5.12.0
42-
- mypy==1.8.0
43-
- pylint==2.17.4
30+
- id: ruff
31+
args: [ --fix ]
32+
- id: ruff-format

‎CONTRIBUTING.md

+46-25
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,64 @@
1-
# How to Contribute
1+
# Contributing Guide
22

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

5-
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).
7+
## Prerequisites
68

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

9-
```bash
10-
pipenv install --dev
11-
```
11+
- **Python 3.10 or higher** installed. Download it from the [official Python website](https://www.python.org/downloads/).
12+
- **Poetry** installed for dependency management. Follow the [Poetry installation guide](https://python-poetry.org/docs/#installation).
13+
14+
## Getting Started
15+
16+
To set up the project on your local machine, follow these steps:
17+
18+
1. **Fork** the repository on GitHub.
19+
2. **Clone** the forked repository to your local machine:
20+
21+
```bash
22+
git clone https://github.com/<your-username>/commitlint.git
23+
cd commitlint
24+
```
25+
26+
3. **Install dependencies**:
27+
28+
```bash
29+
poetry install
30+
```
1231

13-
## Install pre-commit hooks
32+
4. **Verify your setup**:
1433

15-
To install pre-commit and commit-msg hook for this project, run the following command:
34+
```bash
35+
poetry run commitlint --version
36+
```
37+
38+
## Tests
39+
40+
Run tests
1641

1742
```bash
18-
pipenv run install-hooks
43+
poetry run pytest
1944
```
2045

21-
## Run tests
22-
23-
Run the tests using the below command:
46+
Run tests with coverage
2447

2548
```bash
26-
pipenv run test
49+
poetry run pytest --cov=src
2750
```
2851

29-
## Before submitting
52+
Generate html coverage
3053

31-
Before submitting your Pull Request, please do the following steps:
54+
```bash
55+
poetry run pytest --cov=src/ --cov-report=html
56+
```
3257

33-
1. Add any changes you want.
34-
1. Add tests for the new changes.
35-
1. Edit documentation (`README.md`) if you have changed something significant.
36-
1. Commit your changes using [semantic commit message](https://seesparkbox.com/foundry/semantic_commit_messages).
37-
Examples: `"fix: Fixed foobar bug"`, `"feat(accounts): Added foobar feature on accounts"`.
58+
## Use pre-commit hook
3859

39-
## Other help
60+
Install pre-commit hook using the command below.
4061

41-
You can contribute by spreading a word about this library.
42-
It would also be a huge contribution to write a short article on how you are using this project.
43-
You can also share your best practices with us.
62+
```bash
63+
poetry run pre-commit install --hook-type pre-commit --hook-type commit-msg
64+
```

‎Pipfile

-18
This file was deleted.

‎Pipfile.lock

-263
This file was deleted.

‎action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runs:
3333
- name: Install Python
3434
uses: actions/setup-python@v5.1.0
3535
with:
36-
python-version: '3.8'
36+
python-version: '3.10'
3737

3838
- name: Commitlint Action
3939
id: commitlint

‎poetry.lock

+455
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml

+52-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
[tool.poetry]
2+
name = "commitlint"
3+
version = "1.3.0" # x-release-please-version
4+
description = "commitlint is a pre-commit hook designed to lint your commit messages according to the Conventional Commits standard."
5+
authors = [
6+
"Ajesh Sen Thapa <aj3sshh@gmail.com>",
7+
]
8+
license = "GPL-3.0"
9+
readme = "README.md"
10+
repository = "https://github.com/opensource-nepal/commitlint"
11+
homepage = "https://github.com/opensource-nepal/commitlint"
12+
keywords = [
13+
"commitlint", "commit lint", "python commitlint", "conventional commit",
14+
"conventional commit message", "python commit", "github actions", "pre-commit"
15+
]
16+
classifiers = [
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"Programming Language :: Python :: 3 :: Only"
24+
]
25+
packages = [{ include = "src/commitlint" }]
26+
27+
[tool.poetry.urls]
28+
Changelog = "https://github.com/opensource-nepal/commitlint/blob/main/CHANGELOG.md"
29+
Issues = "https://github.com/opensource-nepal/commitlint/issues"
30+
31+
[tool.poetry.dependencies]
32+
python = ">=3.10"
33+
34+
[tool.poetry.group.dev.dependencies]
35+
ruff = "0.9.6"
36+
pre-commit = "4.1.0"
37+
38+
[tool.poetry.group.test.dependencies]
39+
pytest = "7.3.2"
40+
pytest-cov = "4.1.0"
41+
42+
[tool.poetry.scripts]
43+
commitlint = "commitlint.cli:main"
44+
145
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
46+
requires = ["poetry-core"]
47+
build-backend = "poetry.core.masonry.api"
48+
49+
[tool.pytest.ini_options]
50+
pythonpath = "src"
51+
testpaths = ["tests"]
52+
python_files = "test_*.py"
53+
addopts = "-vvv"

‎pytest.ini

-4
This file was deleted.

‎setup.cfg

-38
This file was deleted.

‎tests/test_github_actions/test_run/test_run_action.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test__run_action__calls_handle_push_events(mock_handle_push_event):
2929
run_action()
3030
mock_handle_push_event.assert_called_once()
3131
args, _ = mock_handle_push_event.call_args
32-
assert type(args[0]) == GitHubEvent
32+
assert isinstance(args[0], GitHubEvent)
3333
assert args[0].event_name == "push"
3434

3535

@@ -39,7 +39,7 @@ def test__run_action__calls_handle_pr_events(mock_handle_pr_event):
3939
run_action()
4040
mock_handle_pr_event.assert_called_once()
4141
args, _ = mock_handle_pr_event.call_args
42-
assert type(args[0]) == GitHubEvent
42+
assert isinstance(args[0], GitHubEvent)
4343
assert args[0].event_name == "pull_request"
4444

4545

@@ -51,7 +51,7 @@ def test__run_action__calls_handle_pr_events_for_pull_request_target(
5151
run_action()
5252
mock_handle_pr_event.assert_called_once()
5353
args, _ = mock_handle_pr_event.call_args
54-
assert type(args[0]) == GitHubEvent
54+
assert isinstance(args[0], GitHubEvent)
5555
assert args[0].event_name == "pull_request_target"
5656

5757

0 commit comments

Comments
 (0)
Please sign in to comment.