|
| 1 | +# DEVELOPER.md |
| 2 | + |
| 3 | +## Versioning |
| 4 | + |
| 5 | +This library follows [Semantic Versioning](http://semver.org/). |
| 6 | + |
| 7 | +## Processes |
| 8 | + |
| 9 | +### Conventional Commit messages |
| 10 | + |
| 11 | +This repository uses tool [Release Please](https://github.com/googleapis/release-please) to create GitHub and PyPi releases. It does so by parsing your |
| 12 | +git history, looking for [Conventional Commit messages](https://www.conventionalcommits.org/), |
| 13 | +and creating release PRs. |
| 14 | + |
| 15 | +Learn more by reading [How should I write my commits?](https://github.com/googleapis/release-please?tab=readme-ov-file#how-should-i-write-my-commits) |
| 16 | + |
| 17 | +<!-- ## Testing |
| 18 | +
|
| 19 | +### Run tests locally |
| 20 | +
|
| 21 | +1. Set environment variables for `SPANNER_INSTANCE_ID`, `SPANNER_DATABASE_ID`, `SPANNER_GRAPH_NAME` |
| 22 | +
|
| 23 | +1. Run pytest to automatically run all tests: |
| 24 | +
|
| 25 | + ```bash |
| 26 | + pytest |
| 27 | + ``` |
| 28 | +
|
| 29 | +### CI Platform Setup |
| 30 | +
|
| 31 | +Cloud Build is used to run tests against Google Cloud resources in test project: langchain-spanner-testing. |
| 32 | +Each test has a corresponding Cloud Build trigger, see [all triggers][triggers]. |
| 33 | +These tests are registered as required tests in `.github/sync-repo-settings.yaml`. |
| 34 | +
|
| 35 | +#### Trigger Setup |
| 36 | +
|
| 37 | +Cloud Build triggers (for Python versions 3.9 to 3.11) were created with the following specs: |
| 38 | +
|
| 39 | +```YAML |
| 40 | +name: integration-test-pr-py39 |
| 41 | +description: Run integration tests on PR for Python 3.9 |
| 42 | +filename: integration.cloudbuild.yaml |
| 43 | +github: |
| 44 | + name: langchain-google-spanner-python |
| 45 | + owner: googleapis |
| 46 | + pullRequest: |
| 47 | + branch: .* |
| 48 | + commentControl: COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY |
| 49 | +ignoredFiles: |
| 50 | + - docs/** |
| 51 | + - .kokoro/** |
| 52 | + - .github/** |
| 53 | + - "*.md" |
| 54 | +substitutions: |
| 55 | + _INSTANCE_ID: <ADD_VALUE> |
| 56 | + _PG_DATABASE: <ADD_VALUE> |
| 57 | + _GOOGLE_DATABASE: <ADD_VALUE> |
| 58 | + _VERSION: "3.9" |
| 59 | +``` |
| 60 | +
|
| 61 | +Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line |
| 62 | +
|
| 63 | +#### Project Setup |
| 64 | +
|
| 65 | +1. Create an spanner instance and database |
| 66 | +1. Setup Cloud Build triggers (above) |
| 67 | +
|
| 68 | +#### Run tests with Cloud Build |
| 69 | +
|
| 70 | +* Run integration test: |
| 71 | +
|
| 72 | + ```bash |
| 73 | + gcloud builds submit --config integration.cloudbuild.yaml --region us-central1 --substitutions=_INSTANCE_ID=$INSTANCE_ID |
| 74 | + ``` |
| 75 | +
|
| 76 | +#### Trigger |
| 77 | +
|
| 78 | +To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, comment: `/gcbrun`. |
| 79 | +
|
| 80 | +#### Code Coverage |
| 81 | +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`. |
| 82 | +
|
| 83 | +Check for code coverage report in any Cloud Build integration test log. |
| 84 | +Here is a breakdown of the report: |
| 85 | +- `Stmts`: lines of executable code (statements). |
| 86 | +- `Miss`: number of lines not covered by tests. |
| 87 | +- `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). |
| 88 | +- `BrPart`: number of branches not covered by tests. |
| 89 | +- `Cover`: average coverage of files. |
| 90 | +- `Missing`: lines that are not covered by tests. |
| 91 | +
|
| 92 | +
|
| 93 | +[triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-spanner-testing --> |
0 commit comments