Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

chore: Consolidate CI style checks (#1936)

Matthew Zhouf93dc8250b6c
diff --git a/.github/workflows/autoflake_format.yml b/.github/workflows/autoflake_format.yml
deleted file mode 100644
index bfdaae1bc..000000000
--- a/.github/workflows/autoflake_format.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: Code Formatter (autoflake)
-
-on:
- pull_request:
- paths:
- - '**.py'
- workflow_dispatch:
-
-jobs:
- autoflake-check:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: "Setup Python, Poetry and Dependencies"
- uses: packetcoders/action-setup-cache-python-poetry@main
- with:
- python-version: "3.12"
- poetry-version: "1.8.2"
- install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands
-
- - name: Run Autoflake
- id: autoflake
- run: poetry run autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive --ignore-init-module-imports .
- continue-on-error: true
-
- - name: Check Autoflake Output
- if: steps.autoflake.outcome == 'failure'
- run: |
- poetry run autoflake --version
- poetry run python --version
- echo "Autoflake check failed. To fix, please run 'poetry run autoflake .'"
- exit 1
diff --git a/.github/workflows/black_format.yml b/.github/workflows/black_format.yml
deleted file mode 100644
index 5aeea4d57..000000000
--- a/.github/workflows/black_format.yml
+++ /dev/null
@@ -1,36 +0,0 @@
-name: Code Formatter (Black)
-on:
- pull_request:
- paths:
- - '**.py'
- workflow_dispatch:
-jobs:
- black-check:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- ref: ${{ github.head_ref }} # Checkout the PR branch
- fetch-depth: 0 # Fetch all history for all branches and tags
- - name: "Setup Python, Poetry and Dependencies"
- uses: packetcoders/action-setup-cache-python-poetry@main
- with:
- python-version: "3.12"
- poetry-version: "1.8.2"
- install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands
- - name: Run Black
- id: black
- run: poetry run black --check .
- continue-on-error: true
- - name: Auto-fix with Black and commit
- if: steps.black.outcome == 'failure' && !contains(github.event.pull_request.labels.*.name, 'check-only')
- run: |
- poetry run black .
- git config --local user.email "[email protected]"
- git config --local user.name "GitHub Action"
- git diff --quiet && git diff --staged --quiet || (git add -A && git commit -m "Apply Black formatting")
- git push
- - name: Error if 'check-only' label is present
- if: steps.black.outcome == 'failure' && contains(github.event.pull_request.labels.*.name, 'check-only')
- run: echo "Black formatting check failed. Please run 'black .' locally to fix formatting issues." && exit 1
diff --git a/.github/workflows/code_style_checks.yml b/.github/workflows/code_style_checks.yml
new file mode 100644
index 000000000..2fd9d9b90
--- /dev/null
+++ b/.github/workflows/code_style_checks.yml
@@ -0,0 +1,57 @@
+name: Code Style Checks
+
+on:
+ pull_request:
+ paths:
+ - '**.py'
+ pull_request_target:
+ types:
+ - opened
+ - edited
+ - synchronize
+ workflow_dispatch:
+
+permissions:
+ pull-requests: read
+
+jobs:
+ validation-checks:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: ["3.12"] # Adjust Python version matrix if needed
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.head_ref }} # Checkout the PR branch
+ fetch-depth: 0 # Fetch all history for all branches and tags
+
+ - name: "Setup Python, Poetry and Dependencies"
+ uses: packetcoders/action-setup-cache-python-poetry@main
+ with:
+ python-version: ${{ matrix.python-version }}
+ poetry-version: "1.8.2"
+ install-args: "-E dev -E postgres -E milvus -E external-tools -E tests" # Adjust as necessary
+
+ - name: Validate PR Title
+ uses: amannn/action-semantic-pull-request@v5
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Run Pyright
+ uses: jakebailey/pyright-action@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ level: "error"
+ continue-on-error: true
+
+ - name: Run isort
+ run: poetry run isort --profile black --check-only --diff .
+
+ - name: Run Black
+ run: poetry run black --check .
+
+ - name: Run Autoflake
+ run: poetry run autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive --ignore-init-module-imports .
diff --git a/.github/workflows/isort_format.yml b/.github/workflows/isort_format.yml
deleted file mode 100644
index 670ec01e3..000000000
--- a/.github/workflows/isort_format.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-name: Code Formatter (isort)
-on:
- pull_request:
- paths:
- - '**.py'
- workflow_dispatch:
-jobs:
- isort-check:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- ref: ${{ github.head_ref }} # Checkout the PR branch
- fetch-depth: 0 # Fetch all history for all branches and tags
- - name: "Setup Python, Poetry and Dependencies"
- uses: packetcoders/action-setup-cache-python-poetry@main
- with:
- python-version: "3.12"
- poetry-version: "1.8.2"
- install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands
- - name: Run isort
- id: isort
- run: |
- output=$(poetry run isort --profile black --check-only --diff . | grep -v "Skipped" || true)
- echo "$output"
- if [ -n "$output" ]; then
- echo "isort_changed=true" >> $GITHUB_OUTPUT
- else
- echo "isort_changed=false" >> $GITHUB_OUTPUT
- fi
- continue-on-error: true
- - name: Auto-fix with isort and commit
- if: steps.isort.outputs.isort_changed == 'true' && !contains(github.event.pull_request.labels.*.name, 'check-only')
- run: |
- poetry run isort --profile black .
- git config --local user.email "[email protected]"
- git config --local user.name "GitHub Action"
- if [[ -n $(git status -s) ]]; then
- git add -A
- git commit -m "Apply isort import ordering"
- git push
- else
- echo "No changes to commit"
- fi
- - name: Error if 'check-only' label is present and changes are needed
- if: steps.isort.outputs.isort_changed == 'true' && contains(github.event.pull_request.labels.*.name, 'check-only')
- run: echo "Isort check failed. Please run 'isort .' locally to fix import orders." && exit 1
diff --git a/.github/workflows/pyright_types.yml b/.github/workflows/pyright_types.yml
deleted file mode 100644
index 862c73d56..000000000
--- a/.github/workflows/pyright_types.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-name: Code Formatter (Pyright type checking)"
-on:
- pull_request:
- paths:
- - '**.py'
-
-permissions:
- contents: read
- pull-requests: read
-
-jobs:
- pyright:
- name: "Pyright types check"
- strategy:
- matrix:
- python-version: ["3.11"]
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: "Setup Python, Poetry and Dependencies"
- uses: packetcoders/action-setup-cache-python-poetry@main
- with:
- python-version: ${{matrix.python-version}}
- poetry-version: "1.7.1"
- install-args: "-E dev" # TODO: change this to --group dev when PR #842 lands
-
- - name: "Add Poetry venv to PATH"
- run: 'echo "$(poetry env info --path)/bin" >> $GITHUB_PATH'
-
- - name: "Run Pyright"
- uses: jakebailey/pyright-action@v2
- with:
- python-version: ${{matrix.python-version}}
- level: "error"
- continue-on-error: true # TODO: remove once the repo has been corrected for pyright
diff --git a/.github/workflows/semantic-prs.yml b/.github/workflows/semantic-prs.yml
deleted file mode 100644
index fbcd34f43..000000000
--- a/.github/workflows/semantic-prs.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: Validate Pull Request Format
-
-on:
- pull_request_target:
- types:
- - opened
- - edited
- - synchronize
-
-permissions:
- pull-requests: read
-
-jobs:
- main:
- name: Validate PR title
- runs-on: ubuntu-latest
- steps:
- - uses: amannn/action-semantic-pull-request@v5
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 107b6c6e5..df93bb4bf 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -56,7 +56,7 @@ def test_letta_run_create_new_agent(swap_letta_config):
except (pexpect.TIMEOUT, pexpect.EOF):
print("[WARNING] Embedding model selection step was skipped.")
- child.expect("Created new agent", timeout=10)
+ child.expect("Created new agent", timeout=20)
child.sendline("")
# Get initial response