Adds an example of a good "general case" SQL tool: * enforces read-only mode * hints to the LLM to discover the tables and schemas for the tables it needs before any query * uses RetryableToolErrors to hint to the LLM about what to do next Docs: https://github.com/ArcadeAI/docs/pull/345 For testing, `TEST_POSTGRES_DATABASE_CONNECTION_STRING` has been set in the repo (from Neon). details in 1 password. <img width="1178" height="1091" alt="464977013-49aff5e5-e301-4ca0-83b5-3ea742db2283" src="https://github.com/user-attachments/assets/9344c27b-015d-4b91-907e-84f2e4193e16" />
64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
name: Test Toolkits
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
tool_matrix: ${{ steps.get-toolkits.outputs.toolkits }}
|
|
steps:
|
|
- name: Check out
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get toolkits
|
|
id: get-toolkits
|
|
run: |
|
|
# Find all directories in toolkits/ that have a pyproject.toml
|
|
TOOLKITS=$(find toolkits -maxdepth 1 -type d -not -name "toolkits" -exec test -f {}/pyproject.toml \; -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')
|
|
echo "Found toolkits: $TOOLKITS"
|
|
echo "toolkits=$TOOLKITS" >> $GITHUB_OUTPUT
|
|
|
|
test-toolkits:
|
|
needs: setup
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
toolkit: ${{ fromJson(needs.setup.outputs.tool_matrix) }}
|
|
fail-fast: true
|
|
steps:
|
|
- name: Check out
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up the environment
|
|
uses: ./.github/actions/setup-uv-env
|
|
|
|
- name: Install toolkit dependencies
|
|
working-directory: toolkits/${{ matrix.toolkit }}
|
|
run: uv pip install -e ".[dev]"
|
|
|
|
- name: Check toolkit
|
|
working-directory: toolkits/${{ matrix.toolkit }}
|
|
run: |
|
|
uv run --active pre-commit run -a
|
|
uv run --active mypy --config-file=pyproject.toml
|
|
|
|
- name: Test toolkit
|
|
working-directory: toolkits/${{ matrix.toolkit }}
|
|
env:
|
|
TEST_POSTGRES_DATABASE_CONNECTION_STRING: ${{ secrets.TEST_POSTGRES_DATABASE_CONNECTION_STRING }} # TODO: dynamically only load the `TEST_${{ matrix.toolkit }}_DATABASE_CONNECTION_STRING secret`
|
|
run: |
|
|
# Run pytest and capture exit code
|
|
uv run --active pytest -W ignore -v --cov=arcade_${{ matrix.toolkit }} --cov-report=xml || EXIT_CODE=$?
|
|
|
|
if [ "${EXIT_CODE:-0}" -eq 5 ]; then
|
|
echo "No tests found for toolkit ${{ matrix.toolkit }}, skipping..."
|
|
exit 0
|
|
elif [ "${EXIT_CODE:-0}" -ne 0 ]; then
|
|
exit ${EXIT_CODE}
|
|
fi
|