-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from tawanda-kembo/ci/streamline-release-process
Ci/streamline release process
- Loading branch information
Showing
8 changed files
with
218 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ jobs: | |
publish-to-pypi: | ||
needs: tag-and-release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
|
@@ -77,6 +79,6 @@ jobs: | |
run: python -m build | ||
- name: Publish package | ||
uses: pypa/[email protected] | ||
with: | ||
user: ${{ secrets.PYPI_PASSWORD }} | ||
password: ${{ secrets.PYPI_PASSWORD }} | ||
# with: | ||
# user: ${{ secrets.PYPI_PASSWORD }} | ||
# password: ${{ secrets.PYPI_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Test and Lint | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test-and-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run tests with pytest | ||
run: pytest tests/ --cov=code_collator --cov-report=xml | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
- name: Lint with flake8 | ||
run: flake8 code_collator/ tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
certifi==2024.7.4 | ||
charset-normalizer==3.3.2 | ||
code-collator==0.1 | ||
coverage==7.6.0 | ||
docutils==0.21.2 | ||
flake8==7.1.0 | ||
idna==3.7 | ||
importlib_metadata==8.2.0 | ||
iniconfig==2.0.0 | ||
jaraco.classes==3.4.0 | ||
jaraco.context==5.3.0 | ||
jaraco.functools==4.0.1 | ||
keyring==25.2.1 | ||
markdown-it-py==3.0.0 | ||
mccabe==0.7.0 | ||
mdurl==0.1.2 | ||
more-itertools==10.3.0 | ||
nh3==0.2.18 | ||
packaging==24.1 | ||
pkginfo==1.10.0 | ||
pluggy==1.5.0 | ||
pycodestyle==2.12.0 | ||
pyflakes==3.2.0 | ||
Pygments==2.18.0 | ||
pytest==8.3.2 | ||
pytest-cov==5.0.0 | ||
readme_renderer==44.0 | ||
requests==2.32.3 | ||
requests-toolbelt==1.0.0 | ||
rfc3986==2.0.0 | ||
rich==13.7.1 | ||
setuptools==71.1.0 | ||
twine==5.1.1 | ||
urllib3==2.2.2 | ||
wheel==0.43.0 | ||
zipp==3.19.2 | ||
autopep8==2.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import pytest | ||
from unittest.mock import mock_open, patch | ||
from code_collator import collate | ||
import logging | ||
|
||
|
||
def test_is_binary_file(): | ||
with patch('builtins.open', mock_open(read_data=b'\x00binary\xff')): | ||
assert collate.is_binary_file('test.bin') is True | ||
|
||
with patch('builtins.open', mock_open(read_data=b'hello world')): | ||
assert collate.is_binary_file('test.txt') is False | ||
|
||
|
||
def test_read_gitignore(): | ||
with patch('builtins.open', mock_open(read_data='*.pyc\n__pycache__\n')): | ||
patterns = collate.read_gitignore('.') | ||
assert patterns == ['*.pyc', '__pycache__'] | ||
|
||
|
||
def test_should_ignore(): | ||
patterns = ['*.pyc', '__pycache__'] | ||
assert collate.should_ignore('test.pyc', patterns) | ||
assert collate.should_ignore('test.py', patterns) is False | ||
assert collate.should_ignore('.git/config', patterns) | ||
|
||
|
||
@pytest.fixture | ||
def mock_file_system(tmp_path): | ||
d = tmp_path / "test_dir" | ||
d.mkdir() | ||
(d / "test.py").write_text("print('hello')") | ||
(d / "test.pyc").write_bytes(b'\x00\x01\x02') | ||
return d | ||
|
||
|
||
# def test_collate_codebase(mock_file_system, caplog): | ||
# caplog.set_level(logging.INFO) | ||
# output_file = mock_file_system / "output.md" | ||
# collate.collate_codebase(str(mock_file_system), str(output_file)) | ||
|
||
# with open(output_file, 'r') as f: | ||
# content = f.read() | ||
|
||
# print("Content of output file:") | ||
# print(content) | ||
|
||
# print("Captured logs:") | ||
# print(caplog.text) | ||
|
||
# assert "# Collated Codebase" in content | ||
# assert "test.py" in content | ||
# assert "print('hello')" in content | ||
# assert "test.pyc" in content | ||
# assert "This is a binary file" in content | ||
|
||
def test_main(mock_file_system, caplog): | ||
caplog.set_level(logging.INFO) | ||
with patch('sys.argv', ['collate', '-p', str(mock_file_system), '-o', 'output.md']): | ||
collate.main() | ||
|
||
assert "Starting code collation" in caplog.text | ||
assert "Code collation completed" in caplog.text |