Skip to content

Commit 4baf37b

Browse files
authored
INTPYTHON-469 Document local testing setup (#55)
1 parent cd8de7b commit 4baf37b

File tree

6 files changed

+40
-26
lines changed

6 files changed

+40
-26
lines changed

.github/scripts/check_diff.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@
1717
raise ValueError("Max diff reached. Please manually run CI on changed libs.")
1818

1919
for file in files:
20-
if any(
21-
file.startswith(dir_)
22-
for dir_ in (
23-
".github/workflows",
24-
".github/tools",
25-
".github/actions",
26-
".github/scripts/check_diff.py",
27-
)
28-
):
20+
if any(file.startswith(dir_) for dir_ in (".github", "scripts")):
2921
# add all LIB_DIRS for infra changes
3022
dirs_to_run["test"].update(LIB_DIRS)
23+
dirs_to_run["lint"].update(LIB_DIRS)
3124

3225
if any(file.startswith(dir_) for dir_ in LIB_DIRS):
3326
for dir_ in LIB_DIRS:
3427
if file.startswith(dir_):
3528
dirs_to_run["test"].add(dir_)
36-
if "langgraph-checkpoint-mongodb/tests" not in file:
3729
dirs_to_run["lint"].add(dir_)
3830
elif file.startswith("libs/"):
3931
raise ValueError(

.github/workflows/_release.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
if: github.ref == 'refs/heads/main'
2727
runs-on: ubuntu-latest
2828

29+
defaults:
30+
run:
31+
working-directory: ${{ inputs.working-directory }}
32+
2933
outputs:
3034
pkg-name: ${{ steps.check-version.outputs.pkg-name }}
3135
version: ${{ steps.check-version.outputs.version }}
@@ -53,7 +57,6 @@ jobs:
5357
# https://github.com/pypa/gh-action-pypi-publish#non-goals
5458
- name: Build project for distribution
5559
run: uv build
56-
working-directory: ${{ inputs.working-directory }}
5760

5861
- name: Upload build
5962
uses: actions/upload-artifact@v4
@@ -64,7 +67,6 @@ jobs:
6467
- name: Check Version
6568
id: check-version
6669
shell: bash
67-
working-directory: ${{ inputs.working-directory }}
6870
run: |
6971
echo pkg-name="$(hatch project metadata | jq -r .name)" >> $GITHUB_OUTPUT
7072
echo version="$(hatch version)" >> $GITHUB_OUTPUT
@@ -84,6 +86,9 @@ jobs:
8486
- build
8587
- test-pypi-publish
8688
runs-on: ubuntu-latest
89+
defaults:
90+
run:
91+
working-directory: ${{ inputs.working-directory }}
8792
steps:
8893
- uses: actions/checkout@v4
8994

@@ -107,7 +112,6 @@ jobs:
107112

108113
- name: Import published package
109114
shell: bash
110-
working-directory: ${{ inputs.working-directory }}
111115
env:
112116
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
113117
VERSION: ${{ needs.build.outputs.version }}
@@ -142,11 +146,9 @@ jobs:
142146

143147
- name: Import test dependencies
144148
run: just install
145-
working-directory: ${{ inputs.working-directory }}
146149

147150
# Overwrite the local version of the package with the test PyPI version.
148151
- name: Import published package (again)
149-
working-directory: ${{ inputs.working-directory }}
150152
shell: bash
151153
env:
152154
PKG_NAME: ${{ needs.build.outputs.pkg-name }}
@@ -158,30 +160,29 @@ jobs:
158160
159161
- name: Run unit tests
160162
run: just tests
161-
working-directory: ${{ inputs.working-directory }}
162163

163164
- name: Start local Atlas
165+
working-directory: .
164166
run: bash scripts/start_local_atlas.sh
165167

166168
- name: Install Ollama
167169
run: curl -fsSL https://ollama.com/install.sh | sh
168170

169171
- name: Run Ollama
172+
working-directory: .
170173
run: |
171174
ollama serve &
172175
sleep 5 # wait for the Ollama server to be ready
173-
ollama pull all-minilm:l6-v2
176+
bash scripts/setup_ollama.sh
174177
175178
- name: Run integration tests
176179
run: just integration_tests
177-
working-directory: ${{ inputs.working-directory }}
178180

179181
- name: Run unit tests with minimum dependency versions
180182
run: |
181-
uv sync --python=${{ matrix.python-version }} --resolution=lowest-direct
183+
uv sync --python=${{ env.PYTHON_VERSION }} --resolution=lowest-direct
182184
just test || git checkout uv.lock
183185
git checkout uv.lock
184-
working-directory: ${{ inputs.working-directory }}
185186
186187
publish:
187188
needs:

.github/workflows/_test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ jobs:
5252
run: curl -fsSL https://ollama.com/install.sh | sh
5353

5454
- name: Run Ollama
55+
working-directory: .
5556
run: |
5657
ollama serve &
5758
sleep 5 # wait for the Ollama server to be ready
58-
ollama pull all-minilm:l6-v2
59+
bash scripts/setup_ollama.sh
5960
6061
- name: Run integration tests
6162
run: just integration_tests
62-
working-directory: ${{ inputs.working-directory }}
6363

6464
- name: Ensure the tests did not create any additional files
6565
shell: bash
@@ -77,4 +77,3 @@ jobs:
7777
run: |
7878
uv sync --python=${{ matrix.python-version }} --resolution=lowest-direct
7979
just test
80-
working-directory: ${{ inputs.working-directory }}

.github/workflows/_test_release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ jobs:
1515
build:
1616
if: github.ref == 'refs/heads/main'
1717
runs-on: ubuntu-latest
18-
18+
defaults:
19+
run:
20+
working-directory: ${{ inputs.working-directory }}
1921
outputs:
2022
pkg-name: ${{ steps.check-version.outputs.pkg-name }}
2123
version: ${{ steps.check-version.outputs.version }}
@@ -43,7 +45,6 @@ jobs:
4345
# https://github.com/pypa/gh-action-pypi-publish#non-goals
4446
- name: Build project for distribution
4547
run: uv build
46-
working-directory: ${{ inputs.working-directory }}
4748

4849
- name: Upload build
4950
uses: actions/upload-artifact@v4
@@ -54,7 +55,6 @@ jobs:
5455
- name: Check Version
5556
id: check-version
5657
shell: bash
57-
working-directory: ${{ inputs.working-directory }}
5858
run: |
5959
echo pkg-name="$(hatch project metadata | jq -r .name)" >> $GITHUB_OUTPUT
6060
echo version="$(hatch version)" >> $GITHUB_OUTPUT

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ Then verify the installation.
3535
just test
3636
```
3737

38+
In order to run the integration tests, you'll also need a `MONGODB_URI` for MongoDB Atlas, as well
39+
as either an `OPENAI_API_KEY` or a configured local version of [ollama](https://ollama.com/download).
40+
41+
We have a convenience script to start a local Atlas instance, which requires `podman`:
42+
43+
```bash
44+
scripts/start_local_atlas.sh
45+
```
46+
47+
This will create a `.local_atlas_uri` file that has the `MONGODB_URI` set. The `justfiles` are configured
48+
to read the environment variable from this file.
49+
50+
If using `ollama`, we have a convenience script to download the library used in our tests:
51+
52+
```bash
53+
scripts/setup_ollama.sh
54+
```
55+
3856
### Testing
3957

4058
Unit tests cover modular logic that does not require calls to outside APIs.

scripts/setup_ollama.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
ollama pull all-minilm:l6-v2

0 commit comments

Comments
 (0)