Skip to content

Commit

Permalink
Add codecov test-results to detect flaky tests (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
r0x0d authored Nov 22, 2024
1 parent 557c7a8 commit 0ed9861
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- uses: actions/setup-python@v5
with:
Expand All @@ -29,15 +30,21 @@ jobs:
cache: true

- name: Install dependencies
run: make install
run: |
make install
echo "$(pdm venv --path in-project)/bin" >> $GITHUB_PATH
- name: Run unit tests
run: pdm run unit-test

- name: Generate coverage report
run: pdm run coverage
run: pdm run unit-test-coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# https://docs.codecov.com/docs/test-analytics
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ htmlcov/
# ignore tests specifics
.tox
coverage*
junit.xml
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ install: install-tools ## Sync all required dependencies for Command Line Assist
install-dev: install-tools ## Sync all development dependencies
pdm sync --dev

unit-test: ## Unit test Command Line Assistant
unit-test: ## Unit test cla
@echo "Running tests..."
@pytest tests --cov
@pytest
@echo "Tests completed."

unit-test-coverage: ## Unit test cla with coverage
@echo "Running tests..."
@pytest --cov --junitxml=junit.xml -o junit_family=legacy
@echo "Tests completed."


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

Expand All @@ -36,5 +42,5 @@ clean: ## Clean project files
@find . -name '__pycache__' -exec rm -fr {} +
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@rm -rf .pdm-build .ruff_cache .coverage .pdm-python dist .tox
@rm -rf .pdm-build .ruff_cache .coverage .pdm-python dist .tox junit.xml coverage.xml
@coverage erase
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ lint.ignore = [
distribution = true

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

unit-test = "make unit-test"
unit-test-coverage = "make unit-test-coverage"

[tool.pytest.init_options]
testpaths = ["tests"]
addopts = ["--cov-report=term-missing", "--cov-report=html"]

[tool.coverage.report]
skip_empty = true
Expand Down

0 comments on commit 0ed9861

Please sign in to comment.