api-tests.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. name: Run Pytest
  2. on:
  3. pull_request:
  4. branches:
  5. - main
  6. paths:
  7. - api/**
  8. - docker/**
  9. - .github/workflows/api-tests.yml
  10. concurrency:
  11. group: api-tests-${{ github.head_ref || github.run_id }}
  12. cancel-in-progress: true
  13. jobs:
  14. test:
  15. name: API Tests
  16. runs-on: ubuntu-latest
  17. strategy:
  18. matrix:
  19. python-version:
  20. - "3.11"
  21. - "3.12"
  22. steps:
  23. - name: Checkout code
  24. uses: actions/checkout@v4
  25. - name: Setup Poetry and Python ${{ matrix.python-version }}
  26. uses: ./.github/actions/setup-poetry
  27. with:
  28. python-version: ${{ matrix.python-version }}
  29. poetry-lockfile: api/poetry.lock
  30. - name: Check Poetry lockfile
  31. run: |
  32. poetry check -C api --lock
  33. poetry show -C api
  34. - name: Install dependencies
  35. run: poetry install -C api --with dev
  36. - name: Check dependencies in pyproject.toml
  37. run: poetry run -C api bash dev/pytest/pytest_artifacts.sh
  38. - name: Run Unit tests
  39. run: poetry run -C api bash dev/pytest/pytest_unit_tests.sh
  40. - name: Run ModelRuntime
  41. run: poetry run -C api bash dev/pytest/pytest_model_runtime.sh
  42. - name: Run dify config tests
  43. run: poetry run -C api python dev/pytest/pytest_config_tests.py
  44. - name: Run Tool
  45. run: poetry run -C api bash dev/pytest/pytest_tools.sh
  46. - name: Run mypy
  47. run: |
  48. pushd api
  49. poetry run python -m mypy --install-types --non-interactive .
  50. popd
  51. - name: Set up dotenvs
  52. run: |
  53. cp docker/.env.example docker/.env
  54. cp docker/middleware.env.example docker/middleware.env
  55. - name: Expose Service Ports
  56. run: sh .github/workflows/expose_service_ports.sh
  57. - name: Set up Sandbox
  58. uses: hoverkraft-tech/compose-action@v2.0.2
  59. with:
  60. compose-file: |
  61. docker/docker-compose.middleware.yaml
  62. services: |
  63. sandbox
  64. ssrf_proxy
  65. - name: Run Workflow
  66. run: poetry run -C api bash dev/pytest/pytest_workflow.sh