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 787b007

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

File tree

11 files changed

+615
-401
lines changed

11 files changed

+615
-401
lines changed
 

‎.github/workflows/ci.yaml

+7-33
Original file line numberDiff line numberDiff line change
@@ -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/

‎.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

+90-22
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,111 @@
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:
10+
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+
```
31+
32+
4. **Verify your setup**:
33+
34+
```bash
35+
poetry run commitlint --version
36+
```
37+
38+
## Tests
39+
40+
Run tests
841

942
```bash
10-
pipenv install --dev
43+
poetry run pytest
1144
```
1245

13-
## Install pre-commit hooks
46+
Run tests with coverage
47+
48+
```bash
49+
poetry run pytest --cov=src
50+
```
1451

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

1754
```bash
18-
pipenv run install-hooks
55+
poetry run pytest --cov=src/ --cov-report=html
1956
```
2057

21-
## Run tests
58+
## Use pre-commit hook
2259

23-
Run the tests using the below command:
60+
Install pre-commit hook using the command below.
2461

2562
```bash
26-
pipenv run test
63+
poetry run pre-commit install --hook-type pre-commit --hook-type commit-msg
2764
```
2865

29-
## Before submitting
66+
## Pull Requests
67+
68+
We welcome and appreciate pull requests from the community. To contribute:
69+
70+
1. **Fork** the repository and create a new branch based on the `main` branch:
71+
72+
```bash
73+
git checkout -b <your-branch-name>
74+
```
75+
76+
2. **Write tests** for your changes if applicable.
77+
3. **Follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** for commit messages.
78+
Examples:
79+
80+
- `feat: add commit message validation`
81+
- `fix(parser): resolve message parsing issue`
82+
83+
4. **Push** your branch to your forked repository:
84+
85+
```bash
86+
git push origin <your-branch-name>
87+
```
88+
89+
5. **Create a Pull Request**:
90+
91+
- Open a pull request from your branch to the `main` branch of the original repository.
92+
- Provide a clear and concise description of the changes, along with relevant context.
93+
94+
6. **Review & Feedback**:
95+
96+
- Participate in the code review process and address any feedback promptly.
97+
98+
## License
99+
100+
By contributing to this project, you agree that your contributions will be licensed under the **GPL-3.0 License**.
101+
Refer to the [LICENSE](./LICENSE) file for more details.
30102

31-
Before submitting your Pull Request, please do the following steps:
103+
## Other Ways to Contribute
32104

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"`.
105+
Even if you don’t contribute code, you can still help:
38106

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

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.
111+
Thank you for contributing to **commitlint**! 🎉

‎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

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,54 @@
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+
"Sugat Bajracharya<sugatbajracharya49@gmail.com>"
8+
]
9+
license = "GPL-3.0"
10+
readme = "README.md"
11+
repository = "https://github.com/opensource-nepal/commitlint"
12+
homepage = "https://github.com/opensource-nepal/commitlint"
13+
keywords = [
14+
"commitlint", "commit lint", "python commitlint", "conventional commit",
15+
"conventional commit message", "python commit", "github actions", "pre-commit"
16+
]
17+
classifiers = [
18+
"Operating System :: OS Independent",
19+
"Programming Language :: Python",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
"Programming Language :: Python :: 3 :: Only"
25+
]
26+
packages = [{ include = "commitlint", from = "src" }]
27+
28+
[tool.poetry.urls]
29+
Changelog = "https://github.com/opensource-nepal/commitlint/blob/main/CHANGELOG.md"
30+
Issues = "https://github.com/opensource-nepal/commitlint/issues"
31+
32+
[tool.poetry.dependencies]
33+
python = ">=3.10"
34+
35+
[tool.poetry.group.dev.dependencies]
36+
ruff = "0.9.6"
37+
pre-commit = "4.1.0"
38+
39+
[tool.poetry.group.test.dependencies]
40+
pytest = "7.3.2"
41+
pytest-cov = "4.1.0"
42+
43+
[tool.poetry.scripts]
44+
commitlint = "commitlint.cli:main"
45+
146
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
47+
requires = ["poetry-core"]
48+
build-backend = "poetry.core.masonry.api"
49+
50+
[tool.pytest.ini_options]
51+
pythonpath = "src"
52+
testpaths = ["tests"]
53+
python_files = "test_*.py"
54+
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.