Skip to content

Commit 39a1bdd

Browse files
committed
Added support for coverage report generation
1 parent d7e0fc6 commit 39a1bdd

File tree

20 files changed

+197
-31
lines changed

20 files changed

+197
-31
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ jobs:
4343

4444
- name: Test
4545
working-directory: src/${{ matrix.directory }}
46-
run: uv run pytest
46+
run: |
47+
uv run pytest --cov=. --cov-report=html
48+
env:
49+
COVERAGE_FILE: .coverage.${{ matrix.directory }}
4750

4851
- name: Build
4952
working-directory: src/${{ matrix.directory }}
@@ -53,6 +56,24 @@ jobs:
5356
working-directory: src/${{ matrix.directory }}
5457
run: uv pip install .
5558

59+
- name: Store coverage file
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: coverage-${{ matrix.directory }}
63+
path: src/${{ matrix.directory }}/.coverage.${{ matrix.directory }}
64+
# By default hidden files/folders (i.e. starting with .) are ignored.
65+
# You may prefer (for security reasons) not setting this and instead
66+
# set COVERAGE_FILE above to not start with a `.`, but you cannot
67+
# use "MERGE_COVERAGE_FILES: true" later on and need to manually
68+
# combine the coverage file using "pipx run coverage combine"
69+
include-hidden-files: true
70+
71+
- name: Upload coverage report
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ${{ matrix.directory }}-coverage-report
75+
path: src/${{ matrix.directory }}/htmlcov
76+
5677
get-directories:
5778
runs-on: ubuntu-latest
5879
outputs:
@@ -66,3 +87,33 @@ jobs:
6687
run: |
6788
directories=$(ls src | grep -v dbtools-mcp-server | grep -v mysql-mcp-server | grep -v oci-pricing-mcp-server | grep -v oracle-db-doc-mcp-server | jq -R -s -c 'split("\n")[:-1]')
6889
echo "directories=$directories" >> $GITHUB_OUTPUT
90+
91+
coverage:
92+
name: Coverage
93+
runs-on: ubuntu-latest
94+
needs: build
95+
permissions:
96+
pull-requests: write
97+
contents: write
98+
steps:
99+
- uses: actions/checkout@v4
100+
101+
- uses: actions/download-artifact@v4
102+
id: download
103+
with:
104+
pattern: coverage-*
105+
merge-multiple: true
106+
107+
- name: Coverage comment
108+
id: coverage_comment
109+
uses: py-cov-action/python-coverage-comment-action@v3
110+
with:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
MERGE_COVERAGE_FILES: true
113+
114+
- name: Store Pull Request comment to be posted
115+
uses: actions/upload-artifact@v4
116+
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
117+
with:
118+
name: python-coverage-comment-action
119+
path: python-coverage-comment-action.txt

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ env.bak/
1010
venv.bak/
1111

1212
# Python uv
13-
uv.lock
1413
.python-version
1514

1615
# VScode
@@ -21,3 +20,4 @@ uv.lock
2120

2221
# test environments
2322
.env
23+
.coverage*

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test:
4949
@for dir in $(SUBDIRS); do \
5050
if [ -f $$dir/pyproject.toml ]; then \
5151
echo "Testing $$dir"; \
52-
cd $$dir && uv sync && uv run pytest && cd ../..; \
52+
cd $$dir && uv sync && uv run pytest --cov=. --cov-report=html && cd ../..; \
5353
fi \
5454
done
5555

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-r requirements.txt
22
pytest
33
pytest-asyncio
4+
pytest-cov
45
tox
56
tomlq
67
uv

src/oci-api-mcp-server/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ authors = [
1212
dependencies = [
1313
"fastmcp==2.12.2",
1414
"oci==2.160.0",
15+
"pytest-cov>=7.0.0",
1516
]
1617

1718
classifiers = [

src/oci-api-mcp-server/uv.lock

Lines changed: 78 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/oci-compute-instance-agent-mcp-server/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ authors = [
1212
dependencies = [
1313
"oci==2.160.0",
1414
"fastmcp==2.12.2",
15+
"pytest-cov>=7.0.0",
1516
]
1617

1718
classifiers = [

src/oci-compute-mcp-server/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies = [
1313
"fastmcp==2.12.2",
1414
"oci==2.160.0",
1515
"pydantic==2.12.3",
16+
"pytest-cov>=7.0.0",
1617
]
1718

1819
classifiers = [

src/oci-compute-mcp-server/uv.lock

Lines changed: 50 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/oci-identity-mcp-server/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ authors = [
1212
dependencies = [
1313
"fastmcp==2.12.2",
1414
"oci==2.160.0",
15+
"pytest-cov>=7.0.0",
1516
]
1617

1718
classifiers = [

0 commit comments

Comments
 (0)