Skip to content

Commit

Permalink
INTPYTHON-467 Switch from Makefile to Justfile (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Jan 8, 2025
1 parent d01b7c3 commit fe6f9eb
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 158 deletions.
10 changes: 0 additions & 10 deletions .github/scripts/extract_ignored_words_list.py

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/_codespell.yml

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

jobs:
build:
name: "make lint #${{ matrix.python-version }}"
name: "run lint #${{ matrix.python-version }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down Expand Up @@ -55,6 +55,8 @@ jobs:
run: |
poetry lock --check
- uses: extractions/setup-just@v2

- name: Install dependencies
# Also installs dev/lint/test/typing dependencies, to ensure we have
# type hints for as many of our libraries as possible.
Expand All @@ -66,7 +68,7 @@ jobs:
# It doesn't matter how you change it, any change will cause a cache-bust.
working-directory: ${{ inputs.working-directory }}
run: |
make install
just install
- name: Get .mypy_cache to speed up mypy
uses: actions/cache@v4
Expand All @@ -81,4 +83,4 @@ jobs:
- name: Analysing the code with our lint
working-directory: ${{ inputs.working-directory }}
run: |
make lint
just lint
10 changes: 6 additions & 4 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ jobs:
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
- uses: extractions/setup-just@v2

- name: Import test dependencies
run: make install
run: just install
working-directory: ${{ inputs.working-directory }}

# Overwrite the local version of the package with the test PyPI version.
Expand All @@ -162,7 +164,7 @@ jobs:
uses: supercharge/mongodb-github-action@1.11.0

- name: Run unit tests
run: make tests
run: just tests
working-directory: ${{ inputs.working-directory }}

- name: Start local Atlas
Expand All @@ -181,7 +183,7 @@ jobs:
ollama pull all-minilm:l6-v2
- name: Run integration tests
run: make integration_tests
run: just integration_tests
working-directory: ${{ inputs.working-directory }}

- name: Get minimum versions
Expand All @@ -199,7 +201,7 @@ jobs:
MIN_VERSIONS: ${{ steps.min-version.outputs.min-versions }}
run: |
poetry run pip install $MIN_VERSIONS
make tests
just tests
working-directory: ${{ inputs.working-directory }}

publish:
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version:
- "3.9"
- "3.12"
name: "make test #${{ matrix.python-version }}"
name: "run test #${{ matrix.python-version }}"
steps:
- uses: actions/checkout@v4

Expand All @@ -35,17 +35,19 @@ jobs:
working-directory: ${{ inputs.working-directory }}
cache-key: core

- uses: extractions/setup-just@v2

- name: Install dependencies
shell: bash
run: make install
run: just install

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0

- name: Run core tests
shell: bash
run: |
make test
just test
- name: Start local Atlas
working-directory: .
Expand All @@ -65,7 +67,7 @@ jobs:
ollama pull all-minilm:l6-v2
- name: Run integration tests
run: make integration_tests
run: just integration_tests
working-directory: ${{ inputs.working-directory }}

- name: Ensure the tests did not create any additional files
Expand Down
18 changes: 10 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Install Poetry: **[documentation on how to install it](https://python-poetry.org

### Local Development Dependencies

The project configuration and the makefile for running dev commands are located under the `libs/langchain-mongodb` or `libs/langgraph-checkpoint-mongodb` directories.
The project configuration and the `justfile` for running dev commands are located under the `libs/langchain-mongodb` or `libs/langgraph-checkpoint-mongodb` directories.

`just` can be [installed](https://just.systems/man/en/packages.html) from many package managers, including `brew`.

```bash
cd libs/langchain-mongodb
Expand All @@ -24,13 +26,13 @@ cd libs/langchain-mongodb
Install langchain-mongodb development requirements (for running langchain, running examples, linting, formatting, tests, and coverage):

```bash
make install
just install
```

Then verify the installation.

```bash
make test
just test
```

### Testing
Expand All @@ -41,7 +43,7 @@ If you add new logic, please add a unit test.
To run unit tests:

```bash
make test
just test
```

Integration tests cover the end-to-end service calls as much as possible.
Expand All @@ -53,7 +55,7 @@ this, please raise an issue.
To run the integration tests:

```bash
make integration_test
just integration_test
```

### Formatting and Linting
Expand Down Expand Up @@ -84,13 +86,13 @@ Linting and formatting for this project is done via a combination of [ruff](http
To run lint:

```bash
make lint
just lint
```

To run the type checker:

```bash
make typing
just typing
```

We recognize linting can be annoying - if you do not want to do it, please contact a project maintainer, and they can help you with it. We do not want this to be a blocker for good code getting contributed.
Expand All @@ -103,7 +105,7 @@ Note that `codespell` finds common typos, so it could have false-positive (corre
To check spelling for this project:

```bash
make codespell
just codespell
```

If codespell is incorrectly flagging a word, you can skip spellcheck for that word by adding it to the codespell config in the `.pre-commit-config.yaml` file.
45 changes: 0 additions & 45 deletions libs/langchain-mongodb/Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions libs/langchain-mongodb/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
set shell := ["bash", "-c"]
set dotenv-load
set dotenv-filename := "../../.local_atlas_uri"

# Default target executed when no arguments are given.
[private]
default:
@just --list

install:
poetry install --with dev

[group('test')]
integration_tests:
poetry run pytest tests/integration_tests/

[group('test')]
test *args="tests/unit_tests":
poetry run pytest {{args}}

[group('test')]
test_watch filename:
poetry run ptw --snapshot-update --now . -- -vv {{filename}}

[group('lint')]
lint:
git ls-files -- '*.py' | xargs poetry run pre-commit run ruff --files
git ls-files -- '*.py' | xargs poetry run pre-commit run ruff-format --files

[group('lint')]
typing:
poetry run mypy .

[group('lint')]
codespell:
git ls-files -- '*.py' | xargs poetry run pre-commit run --hook-stage manual codespell --files
45 changes: 0 additions & 45 deletions libs/langgraph-checkpoint-mongodb/Makefile

This file was deleted.

36 changes: 36 additions & 0 deletions libs/langgraph-checkpoint-mongodb/justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
set shell := ["bash", "-c"]
set dotenv-load
set dotenv-filename := "../../.local_atlas_uri"

# Default target executed when no arguments are given.
[private]
default:
@just --list

install:
poetry install --with dev

[group('test')]
integration_tests:
poetry run pytest tests/integration_tests/

[group('test')]
test *args="tests/unit_tests":
poetry run pytest {{args}}

[group('test')]
test_watch filename:
poetry run ptw --snapshot-update --now . -- -vv {{filename}}

[group('lint')]
lint:
git ls-files -- '*.py' | xargs poetry run pre-commit run ruff --files
git ls-files -- '*.py' | xargs poetry run pre-commit run ruff-format --files

[group('lint')]
typing:
poetry run mypy .

[group('lint')]
codespell:
git ls-files -- '*.py' | xargs poetry run pre-commit run --hook-stage manual codespell --files

0 comments on commit fe6f9eb

Please sign in to comment.