Skip to content

Commit fb057ba

Browse files
authored
Merge pull request #206 from UiPath/ci/sonarcloud
ci: add coverage report and sonarcloud scan on PRs
2 parents 74e1aa9 + f6148d7 commit fb057ba

4 files changed

Lines changed: 85 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ jobs:
2323

2424
test:
2525
uses: ./.github/workflows/test.yml
26+
secrets:
27+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/test.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Test
22

33
on:
4-
workflow_call
4+
workflow_call:
5+
secrets:
6+
SONAR_TOKEN:
7+
required: false
58

69
jobs:
710
test:
@@ -32,6 +35,51 @@ jobs:
3235
run: uv sync --all-extras
3336

3437
- name: Run tests
38+
if: "!(matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13')"
3539
run: uv run pytest
3640

41+
- name: Run tests with coverage
42+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
43+
run: uv run pytest --cov=src/uipath_mcp --cov-report=xml --cov-report=html --tb=short
44+
45+
- name: Upload coverage HTML report
46+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' && always()
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: coverage-html-report
50+
path: htmlcov/
51+
retention-days: 30
52+
53+
- name: Upload coverage XML report
54+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' && always()
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: coverage-xml-report
58+
path: coverage.xml
59+
retention-days: 30
60+
3761
continue-on-error: true
62+
63+
sonarcloud:
64+
name: SonarCloud
65+
needs: test
66+
runs-on: ubuntu-latest
67+
if: always() && needs.test.result != 'failure'
68+
permissions:
69+
contents: read
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
with:
74+
fetch-depth: 0
75+
76+
- name: Download coverage
77+
uses: actions/download-artifact@v4
78+
continue-on-error: true
79+
with:
80+
name: coverage-xml-report
81+
82+
- name: SonarCloud Scan
83+
uses: SonarSource/sonarqube-scan-action@2f77a1ec69fb1d595b06f35ab27e97605bdef703 # v5
84+
env:
85+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ python_files = "test_*.py"
8888
addopts = "-ra -q"
8989
asyncio_mode = "auto"
9090

91+
[tool.coverage.run]
92+
source = ["src/uipath_mcp"]
93+
relative_files = true
94+
omit = [
95+
"*/tests/*",
96+
"*/__pycache__/*",
97+
"*/site-packages/*",
98+
"*/conftest.py",
99+
]
100+
101+
[tool.coverage.report]
102+
show_missing = true
103+
precision = 2
104+
exclude_lines = [
105+
"pragma: no cover",
106+
"def __repr__",
107+
"raise NotImplementedError",
108+
"if TYPE_CHECKING:",
109+
"@(abc\\.)?abstractmethod",
110+
]
111+
91112
[[tool.uv.index]]
92113
name = "testpypi"
93114
url = "https://test.pypi.org/simple/"

sonar-project.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sonar.projectKey=UiPath_uipath-mcp-python
2+
sonar.organization=ui
3+
sonar.host.url=https://sonarcloud.io
4+
5+
sonar.sources=src/uipath_mcp
6+
sonar.tests=tests
7+
8+
sonar.python.version=3.11,3.12,3.13
9+
sonar.python.coverage.reportPaths=coverage.xml
10+
11+
sonar.exclusions=**/samples/**,**/testcases/**
12+
13+
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)