Skip to content

Commit 272e6f9

Browse files
authored
feat(tests): add GitHub Actions workflow for automated testing and coverage reporting (#39)
1 parent b1e31cc commit 272e6f9

4 files changed

Lines changed: 77 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.9'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt
25+
pip install pytest pytest-cov coverage-badge
26+
27+
- name: Run tests with pytest and generate coverage
28+
run: |
29+
pytest --cov=penify_hook tests/ --cov-report=xml --cov-report=term
30+
31+
- name: Generate coverage badge
32+
run: |
33+
coverage-badge -o coverage.svg -f
34+
35+
- name: Commit coverage badge
36+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
37+
run: |
38+
git config --local user.email "action@github.com"
39+
git config --local user.name "GitHub Action"
40+
git add coverage.svg
41+
git diff --quiet && git diff --staged --quiet || git commit -m "Update coverage badge" -a
42+
43+
- name: Push coverage badge
44+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
45+
uses: ad-m/github-push-action@master
46+
with:
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
branch: ${{ github.ref }}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Penify CLI Tool
22

3+
![Tests](https://github.com/yourorganization/penify-cli/workflows/Tests/badge.svg)
4+
![Coverage](./coverage.svg)
5+
36
A CLI tool to generate smart commit messages, code documentation, and more.
47

8+
## Features
9+
10+
- Automatically generate documentation for your code
11+
- Support for multiple programming languages
12+
- Git hook integration for automatic documentation on commits
13+
- Folder and file analysis
14+
515
## Installation
616

717
Install from PyPI:
@@ -129,6 +139,12 @@ To set up the development environment:
129139
pip install -e .
130140
```
131141

142+
### Running Tests
143+
144+
```bash
145+
pytest
146+
```
147+
132148
## License
133149

134150
This project is licensed under the MIT License.

pytest.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[pytest]
2+
testpaths = tests
23
python_files = test_*.py
34
python_classes = Test*
45
python_functions = test_*
5-
testpaths = tests
6+
7+
# Coverage settings
8+
addopts = --cov=penify_hook --cov-report=term --cov-report=xml

requirements.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# requirements.txt
1+
# Basic requirements
2+
requests>=2.25.0
3+
gitpython>=3.1.0
4+
tqdm>=4.62.0
25

3-
requests
4-
GitPython
6+
# Testing requirements
7+
pytest>=7.0.0
8+
pytest-cov>=4.0.0
9+
coverage>=6.0.0
10+
coverage-badge>=1.1.0

0 commit comments

Comments
 (0)