Skip to content

Commit

Permalink
[RSPEED-189] Run unit tests in GitHub actions (#20)
Browse files Browse the repository at this point in the history
* Fix config and history wrong paths

There were a couple of leftovers when we renamed the project from
shellai to command-line-assistant, and also, we were handling how to
create the folders and files in the wrong way.

* Write basic unit tests to get the suite started

* Add github actions pipeline for running tests
  • Loading branch information
r0x0d authored Oct 31, 2024
1 parent 8d534a6 commit e6d7097
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 139 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Unit tests

on: [push, pull_request]

jobs:
unit_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.12']

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Setup PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ matrix.python-version }}
cache: true

- name: Install dependencies
run: make install

- name: Run unit tests
run: pdm run unit-test

- name: Generate coverage report
run: pdm run coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ unit-test: ## Unit test Command Line Assistant
@echo "Tests completed."

coverage: ## Generate coverage report from unit-tests
coverage xml
@coverage xml

help: ## Show available make commands
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
Expand All @@ -37,3 +37,4 @@ clean: ## Clean project files
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@rm -rf .pdm-build .ruff_cache .coverage .pdm-python dist
@coverage erase
113 changes: 2 additions & 111 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ distribution = true

[tool.pdm.dev-dependencies]
dev = [
"pytest>=8.3.3",
"tox>=4.23.2",
"pytest-cov>=6.0.0",
"pytest-randomly>=3.16.0",
"coverage>=7.6.4",
"pytest-sugar>=1.0.0",
"pytest-clarity>=1.0.1",
"pytest==8.3.3",
"pytest-cov==6.0.0",
"pytest-randomly==3.16.0",
"coverage==7.6.4",
"pytest-sugar==1.0.0",
"pytest-clarity==1.0.1",
]

[tool.pdm.scripts]
unit-test = "pdm run make unit-test"
coverage = "pdm run make coverage"


[tool.pytest.init_options]
testpaths = ["tests"]
addopts = ["--cov-report=term-missing", "--cov-report=html"]
Expand Down
20 changes: 0 additions & 20 deletions tox.ini

This file was deleted.

0 comments on commit e6d7097

Please sign in to comment.