Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codecov test-results to detect flaky tests #46

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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