From fe6f9eb69bbeadf3a0e74cdaeaa92a2fc339c806 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 8 Jan 2025 07:36:15 -0600 Subject: [PATCH] INTPYTHON-467 Switch from Makefile to Justfile (#52) --- .github/scripts/extract_ignored_words_list.py | 10 ----- .github/workflows/_codespell.yml | 39 ---------------- .github/workflows/_lint.yml | 8 ++-- .github/workflows/_release.yml | 10 +++-- .github/workflows/_test.yml | 10 +++-- CONTRIBUTING.md | 18 ++++---- libs/langchain-mongodb/Makefile | 45 ------------------- libs/langchain-mongodb/justfile | 36 +++++++++++++++ libs/langgraph-checkpoint-mongodb/Makefile | 45 ------------------- libs/langgraph-checkpoint-mongodb/justfile | 36 +++++++++++++++ 10 files changed, 99 insertions(+), 158 deletions(-) delete mode 100644 .github/scripts/extract_ignored_words_list.py delete mode 100644 .github/workflows/_codespell.yml delete mode 100644 libs/langchain-mongodb/Makefile create mode 100644 libs/langchain-mongodb/justfile delete mode 100644 libs/langgraph-checkpoint-mongodb/Makefile create mode 100644 libs/langgraph-checkpoint-mongodb/justfile diff --git a/.github/scripts/extract_ignored_words_list.py b/.github/scripts/extract_ignored_words_list.py deleted file mode 100644 index 7c800e0..0000000 --- a/.github/scripts/extract_ignored_words_list.py +++ /dev/null @@ -1,10 +0,0 @@ -import toml - -pyproject_toml = toml.load("pyproject.toml") - -# Extract the ignore words list (adjust the key as per your TOML structure) -ignore_words_list = ( - pyproject_toml.get("tool", {}).get("codespell", {}).get("ignore-words-list") -) - -print(f"::set-output name=ignore_words_list::{ignore_words_list}") diff --git a/.github/workflows/_codespell.yml b/.github/workflows/_codespell.yml deleted file mode 100644 index 53e4dc4..0000000 --- a/.github/workflows/_codespell.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -name: make spell_check - -on: - workflow_call: - inputs: - working-directory: - required: true - type: string - description: "From which folder this pipeline executes" - -permissions: - contents: read - -jobs: - codespell: - name: (Check for spelling errors) - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Dependencies - run: | - pip install toml - - - name: Extract Ignore Words List - working-directory: ${{ inputs.working-directory }} - run: | - # Use a Python script to extract the ignore words list from pyproject.toml - python ../../.github/scripts/extract_ignored_words_list.py - id: extract_ignore_words - - - name: Codespell - uses: codespell-project/actions-codespell@v2 - with: - skip: guide_imports.json - ignore_words_list: ${{ steps.extract_ignore_words.outputs.ignore_words_list }} diff --git a/.github/workflows/_lint.yml b/.github/workflows/_lint.yml index c400393..15d94f7 100644 --- a/.github/workflows/_lint.yml +++ b/.github/workflows/_lint.yml @@ -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 @@ -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. @@ -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 @@ -81,4 +83,4 @@ jobs: - name: Analysing the code with our lint working-directory: ${{ inputs.working-directory }} run: | - make lint + just lint diff --git a/.github/workflows/_release.yml b/.github/workflows/_release.yml index 9535951..63c9e02 100644 --- a/.github/workflows/_release.yml +++ b/.github/workflows/_release.yml @@ -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. @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 8e87ce6..e463a1b 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -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 @@ -35,9 +35,11 @@ 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 @@ -45,7 +47,7 @@ jobs: - name: Run core tests shell: bash run: | - make test + just test - name: Start local Atlas working-directory: . @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ace9dd6..fe133c5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 @@ -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 @@ -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. @@ -53,7 +55,7 @@ this, please raise an issue. To run the integration tests: ```bash -make integration_test +just integration_test ``` ### Formatting and Linting @@ -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. @@ -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. diff --git a/libs/langchain-mongodb/Makefile b/libs/langchain-mongodb/Makefile deleted file mode 100644 index adf2008..0000000 --- a/libs/langchain-mongodb/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -.PHONY: all lint test tests integration_tests docker_tests help extended_tests - -# Default target executed when no arguments are given to make. -all: help - -install: - poetry install --with dev - -# Define a variable for the test file path. -TEST_FILE ?= tests/unit_tests/ -integration_test integration_tests: TEST_FILE=tests/integration_tests/ - -test tests integration_test integration_tests: - poetry run pytest $(TEST_FILE) - -test_watch: - poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE) - - -###################### -# LINTING AND FORMATTING -###################### - -lint: - poetry run pre-commit run ruff --files . - -typing: - poetry run mypy --files . - -codespell: - pre-commit run --hook-stage manual codespell --files . - - -###################### -# HELP -###################### - -help: - @echo '----' - @echo 'install - install the package in dev mode' - @echo 'lint - run linter and formatter' - @echo 'typing - run type check' - @echo 'test - run unit tests' - @echo 'integration_test - run integration tests' - @echo 'test TEST_FILE= - run all tests in file' diff --git a/libs/langchain-mongodb/justfile b/libs/langchain-mongodb/justfile new file mode 100644 index 0000000..9e78664 --- /dev/null +++ b/libs/langchain-mongodb/justfile @@ -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 diff --git a/libs/langgraph-checkpoint-mongodb/Makefile b/libs/langgraph-checkpoint-mongodb/Makefile deleted file mode 100644 index 411a7dd..0000000 --- a/libs/langgraph-checkpoint-mongodb/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -.PHONY: test lint format help - -# Default target executed when no arguments are given to make. -all: help - -install: - poetry install --with dev - -###################### -# TESTING AND COVERAGE -###################### - -# Define a variable for the test file path. -TEST_FILE ?= tests/unit_tests/ -integration_test integration_tests: TEST_FILE=tests/integration_tests/ - - -test tests integration_test integration_tests: - poetry run pytest $(TEST_FILE) - -###################### -# LINTING AND FORMATTING -###################### - -lint: - poetry run pre-commit run ruff --files . - -typing: - poetry run mypy --files . - -codespell: - pre-commit run --hook-stage manual codespell --files . - -###################### -# HELP -###################### - -help: - @echo '----' - @echo 'install - install the package in dev mode' - @echo 'lint - run linter and formatter' - @echo 'typing - run type check' - @echo 'test - run unit tests' - @echo 'integration_test - run integration tests' - @echo 'test TEST_FILE= - run all tests in file' diff --git a/libs/langgraph-checkpoint-mongodb/justfile b/libs/langgraph-checkpoint-mongodb/justfile new file mode 100644 index 0000000..9e78664 --- /dev/null +++ b/libs/langgraph-checkpoint-mongodb/justfile @@ -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