Skip to content
Closed
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
31 changes: 31 additions & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,50 @@ jobs:
--cov-report=term-missing
--cov-report=xml

- name: Collect Flake8 report for badge
working-directory: backend
run: poetry run flake8 src tests --exit-zero --output-file flake8.log

- name: Generate status badges
working-directory: backend
run: |
poetry run genbadge tests --local -i pytest-results.xml -o tests.svg
poetry run genbadge flake8 --local -i flake8.log -o flake8.svg
poetry run genbadge coverage --local -i coverage.xml -o coverage.svg
Comment on lines +119 to +124

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Ensure genbadge dependency is installed

The workflow now runs poetry run genbadge … to generate SVG badges, but the commit only adds genbadge to backend/pyproject.toml and does not update backend/poetry.lock. The CI job installs dependencies from the lock file (poetry install --with dev), so genbadge is never installed and these steps will fail with Command not found. Run poetry lock (or otherwise update the lock file) so the package is present in CI before invoking it.

Useful? React with 👍 / 👎.


- name: Upload pytest results
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: backend/pytest-results.xml

- name: Upload coverage badge
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-badges-${{ matrix.python-version }}
path: |
backend/tests.svg
backend/flake8.svg
backend/coverage.svg

- name: Publish Unit Test Results
if: ${{ always() && github.event_name == 'pull_request' }}
uses: EnricoMi/publish-unit-test-result-action/linux@v2
with:
files: backend/pytest-results.xml

- name: Commit coverage badge
if: ${{ github.event_name != 'pull_request' && matrix.python-version == '3.10' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: chore: update backend status badges
file_pattern: |
backend/tests.svg
backend/flake8.svg
backend/coverage.svg

- name: Post coverage comment
if: ${{ github.event_name == 'pull_request' }}
uses: py-cov-action/python-coverage-comment-action@v3
Expand Down
5 changes: 5 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Human Evaluation Tool Backend

[![Backend CI](https://img.shields.io/github/actions/workflow/status/yaraku/he-tool/backend-ci.yml?branch=main&label=Backend%20CI)](https://github.com/yaraku/he-tool/actions/workflows/backend-ci.yml)
![Tests](./tests.svg)
![Flake8](./flake8.svg)
![Coverage](./coverage.svg)

The backend is a Flask + SQLAlchemy application that powers the Human Evaluation Tool. It exposes a REST API for managing evaluations, documents, bitext pairs, annotations, systems, markings, and authentication.

## Quick start
Expand Down
21 changes: 21 additions & 0 deletions backend/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions backend/flake8.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mypy = "^1.8"
coverage = { extras = ["toml"], version = "^7.4" }
pytest = "^7.4"
pytest-cov = "^4.1"
genbadge = { version = "^1.1", extras = ["flake8", "tests"] }

[tool.pytest.ini_options]
pythonpath = ["src"]
Expand Down
21 changes: 21 additions & 0 deletions backend/tests.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion docs/backend/testing-and-quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ poetry run coverage run -m pytest
poetry run coverage report
```

The goal is ≥99 % line coverage (the current suite hits 100 %). Branch coverage is enabled to surface unexecuted conditional logic.
The goal is ≥99 % line coverage (the current suite hits 99 %). Branch coverage is enabled to surface unexecuted conditional logic. The GitHub Actions workflow also runs [`genbadge`](https://github.com/codacy/genbadge) to produce `backend/tests.svg`, `backend/flake8.svg`, and `backend/coverage.svg`, which appear at the top of the backend README. Locally, create `flake8.log` with `poetry run flake8 src tests --exit-zero --output-file flake8.log` and regenerate the badges after running the suite with:

```bash
poetry run genbadge tests --local -i pytest-results.xml -o tests.svg
poetry run genbadge flake8 --local -i flake8.log -o flake8.svg
poetry run genbadge coverage --local -i coverage.xml -o coverage.svg
```

## Static typing with mypy

Expand Down