Skip to content

Commit f2dc866

Browse files
committed
Added comprehensive unit tests
1 parent a943927 commit f2dc866

33 files changed

+4413
-84
lines changed

.bandit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[bandit]
2+
# Bandit configuration file
3+
exclude_dirs = ['tests', 'build', 'dist', '.git', '.tox', '.venv', '__pycache__']
4+
5+
# Skip certain tests that may be too strict for this project
6+
skips = ['B101', 'B601']
7+
8+
# B101: Test for use of assert
9+
# B601: Test for shell injection within Paramiko
10+
11+
[bandit.assert_used]
12+
# Allow assert statements in test files
13+
skips = ['*test*.py', '*tests*.py']
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Bug Description
10+
11+
A clear and concise description of what the bug is.
12+
13+
## To Reproduce
14+
15+
Steps to reproduce the behavior:
16+
1. Go to '...'
17+
2. Click on '....'
18+
3. Scroll down to '....'
19+
4. See error
20+
21+
## Expected Behavior
22+
23+
A clear and concise description of what you expected to happen.
24+
25+
## Actual Behavior
26+
27+
A clear and concise description of what actually happened.
28+
29+
## Environment
30+
31+
- OS: [e.g. Ubuntu 20.04, macOS 12.0, Windows 10]
32+
- Python version: [e.g. 3.9.7]
33+
- himl version: [e.g. 0.17.0]
34+
- Installation method: [e.g. pip, conda, from source]
35+
36+
## Configuration Files
37+
38+
If applicable, add sample configuration files that reproduce the issue.
39+
40+
```yaml
41+
# Example config that causes the issue
42+
```
43+
44+
## Error Messages
45+
46+
If applicable, add the full error message and stack trace.
47+
48+
```
49+
Paste error message here
50+
```
51+
52+
## Additional Context
53+
54+
Add any other context about the problem here.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Description
10+
11+
A clear and concise description of what you want to happen.
12+
13+
## Problem Statement
14+
15+
Is your feature request related to a problem? Please describe.
16+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
17+
18+
## Proposed Solution
19+
20+
Describe the solution you'd like.
21+
A clear and concise description of what you want to happen.
22+
23+
## Alternatives Considered
24+
25+
Describe alternatives you've considered.
26+
A clear and concise description of any alternative solutions or features you've considered.
27+
28+
## Use Case
29+
30+
Describe your use case and how this feature would help.
31+
32+
## Implementation Ideas
33+
34+
If you have ideas about how this could be implemented, please share them here.
35+
36+
## Additional Context
37+
38+
Add any other context or screenshots about the feature request here.

.github/pull_request_template.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Description
2+
3+
Brief description of the changes in this PR.
4+
5+
## Type of Change
6+
7+
- [ ] Bug fix (non-breaking change which fixes an issue)
8+
- [ ] New feature (non-breaking change which adds functionality)
9+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
- [ ] Documentation update
11+
- [ ] Code refactoring
12+
- [ ] Performance improvement
13+
- [ ] Test improvement
14+
15+
## Testing
16+
17+
- [ ] Tests pass locally with my changes
18+
- [ ] I have added tests that prove my fix is effective or that my feature works
19+
- [ ] New and existing unit tests pass locally with my changes
20+
- [ ] I have tested the changes manually
21+
22+
## Checklist
23+
24+
- [ ] My code follows the style guidelines of this project
25+
- [ ] I have performed a self-review of my own code
26+
- [ ] I have commented my code, particularly in hard-to-understand areas
27+
- [ ] I have made corresponding changes to the documentation
28+
- [ ] My changes generate no new warnings
29+
- [ ] Any dependent changes have been merged and published in downstream modules
30+
31+
## Additional Notes
32+
33+
Add any additional notes, concerns, or context about the changes here.

.github/workflows/ci.yaml

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
FORCE_COLOR: 1
12+
13+
jobs:
14+
test:
15+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os: [ubuntu-latest]
21+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
32+
- name: Get pip cache dir
33+
id: pip-cache
34+
run: |
35+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
36+
37+
- name: Cache pip dependencies
38+
uses: actions/cache@v3
39+
with:
40+
path: ${{ steps.pip-cache.outputs.dir }}
41+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml', '**/tests/requirements.txt') }}
42+
restore-keys: |
43+
${{ runner.os }}-pip-${{ matrix.python-version }}-
44+
${{ runner.os }}-pip-
45+
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install --upgrade pip setuptools wheel
49+
pip install -e .[dev]
50+
51+
- name: Lint with flake8
52+
run: |
53+
# Stop the build if there are Python syntax errors or undefined names
54+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
55+
# Exit-zero treats all errors as warnings
56+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
57+
58+
- name: Type check with mypy
59+
run: |
60+
mypy himl/ --ignore-missing-imports
61+
62+
- name: Run tests with pytest
63+
run: |
64+
python -m pytest tests/ -v --tb=short --cov=himl --cov-report=xml --cov-report=term-missing --cov-fail-under=80
65+
66+
- name: Upload coverage to Codecov
67+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14'
68+
uses: codecov/codecov-action@v3
69+
with:
70+
file: ./coverage.xml
71+
flags: unittests
72+
name: codecov-umbrella
73+
fail_ci_if_error: false
74+
75+
security:
76+
name: Security checks
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Set up Python
83+
uses: actions/setup-python@v4
84+
with:
85+
python-version: '3.14'
86+
87+
- name: Install security tools
88+
run: |
89+
python -m pip install --upgrade pip
90+
pip install bandit[toml] safety
91+
92+
- name: Run security checks with bandit
93+
run: |
94+
bandit -r himl/ -f json -o bandit-report.json || true
95+
bandit -r himl/ --severity-level medium
96+
97+
- name: Check dependencies for known security vulnerabilities
98+
run: |
99+
pip install -e .
100+
safety check --json --output safety-report.json || true
101+
safety check
102+
103+
- name: Upload security reports
104+
if: always()
105+
uses: actions/upload-artifact@v3
106+
with:
107+
name: security-reports
108+
path: |
109+
bandit-report.json
110+
safety-report.json
111+
112+
build:
113+
name: Build package
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Checkout code
117+
uses: actions/checkout@v4
118+
with:
119+
fetch-depth: 0 # Needed for setuptools_scm
120+
121+
- name: Set up Python
122+
uses: actions/setup-python@v4
123+
with:
124+
python-version: '3.14'
125+
126+
- name: Install build dependencies
127+
run: |
128+
python -m pip install --upgrade pip
129+
pip install build twine
130+
131+
- name: Build package
132+
run: |
133+
python -m build
134+
135+
- name: Check package
136+
run: |
137+
twine check dist/*
138+
139+
- name: Test package installation
140+
run: |
141+
pip install dist/*.whl
142+
himl --help
143+
himl-config-merger --help
144+
145+
- name: Upload build artifacts
146+
uses: actions/upload-artifact@v3
147+
with:
148+
name: dist-${{ github.sha }}
149+
path: dist/
150+
retention-days: 30
151+
152+
integration:
153+
name: Integration tests
154+
runs-on: ubuntu-latest
155+
needs: [test, build]
156+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
157+
steps:
158+
- name: Checkout code
159+
uses: actions/checkout@v4
160+
161+
- name: Set up Python
162+
uses: actions/setup-python@v4
163+
with:
164+
python-version: '3.14'
165+
166+
- name: Download build artifacts
167+
uses: actions/download-artifact@v3
168+
with:
169+
name: dist-${{ github.sha }}
170+
path: dist/
171+
172+
- name: Install package from wheel
173+
run: |
174+
python -m pip install --upgrade pip
175+
pip install dist/*.whl
176+
177+
- name: Run integration tests
178+
run: |
179+
# Test CLI tools work
180+
himl --help
181+
himl-config-merger --help
182+
183+
# Test basic functionality with examples
184+
if [ -d "examples" ]; then
185+
cd examples
186+
if [ -d "simple" ]; then
187+
himl simple/production --format yaml
188+
fi
189+
fi

0 commit comments

Comments
 (0)