Skip to content

Commit 54a641a

Browse files
committed
Setup code coverage pytest plugin, setup pages with coverage view.
1 parent f1a3ef7 commit 54a641a

File tree

7 files changed

+549
-3
lines changed

7 files changed

+549
-3
lines changed

.github/workflows/coverage.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- new-heuristics
8+
pull_request:
9+
branches:
10+
- main
11+
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
jobs:
17+
coverage:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.head_ref }}
23+
24+
- name: Setup uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
python-version: "3.13"
28+
29+
- name: Install dependencies
30+
run: uv sync --all-groups
31+
32+
- name: Run tests
33+
run: uv run pytest --cov=ttc --cov-report=xml
34+
35+
- name: Generate Coverage Badge
36+
run: uv run coverage-badge -o assets/coverage.svg
37+
38+
- name: Generate Coverage Map
39+
run: |
40+
uv run coverage-plot coverage.xml --no-show --save assets/coverage-map.svg
41+
uv run coverage-plot coverage.xml --no-show --save coverage-map.html
42+
43+
- name: Upload Coverage Artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: coverage-map-${{ github.sha }}
47+
path: coverage-map.html
48+
49+
- name: Deploy to GitHub Pages
50+
if: github.event_name == 'push'
51+
uses: peaceiris/actions-gh-pages@v3
52+
with:
53+
github_token: ${{ secrets.PAGES_TOKEN }}
54+
publish_dir: .
55+
keep_files: true
56+
publish_branch: gh-pages # Configure the Pages branch here
57+
58+
- name: Commit Coverage Assets
59+
uses: stefanzweifel/git-auto-commit-action@v5
60+
with:
61+
commit_message: "chore: update coverage assets"
62+
file_pattern: assets/coverage.svg assets/coverage-map.svg
63+
64+
- name: Comment Coverage Map Link
65+
if: github.event_name == 'pull_request'
66+
uses: marocchino/sticky-pull-request-comment@v2
67+
with:
68+
message: |
69+
## Coverage Report
70+
71+
[![Coverage Map](https://raw.githubusercontent.com/${{ github.repository }}/${{ github.head_ref }}/assets/coverage-map.svg)](https://f1uctus.github.io/ttc/coverage-map.html)

.github/workflows/pages.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["gh-pages"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v5
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
# Upload entire repository
40+
path: '.'
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

.vscode/settings.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
"спрена",
5151
"Таленель",
5252
"Таленелю",
53-
"Уистиоу"
54-
]
53+
"Уистиоу",
54+
"Шаллан"
55+
],
56+
"python.testing.pytestArgs": [
57+
"tests"
58+
],
59+
"python.testing.unittestEnabled": false,
60+
"python.testing.pytestEnabled": true
5561
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Text-To-Conversation toolkit (TTC)
22

3+
![Coverage](assets/coverage.svg)
4+
35
This NLP library can help you with:
46

57
- Extraction of characters' replicas from literary texts;
@@ -67,3 +69,5 @@ Contributions are very welcome!
6769

6870
[russian/\*/actor_classifier.py](ttc/language/russian/pipelines/actor_classifier.py):
6971
![](http://www.plantuml.com/plantuml/svg/ZLLHYzf047xVNp5SNxIWnTAZ89vSMoeSs4FmqHD9udWknjsmMTlQMkWFw6DV--VkbtGdkycOfENqGMTsltpVV3DClCrjPEnXdugjN2FWFhD7M6EU69bPgPN8Tr9baOdsa4g5zfWXQ6EtMfpTE0wBy5q0JBIoS_aDOV0sPFVH7aUZJrhfyHW-w8EHQCGF8QoqAKAIHdakDyTLb5XjSY4MBvVGwurXgdKcFE_LdKL3GNm4wyfACR-2AFSG-e8XzFjzM6G6FozzQ31BPHA5JE5NMuIYf2He7zLwHQRW1WA-NtIZE2mavgxuAI5UO1nVNx_nSgw-wgPYdB7cy0PclfY2PEQYUROJvIFqV7KOVjbpoVSWHl4O03eh687i3RfmOfVGWq5XQFGg7Z-e0jifGFGvqUbvInRJoJAWe2C9nB2ddx-vNHufVDce3gc5SdPL2ne-F6e8Jtz-_QSNJdN6LPDemV_E3VvH-UT5e27A-iLvqcwIyqZqYw6hl1YTL8-50bloMXkBPXu0bHDcRG2USPDZP99jfnJiDYoLDA9EojOOK4lRzbYOJBf9EPkerWxh9rK9lyUDDlYHhjXUMvvX5viakRR5G24gGZR8ruAJIyr9bQEXruwBwOHam_gU-RmhKPNLPXqju6LcA_ccNoOI3MPspI3HoDlUouLztMqjAuMrZJx18aRx1L7nq0C0Q9kVt-H9bAPnbEpQk_mFCuo-h6U-jbR7IXPH1jmelgkdhJOrDE-rmk17fdLUEWdrKiXC_C9sVopY5jNwi4__0W00)
72+
73+
[![Coverage Map](assets/coverage-map.svg)](https://f1uctus.github.io/ttc/coverage-map.html)

coverage-map.html

Lines changed: 14 additions & 0 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ dev = [
3333
"jupyter>=1.0.0",
3434
"ty",
3535
"black>=23.1",
36-
"ruff>=0.0.275"
36+
"ruff>=0.0.275",
37+
"coverage-badge",
38+
"coverage-plot @ git+https://github.com/F1uctus/coverage-plot.git",
39+
"pytest-cov>=7.0.0",
3740
]
3841

3942
[project.scripts]

0 commit comments

Comments
 (0)