parent
ff29a6b816
commit
415a5cf644
@ -1,11 +0,0 @@
|
|||||||
[flake8]
|
|
||||||
max-line-length = 127
|
|
||||||
extend-ignore = E203
|
|
||||||
per-file-ignores =
|
|
||||||
# Most of this is just long strings
|
|
||||||
./swarms/prompts/**.py: E501 W293 W291
|
|
||||||
./swarms/__init__.py: F401
|
|
||||||
exclude =
|
|
||||||
./playground
|
|
||||||
./tests
|
|
||||||
./scripts
|
|
@ -0,0 +1,37 @@
|
|||||||
|
name: "Init Environment"
|
||||||
|
description: "Initialize environment for tests"
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Checkout actions
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install and configure Poetry
|
||||||
|
uses: snok/install-poetry@v1
|
||||||
|
with:
|
||||||
|
virtualenvs-create: true
|
||||||
|
virtualenvs-in-project: true
|
||||||
|
installer-parallel: true
|
||||||
|
|
||||||
|
- name: Load cached venv
|
||||||
|
id: cached-poetry-dependencies
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: .venv
|
||||||
|
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||||
|
run: poetry install --no-interaction --no-root --with test --with dev --all-extras
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Activate venv
|
||||||
|
run: |
|
||||||
|
source .venv/bin/activate
|
||||||
|
echo PATH=$PATH >> $GITHUB_ENV
|
||||||
|
shell: bash
|
@ -1,52 +1,14 @@
|
|||||||
---
|
---
|
||||||
documentation:
|
# this is a config file for the github action labeler
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: ["docs/**", "*.md"]
|
# Add 'label1' to any changes within 'example' folder or any subfolders
|
||||||
tests:
|
example_change:
|
||||||
- changed-files:
|
- example/**
|
||||||
- any-glob-to-any-file: "tests/**"
|
|
||||||
agents:
|
# Add 'label2' to any file changes within 'example2' folder
|
||||||
- changed-files:
|
example2_change: example2/*
|
||||||
- any-glob-to-any-file: "swarms/agents/**"
|
|
||||||
artifacts:
|
# Add label3 to any change to .txt files within the entire repository.
|
||||||
- changed-files:
|
# Quotation marks are required for the leading asterisk
|
||||||
- any-glob-to-any-file: "swarms/artifacts/**"
|
text_files:
|
||||||
chunkers:
|
- '**/*.txt'
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/chunkers/**"
|
|
||||||
cli:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/cli/**"
|
|
||||||
loaders:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/loaders/**"
|
|
||||||
memory:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/memory/**"
|
|
||||||
models:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/models/**"
|
|
||||||
prompts:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/prompts/**"
|
|
||||||
structs:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/structs/**"
|
|
||||||
telemetry:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/telemetry/**"
|
|
||||||
tokenizers:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/tokenizers/**"
|
|
||||||
tools:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/tools/**"
|
|
||||||
utils:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/utils/**"
|
|
||||||
workers:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "swarms/workers/**"
|
|
||||||
rust:
|
|
||||||
- changed-files:
|
|
||||||
- any-glob-to-any-file: "**/*.rs"
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
---
|
|
||||||
name: "Setup"
|
|
||||||
description: Setup the environment for the project
|
|
||||||
inputs:
|
|
||||||
python-version:
|
|
||||||
description: "Python version to use"
|
|
||||||
required: false
|
|
||||||
default: "3.10"
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Free up disk space
|
|
||||||
run: |
|
|
||||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
|
|
||||||
sudo docker image prune --all --force
|
|
||||||
shell: bash
|
|
||||||
- name: Set up Python ${{ inputs.python-version }}
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: ${{ inputs.python-version }}
|
|
||||||
- name: Install and configure Poetry
|
|
||||||
uses: snok/install-poetry@v1
|
|
||||||
with:
|
|
||||||
installer-parallel: true
|
|
||||||
- name: Cache Poetry cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pypoetry
|
|
||||||
key: poetry-cache
|
|
||||||
-${{ runner.os }}
|
|
||||||
-${{ steps.setup_python.outputs.python-version }}
|
|
||||||
-${{ env.POETRY_VERSION }}
|
|
||||||
- name: Cache Packages
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: ~/.local
|
|
||||||
key: poetry-local
|
|
||||||
-${{ runner.os }}
|
|
||||||
-${{ steps.setup_python.outputs.python-version }}
|
|
||||||
-${{ hashFiles('**/poetry.lock')}}
|
|
||||||
-${{ hashFiles('.github/workflows/*.yml') }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: POETRY_VIRTUALENVS_CREATE=false poetry install
|
|
||||||
shell: bash
|
|
@ -1,20 +1,22 @@
|
|||||||
---
|
|
||||||
# This workflow will triage pull requests and apply a label based on the
|
# This workflow will triage pull requests and apply a label based on the
|
||||||
# paths that are modified in the pull request.
|
# paths that are modified in the pull request.
|
||||||
#
|
#
|
||||||
# To use this workflow, you will need to set up a .github/labeler.yml
|
# To use this workflow, you will need to set up a .github/labeler.yml
|
||||||
# file with configuration. For more information, see:
|
# file with configuration. For more information, see:
|
||||||
# https://github.com/actions/labeler
|
# https://github.com/actions/labeler
|
||||||
|
|
||||||
name: Labeler
|
name: Labeler
|
||||||
on: [pull_request_target]
|
on: [pull_request_target]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
label:
|
label:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/labeler@v5
|
- uses: actions/labeler@v5
|
||||||
with:
|
with:
|
||||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
sync-labels: true
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
name: "PR Labeler"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: ["opened", "reopened", "ready_for_review"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
triage:
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: write
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/labeler@v5
|
||||||
|
if: ${{ github.event.pull_request.draft == false }}
|
@ -0,0 +1,30 @@
|
|||||||
|
name: Pull Request Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install swarms
|
||||||
|
pip install pytest
|
||||||
|
|
||||||
|
- name: Run tests and checks
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
|
pylint swarms
|
@ -0,0 +1,23 @@
|
|||||||
|
name: Pylint
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.8", "3.9", "3.10"]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pylint
|
||||||
|
- name: Analysing the code with pylint
|
||||||
|
run: |
|
||||||
|
pylint $(git ls-files '*.py')
|
@ -0,0 +1,39 @@
|
|||||||
|
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||||
|
|
||||||
|
name: Python application
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python 3.10
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install flake8 pytest swarms
|
||||||
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
@ -0,0 +1,41 @@
|
|||||||
|
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
||||||
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||||
|
|
||||||
|
name: Python package
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version: ["3.7", "3.9", "3.10", "3.11"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install --upgrade swarms
|
||||||
|
python -m pip install flake8 pytest swarms
|
||||||
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
pytest
|
@ -1,49 +1,27 @@
|
|||||||
---
|
|
||||||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||||
#
|
#
|
||||||
# You can adjust the behavior by modifying this file.
|
# You can adjust the behavior by modifying this file.
|
||||||
# For more information, see:
|
# For more information, see:
|
||||||
# https://github.com/actions/stale
|
# https://github.com/actions/stale
|
||||||
name: Mark stale issues and pull requests
|
name: Mark stale issues and pull requests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# Scheduled to run at 1.30 UTC everyday
|
- cron: '26 12 * * *'
|
||||||
- cron: "30 1 * * *"
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
issues: write
|
issues: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
|
||||||
- uses: actions/stale@v9
|
|
||||||
with:
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
days-before-issue-stale: 14
|
|
||||||
days-before-issue-close: 14
|
|
||||||
stale-issue-label: "status:stale"
|
|
||||||
close-issue-reason: not_planned
|
|
||||||
any-of-labels: "status:awaiting user response,status:more data needed"
|
|
||||||
stale-issue-message: >
|
|
||||||
Marking this issue as stale since it has been open for 14 days with no activity. This issue
|
|
||||||
will be closed if no further activity occurs.
|
|
||||||
|
|
||||||
close-issue-message: >
|
steps:
|
||||||
This issue was closed because it has been inactive for 28 days. Please post a new issue if
|
- uses: actions/stale@v9
|
||||||
you need further assistance. Thanks!
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
days-before-pr-stale: 14
|
stale-issue-message: 'Stale issue message'
|
||||||
days-before-pr-close: 14
|
stale-pr-message: 'Stale pull request message'
|
||||||
stale-pr-label: "status:stale"
|
stale-issue-label: 'no-issue-activity'
|
||||||
stale-pr-message: >
|
stale-pr-label: 'no-pr-activity'
|
||||||
Marking this pull request as stale since it has been open for 14 days with no activity. This
|
|
||||||
PR will be closed if no further activity occurs.
|
|
||||||
|
|
||||||
close-pr-message: >
|
|
||||||
This pull request was closed because it has been inactive for 28 days. Please open a new
|
|
||||||
pull request if you need furtherassistance. Thanks!
|
|
||||||
|
|
||||||
# Label that can be assigned to issues to exclude them from being marked as stale
|
|
||||||
exempt-issue-labels: "override-stale"
|
|
||||||
# Label that can be assigned to PRs to exclude them from being marked as stale
|
|
||||||
exempt-pr-labels: "override-stale"
|
|
@ -0,0 +1,49 @@
|
|||||||
|
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||||
|
#
|
||||||
|
# You can adjust the behavior by modifying this file.
|
||||||
|
# For more information, see:
|
||||||
|
# https://github.com/actions/stale
|
||||||
|
name: Mark stale issues and pull requests
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# Scheduled to run at 1.30 UTC everyday
|
||||||
|
- cron: '30 1 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v9
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
days-before-issue-stale: 14
|
||||||
|
days-before-issue-close: 14
|
||||||
|
stale-issue-label: "status:stale"
|
||||||
|
close-issue-reason: not_planned
|
||||||
|
any-of-labels: "status:awaiting user response,status:more data needed"
|
||||||
|
stale-issue-message: >
|
||||||
|
Marking this issue as stale since it has been open for 14 days with no activity.
|
||||||
|
This issue will be closed if no further activity occurs.
|
||||||
|
close-issue-message: >
|
||||||
|
This issue was closed because it has been inactive for 28 days.
|
||||||
|
Please post a new issue if you need further assistance. Thanks!
|
||||||
|
days-before-pr-stale: 14
|
||||||
|
days-before-pr-close: 14
|
||||||
|
stale-pr-label: "status:stale"
|
||||||
|
stale-pr-message: >
|
||||||
|
Marking this pull request as stale since it has been open for 14 days with no activity.
|
||||||
|
This PR will be closed if no further activity occurs.
|
||||||
|
close-pr-message: >
|
||||||
|
This pull request was closed because it has been inactive for 28 days.
|
||||||
|
Please open a new pull request if you need further assistance. Thanks!
|
||||||
|
# Label that can be assigned to issues to exclude them from being marked as stale
|
||||||
|
exempt-issue-labels: 'override-stale'
|
||||||
|
# Label that can be assigned to PRs to exclude them from being marked as stale
|
||||||
|
exempt-pr-labels: "override-stale"
|
||||||
|
|
@ -1,16 +1,110 @@
|
|||||||
---
|
name: test
|
||||||
name: build
|
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
POETRY_VERSION: "1.4.2"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version:
|
||||||
|
- "3.8"
|
||||||
|
- "3.9"
|
||||||
|
- "3.10"
|
||||||
|
- "3.11"
|
||||||
|
test_type:
|
||||||
|
- "core"
|
||||||
|
- "extended"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: "snok/install-poetry@v1"
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
poetry-version: "1.4.2"
|
||||||
|
cache-key: ${{ matrix.test_type }}
|
||||||
|
install-command:
|
||||||
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
|
echo "Running core tests, installing dependencies with poetry..."
|
||||||
|
poetry install
|
||||||
|
else
|
||||||
|
echo "Running extended tests, installing dependencies with poetry..."
|
||||||
|
poetry install -E extended_testing
|
||||||
|
fi
|
||||||
|
- name: Run ${{matrix.test_type}} tests
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
|
make test
|
||||||
|
else
|
||||||
|
make extended_tests
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
name: Python ${{ matrix.python-version }} ${{ matrix.test_type }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: "./.github/actions/poetry_setup"
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
poetry-version: "1.4.2"
|
||||||
|
cache-key: ${{ matrix.test_type }}
|
||||||
|
install-command: |
|
||||||
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
|
echo "Running core tests, installing dependencies with poetry..."
|
||||||
|
poetry install
|
||||||
|
else
|
||||||
|
echo "Running extended tests, installing dependencies with poetry..."
|
||||||
|
poetry install -E extended_testing
|
||||||
|
fi
|
||||||
|
- name: Run ${{matrix.test_type}} tests
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
|
make test
|
||||||
|
else
|
||||||
|
make extended_tests
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version:
|
||||||
|
- "3.8"
|
||||||
|
- "3.9"
|
||||||
|
- "3.10"
|
||||||
|
- "3.11"
|
||||||
|
test_type:
|
||||||
|
- "core"
|
||||||
|
- "extended"
|
||||||
|
name: Python ${{ matrix.python-version }} ${{ matrix.test_type }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/library/setup
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
- name: Install dependencies
|
uses: "./.github/actions/poetry_setup"
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
poetry-version: "1.4.2"
|
||||||
|
cache-key: ${{ matrix.test_type }}
|
||||||
|
install-command: |
|
||||||
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
|
echo "Running core tests, installing dependencies with poetry..."
|
||||||
|
poetry install
|
||||||
|
else
|
||||||
|
echo "Running extended tests, installing dependencies with poetry..."
|
||||||
|
poetry install -E extended_testing
|
||||||
|
fi
|
||||||
|
- name: Run ${{matrix.test_type}} tests
|
||||||
run: |
|
run: |
|
||||||
pip install pytest
|
if [ "${{ matrix.test_type }}" == "core" ]; then
|
||||||
- name: Run Python unit tests
|
make test
|
||||||
run: pytest
|
else
|
||||||
- name: Verify that the Docker image for the action builds
|
make extended_tests
|
||||||
run: docker build . --file Dockerfile
|
fi
|
||||||
|
shell: bash
|
@ -1,28 +1,81 @@
|
|||||||
---
|
|
||||||
# Notebook-related checks
|
# Notebook-related checks
|
||||||
|
|
||||||
name: Presubmit checks
|
name: Presubmit checks
|
||||||
on: [push, pull_request]
|
|
||||||
|
on:
|
||||||
|
# Relevant PRs
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "swarms/**"
|
||||||
|
- "tests/**"
|
||||||
|
# Allow manual runs
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Disabled until google/pytype/issues/151 is resolved
|
test3_11:
|
||||||
# pytype3_10:
|
name: Test Py3.11
|
||||||
# name: pytype 3.10
|
runs-on: ubuntu-latest
|
||||||
# runs-on: ubuntu-latest
|
steps:
|
||||||
# steps:
|
- uses: actions/checkout@v4
|
||||||
# - uses: actions/checkout@v4
|
- uses: actions/setup-python@v5
|
||||||
# - uses: ./.github/library/setup
|
with:
|
||||||
# - name: Install pytype
|
python-version: '3.11'
|
||||||
# run: pip install -q pytype
|
- name: Run tests
|
||||||
# - name: Run pytype
|
run: |
|
||||||
# run: pytype ./swarms
|
python --version
|
||||||
|
pip install .[dev]
|
||||||
|
python -m pytest
|
||||||
|
test3_10:
|
||||||
|
name: Test Py3.10
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
python --version
|
||||||
|
pip install -q .[dev]
|
||||||
|
python -m pytest
|
||||||
|
test3_9:
|
||||||
|
name: Test Py3.9
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.9'
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
python --version
|
||||||
|
pip install .[dev]
|
||||||
|
python -m pytest
|
||||||
|
pytype3_10:
|
||||||
|
name: pytype 3.10
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
- name: Run pytype
|
||||||
|
run: |
|
||||||
|
python --version
|
||||||
|
pip install .[dev]
|
||||||
|
pip install -q gspread ipython
|
||||||
|
pytype
|
||||||
format:
|
format:
|
||||||
name: Check format with black
|
name: Check format with black
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/library/setup
|
- uses: actions/setup-python@v5
|
||||||
- name: Check format
|
with:
|
||||||
run: |
|
python-version: '3.11'
|
||||||
python --version
|
- name: Check format
|
||||||
pip install -q .
|
run: |
|
||||||
pip install -q black
|
python --version
|
||||||
black . --check
|
pip install -q .
|
||||||
|
pip install -q black
|
||||||
|
black . --check
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
name: Unit Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install pytest
|
||||||
|
|
||||||
|
- name: Run unit tests
|
||||||
|
run: pytest
|
@ -0,0 +1,36 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.9'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install pytest
|
||||||
|
pip install swarms
|
||||||
|
|
||||||
|
- name: Run Python unit tests
|
||||||
|
run: pytest
|
||||||
|
|
||||||
|
- name: Verify that the Docker image for the action builds
|
||||||
|
run: docker build . --file Dockerfile
|
||||||
|
|
||||||
|
- name: Verify integration test results
|
||||||
|
run: pytest
|
@ -1,19 +1,18 @@
|
|||||||
---
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
rev: 22.3.0
|
rev: 22.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||||
rev: 'v0.0.255'
|
rev: 'v0.0.255'
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: ['----unsafe-fixes']
|
args: [----unsafe-fixes]
|
||||||
- repo: https://github.com/nbQA-dev/nbQA
|
- repo: https://github.com/nbQA-dev/nbQA
|
||||||
rev: 1.6.3
|
rev: 1.6.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: nbqa-black
|
- id: nbqa-black
|
||||||
additional_dependencies: [ipython==8.12, black]
|
additional_dependencies: [ipython==8.12, black]
|
||||||
- id: nbqa-ruff
|
- id: nbqa-ruff
|
||||||
args: ["--ignore=I001"]
|
args: ["--ignore=I001"]
|
||||||
additional_dependencies: [ipython==8.12, ruff]
|
additional_dependencies: [ipython==8.12, ruff]
|
@ -1,11 +1,13 @@
|
|||||||
---
|
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
build:
|
build:
|
||||||
os: ubuntu-22.04
|
os: ubuntu-22.04
|
||||||
tools:
|
tools:
|
||||||
python: "3.11"
|
python: "3.11"
|
||||||
|
|
||||||
mkdocs:
|
mkdocs:
|
||||||
configuration: mkdocs.yml
|
configuration: mkdocs.yml
|
||||||
|
|
||||||
python:
|
python:
|
||||||
install:
|
install:
|
||||||
- requirements: requirements.txt
|
- requirements: requirements.txt
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
---
|
|
||||||
formatter:
|
|
||||||
type: basic
|
|
||||||
include_document_start: true
|
|
||||||
max_line_length: 100
|
|
||||||
pad_line_comments: 2
|
|
@ -1,14 +0,0 @@
|
|||||||
---
|
|
||||||
extends: default
|
|
||||||
|
|
||||||
rules:
|
|
||||||
line-length:
|
|
||||||
max: 127
|
|
||||||
truthy:
|
|
||||||
# GitHub Actions
|
|
||||||
check-keys: false
|
|
||||||
|
|
||||||
ignore:
|
|
||||||
# GH Actions
|
|
||||||
- lib
|
|
||||||
- .venv
|
|
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
|||||||
[pytest]
|
|
||||||
testpaths = tests
|
|
@ -1,10 +0,0 @@
|
|||||||
exclude = ["./playground", "./tests", "./scripts"]
|
|
||||||
line-length = 127
|
|
||||||
|
|
||||||
[lint]
|
|
||||||
ignore = ["E203"]
|
|
||||||
select = ["E", "F", "W"]
|
|
||||||
|
|
||||||
[lint.per-file-ignores]
|
|
||||||
"./swarms/prompts/**.py" = ["E501", "W291", "W293"]
|
|
||||||
"./swarms/__init__.py" = ["F401"]
|
|
@ -0,0 +1,73 @@
|
|||||||
|
# JSON
|
||||||
|
|
||||||
|
# Contents of test_json.py, which must be placed in the `tests/` directory.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from swarms.tokenizers import JSON
|
||||||
|
|
||||||
|
|
||||||
|
# Fixture for reusable JSON schema file paths
|
||||||
|
@pytest.fixture
|
||||||
|
def valid_schema_path(tmp_path):
|
||||||
|
d = tmp_path / "sub"
|
||||||
|
d.mkdir()
|
||||||
|
p = d / "schema.json"
|
||||||
|
p.write_text(
|
||||||
|
'{"type": "object", "properties": {"name": {"type":'
|
||||||
|
' "string"}}}'
|
||||||
|
)
|
||||||
|
return str(p)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def invalid_schema_path(tmp_path):
|
||||||
|
d = tmp_path / "sub"
|
||||||
|
d.mkdir()
|
||||||
|
p = d / "invalid_schema.json"
|
||||||
|
p.write_text("this is not a valid JSON")
|
||||||
|
return str(p)
|
||||||
|
|
||||||
|
|
||||||
|
# This test class must be subclassed as JSON class is abstract
|
||||||
|
class TestableJSON(JSON):
|
||||||
|
def validate(self, data):
|
||||||
|
# Here must be a real validation implementation for testing
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Basic tests
|
||||||
|
def test_initialize_json(valid_schema_path):
|
||||||
|
json_obj = TestableJSON(valid_schema_path)
|
||||||
|
assert json_obj.schema_path == valid_schema_path
|
||||||
|
assert "name" in json_obj.schema["properties"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_schema_failure(invalid_schema_path):
|
||||||
|
with pytest.raises(json.JSONDecodeError):
|
||||||
|
TestableJSON(invalid_schema_path)
|
||||||
|
|
||||||
|
|
||||||
|
# Mocking tests
|
||||||
|
def test_validate_calls_method(monkeypatch):
|
||||||
|
# Mock the validate method to check that it is being called
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Exception tests
|
||||||
|
def test_initialize_with_nonexistent_schema():
|
||||||
|
with pytest.raises(FileNotFoundError):
|
||||||
|
TestableJSON("nonexistent_path.json")
|
||||||
|
|
||||||
|
|
||||||
|
# Tests on different Python versions if applicable
|
||||||
|
# ...
|
||||||
|
|
||||||
|
|
||||||
|
# Grouping tests marked as slow if they perform I/O operations
|
||||||
|
@pytest.mark.slow
|
||||||
|
def test_loading_large_schema():
|
||||||
|
# Test with a large json file
|
||||||
|
pass
|
Loading…
Reference in new issue