Skip to content

Commit e4f02f2

Browse files
authored
feat: test against multiple versions (#58)
* feat: test against multiple versions * Update DEVELOPER.md * add req for 38
1 parent fd8d870 commit e4f02f2

File tree

5 files changed

+104
-9
lines changed

5 files changed

+104
-9
lines changed

.github/header-checker-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ ignoreFiles:
1818
- ".github/sync-repo-settings.yaml"
1919
- ".kokoro/**"
2020
- "**/requirements.txt"
21-
- "**/requirements-test.txt"
21+
- "**/requirements*.txt"

.github/sync-repo-settings.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ branchProtectionRules:
2727
requiredStatusCheckContexts:
2828
- "cla/google"
2929
- "lint"
30-
- "integration-test-pr (langchain-redis-query-testing)"
30+
- "integration-test-pr-py38 (langchain-redis-query-testing)"
31+
- "integration-test-pr-py39 (langchain-redis-query-testing)"
32+
- "integration-test-pr-py310 (langchain-redis-query-testing)"
33+
- "integration-test-pr-py311 (langchain-redis-query-testing)"
34+
- "integration-test-pr-py312 (langchain-redis-query-testing)"
3135
- "conventionalcommits.org"
3236
- "header-check"
3337
# - Add required status checks like presubmit tests

DEVELOPER.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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. Run pytest to automatically run all tests:
22+
23+
```bash
24+
pytest
25+
```
26+
27+
### CI Platform Setup
28+
29+
Cloud Build is used to run tests against Google Cloud resources in test project: langchain-redis-query-testing.
30+
Each test has a corresponding Cloud Build trigger, see [all triggers][triggers].
31+
These tests are registered as required tests in `.github/sync-repo-settings.yaml`.
32+
33+
#### Trigger Setup
34+
35+
Cloud Build triggers (for Python versions 3.8 to 3.11) were created with the following specs:
36+
37+
```YAML
38+
name: integration-test-pr-py38
39+
description: Run integration tests on PR for Python 3.8
40+
filename: integration.cloudbuild.yaml
41+
github:
42+
name: langchain-google-memorystore-redis-python
43+
owner: googleapis
44+
pullRequest:
45+
branch: .*
46+
commentControl: COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY
47+
ignoredFiles:
48+
- docs/**
49+
- .kokoro/**
50+
- .github/**
51+
- "*.md"
52+
substitutions:
53+
_VERSION: "3.8"
54+
_WORKER_POOL: ""
55+
_REDIS_URL: ""
56+
```
57+
58+
Use `gcloud builds triggers import --source=trigger.yaml` create triggers via the command line
59+
60+
#### Project Setup
61+
62+
1. Create an Memorystore for Redis instance
63+
1. Create a Cloud Build private worker pool
64+
1. Setup Cloud Build triggers (above)
65+
66+
#### Run tests with Cloud Build
67+
68+
* Run integration test:
69+
70+
```bash
71+
gcloud builds submit --config integration.cloudbuild.yaml --region us-central1 --substitutions=_WORKER_POOL="path-to-worker-pool",_REDIS_URL="redis://..."
72+
```
73+
74+
#### Trigger
75+
76+
To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, comment: `/gcbrun`.
77+
78+
79+
[triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-redis-query-testing

integration.cloudbuild.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,30 @@
1414

1515
steps:
1616
- id: Install dependencies
17-
name: python:3.11
18-
entrypoint: pip
19-
args: ["install", "--user", "-r", "requirements.txt"]
17+
name: python:${_VERSION}
18+
entrypoint: /bin/bash
19+
args:
20+
- -c
21+
- |
22+
if [[ $_VERSION == "3.8" ]]; then version="-3.8"; fi
23+
pip install --user -r requirements${version}.txt
2024
2125
- id: Install module (and test requirements)
22-
name: python:3.11
26+
name: python:${_VERSION}
2327
entrypoint: pip
2428
args: ["install", ".[test]", "--user"]
2529

2630
- id: Run integration tests
27-
name: python:3.11
31+
name: python:${_VERSION}
2832
entrypoint: python
2933
args: ["-m", "pytest"]
3034
env:
31-
- 'REDIS_URL=$_REDIS_URL'
35+
- "REDIS_URL=$_REDIS_URL"
36+
37+
substitutions:
38+
_VERSION: "3.8"
3239

3340
options:
3441
pool:
35-
name: '$_WORKER_POOL'
42+
name: "$_WORKER_POOL"
43+
dynamicSubstitutions: true

requirements-3.8.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
langchain-core==0.1.32
2+
langchain-community==0.0.28
3+
redis==5.0.3
4+
numpy==1.24.4

0 commit comments

Comments
 (0)