Skip to content

Commit ef10932

Browse files
committed
Add formatters, configs and pre-commit hook. Modify ci_pileline
1 parent b95b98d commit ef10932

File tree

6 files changed

+317
-10
lines changed

6 files changed

+317
-10
lines changed

.editorconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.{py,rst,ini,json,sh}]
11+
indent_style = space
12+
indent_size = 4
13+
14+
[*.py]
15+
line_length=120
16+
known_first_party=cover_agent,tests_integration
17+
multi_line_output=3
18+
default_section=THIRDPARTY
19+
20+
[*.{html,css,scss,js}]
21+
indent_style = space
22+
indent_size = 2
23+
24+
[*.yml]
25+
indent_style = space
26+
indent_size = 2
27+
28+
[*.md]
29+
trim_trailing_whitespace = false
30+
31+
[Makefile]
32+
indent_style = tab
33+
34+
[makefile-local]
35+
indent_style = tab

.github/workflows/ci_pipeline.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ jobs:
3535
- uses: actions/checkout@v2
3636
with:
3737
fetch-depth: 0 # Ensures we fetch all history for all branches
38+
3839
- name: Set up Python
3940
uses: actions/setup-python@v2
4041
with:
4142
python-version: '3.12'
42-
43+
4344
# Step to cache Poetry dependencies
4445
- name: Cache Poetry dependencies
4546
uses: actions/cache@v4
@@ -53,18 +54,28 @@ jobs:
5354
5455
- name: Install Poetry
5556
run: pip install poetry
57+
5658
- name: Install dependencies using Poetry
5759
run: poetry install
60+
61+
- name: Check import sorting with isort
62+
run: poetry run isort --check-only --diff .
63+
64+
- name: Check code formatting with black
65+
run: poetry run black --check .
66+
5867
- name: Run tests and generate reports
5968
env:
6069
OPENAI_API_KEY: "This_is_a_fake_API_key"
6170
run: make test
71+
6272
- name: Upload test report
6373
uses: actions/upload-artifact@v4
6474
if: always()
6575
with:
6676
name: test-reports
6777
path: testLog.xml
78+
6879
- name: Upload coverage report
6980
uses: actions/upload-artifact@v4
7081
if: always()
@@ -84,7 +95,7 @@ jobs:
8495
uses: actions/setup-python@v2
8596
with:
8697
python-version: '3.12'
87-
98+
8899
# Step to cache Poetry dependencies
89100
- name: Cache Poetry dependencies
90101
uses: actions/cache@v4
@@ -105,7 +116,7 @@ jobs:
105116
poetry build
106117
pip install dist/*.whl
107118
cd /tmp
108-
cover-agent --help
119+
cover-agent --help
109120
110121
build:
111122
needs: [test, changes]
@@ -121,7 +132,7 @@ jobs:
121132
uses: actions/setup-python@v2
122133
with:
123134
python-version: '3.12'
124-
135+
125136
# Step to cache Poetry dependencies
126137
- name: Cache Poetry dependencies
127138
uses: actions/cache@v4
@@ -215,7 +226,7 @@ jobs:
215226
# - There are relevant changes outside 'README.md' and the 'docs/' folder
216227
needs: [build, changes, e2e-test]
217228
if: >
218-
github.event_name == 'push' &&
229+
github.event_name == 'push' &&
219230
github.ref == 'refs/heads/main' &&
220231
needs.changes.outputs.version_changed == 'true' &&
221232
needs.changes.outputs.relevant_changes == 'true'

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 25.1.0
4+
hooks:
5+
- id: black
6+
language_version: python3.12
7+
args: ["--check"]
8+
exclude: ^(templated_tests|cover_agent/lsp_logic)/
9+
10+
- repo: https://github.com/pycqa/isort
11+
rev: 6.0.1
12+
hooks:
13+
- id: isort
14+
args: ["--check-only", "--diff"]
15+
exclude: ^(templated_tests|cover_agent/lsp_logic)/

docs/pre_commit_hook.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## qodo-cover: Pre-commit hooks #
2+
3+
To run additional checks before making commit we use [Pre-commit](https://pre-commit.com/) hooks.
4+
5+
`pre-commit` package is installed with backend requirements, so there is no need of [manual installation](https://pre-commit.com/#install).
6+
But you need to generate the actual git pre-commit hook. It should be done only once during the project setup:
7+
8+
```bash
9+
poetry run pre-commit install
10+
```
11+
12+
Keep in mind, code formatters are configured separately for the pre-commit hook in the `.pre-commit-config.yaml` file. Pre-commit runs tools on staged files, not as part of your project that's why it requires a separate configuration. However it should be synced with those settings in `pyproject.toml` file.
13+
14+
15+
### Usage
16+
To run pre-commit hooks manually:
17+
18+
```bash
19+
poetry run pre-commit run --all-files
20+
```
21+
22+
Check staged files only:
23+
```bash
24+
poetry run pre-commit run
25+
```
26+
27+
To run specific hook:
28+
29+
```bash
30+
poetry run pre-commit run <hook_id>
31+
```
32+
33+
See more info in official documentation:
34+
35+
* [Usage](https://pre-commit.com/#usage)
36+
* [Adding new hooks](https://pre-commit.com/#plugins)

0 commit comments

Comments
 (0)