Skip to content

ci: Add code coverage check #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2024
Merged
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
8 changes: 8 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[run]
branch = true
omit =
*/__init__.py

[report]
show_missing = true
fail_under = 89
15 changes: 14 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ substitutions:
_VERSION: "3.8"
```

Use `gcloud builds triggers import --source=trigger.yaml` create triggers via the command line
Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line

#### Project Setup

Expand All @@ -78,4 +78,17 @@ Use `gcloud builds triggers import --source=trigger.yaml` create triggers via th
To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, comment: `/gcbrun`.


#### Code Coverage
Please make sure your code is fully tested. The Cloud Build integration tests are run with the `pytest-cov` code coverage plugin. They fail for PRs with a code coverage less than the threshold specified in `.coveragerc`. If your file is inside the main module and should be ignored by code coverage check, add it to the `omit` section of `.coveragerc`.

Check for code coverage report in any Cloud Build integration test log.
Here is a breakdown of the report:
- `Stmts`: lines of executable code (statements).
- `Miss`: number of lines not covered by tests.
- `Branch`: branches of executable code (e.g an if-else clause may count as 1 statement but 2 branches; test for both conditions to have both branches covered).
- `BrPart`: number of branches not covered by tests.
- `Cover`: average coverage of files.
- `Missing`: lines that are not covered by tests.


[triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-cloud-sql-testing
2 changes: 1 addition & 1 deletion integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ steps:
- id: Run integration tests
name: python:${_VERSION}
entrypoint: python
args: ["-m", "pytest"]
args: ["-m", "pytest", "--cov=langchain_google_cloud_sql_mysql", "--cov-config=.coveragerc", "tests/"]
env:
- "PROJECT_ID=$PROJECT_ID"
- "INSTANCE_ID=$_INSTANCE_ID"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ test = [
"isort==5.13.2",
"mypy==1.10.0",
"pytest-asyncio==0.23.6",
"pytest==8.1.1"
"pytest==8.1.1",
"pytest-cov==5.0.0"
]

[build-system]
Expand Down
Loading