forked from microsoft/semantic-kernel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python: added code coverage and vscode tasks def for python (microsof…
…t#4193) ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> To improve the code and PR quality I want to add code coverage to the dev dependencies, and setup. I then also added tasks into the python folder for both the pre-commit config and running unit tests with code coverage. Fixes microsoft#3980 Initially I excluded code coverage for all connectors, that needs to be refined and this can also be added to the GH actions once we have it setup well. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
- Loading branch information
1 parent
3d8f0d6
commit c56dab7
Showing
6 changed files
with
303 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[run] | ||
source = semantic_kernel | ||
omit = | ||
semantic_kernel/connectors/* | ||
|
||
[report] | ||
# Regexes for lines to exclude from consideration | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain about missing debug-only code: | ||
def __repr__ | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# TYPE_CHECKING and @overload blocks are never executed during pytest run | ||
if TYPE_CHECKING: | ||
@overload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Python: Run Checks", | ||
"type": "shell", | ||
"command": "poetry", | ||
"args": [ | ||
"run", | ||
"pre-commit", | ||
"run", | ||
"-c", | ||
".conf/.pre-commit-config.yaml", | ||
"-a" | ||
], | ||
"problemMatcher": { | ||
"owner": "python", | ||
"fileLocation": [ | ||
"relative", | ||
"${workspaceFolder}" | ||
], | ||
"pattern": { | ||
"regexp": "^(.*):(\\d+):(\\d+):\\s+(.*)$", | ||
"file": 1, | ||
"line": 2, | ||
"column": 3, | ||
"message": 4 | ||
} | ||
}, | ||
"presentation": { | ||
"reveal": "silent", | ||
"panel": "shared" | ||
} | ||
}, | ||
{ | ||
"label": "Python: Install", | ||
"type": "shell", | ||
"command": "poetry", | ||
"args": [ | ||
"install" | ||
], | ||
"presentation": { | ||
"reveal": "silent", | ||
"panel": "shared" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Python: Tests - Unit", | ||
"type": "shell", | ||
"command": "poetry", | ||
"args": [ | ||
"run", | ||
"pytest", | ||
"tests/unit/" | ||
], | ||
"group": "test", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Python: Tests - Code Coverage", | ||
"type": "shell", | ||
"command": "poetry run pytest --cov=semantic_kernel --cov-report term-missing tests/unit/", | ||
"group": "test", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Python: Tests - All", | ||
"type": "shell", | ||
"command": "poetry", | ||
"args": [ | ||
"run", | ||
"pytest", | ||
"tests/" | ||
], | ||
"group": "test", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "shared" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.