api-tests.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. with:
  26. fetch-depth: 0
  27. persist-credentials: false
  28. - name: Setup Poetry and Python ${{ matrix.python-version }}
  29. uses: ./.github/actions/setup-poetry
  30. with:
  31. python-version: ${{ matrix.python-version }}
  32. poetry-lockfile: api/poetry.lock
  33. - name: Check Poetry lockfile
  34. run: |
  35. poetry check -C api --lock
  36. poetry show -C api
  37. - name: Install dependencies
  38. run: poetry install -C api --with dev
  39. - name: Check dependencies in pyproject.toml
  40. run: poetry run -P api bash dev/pytest/pytest_artifacts.sh
  41. - name: Run Unit tests
  42. run: poetry run -P api bash dev/pytest/pytest_unit_tests.sh
  43. - name: Run dify config tests
  44. run: poetry run -P api python dev/pytest/pytest_config_tests.py
  45. - name: Run mypy
  46. run: |
  47. poetry run -C api python -m mypy --install-types --non-interactive .
  48. - name: Set up dotenvs
  49. run: |
  50. cp docker/.env.example docker/.env
  51. cp docker/middleware.env.example docker/middleware.env
  52. - name: Expose Service Ports
  53. run: sh .github/workflows/expose_service_ports.sh
  54. - name: Set up Sandbox
  55. uses: hoverkraft-tech/compose-action@v2.0.2
  56. with:
  57. compose-file: |
  58. docker/docker-compose.middleware.yaml
  59. services: |
  60. sandbox
  61. ssrf_proxy
  62. - name: Run Workflow
  63. run: poetry run -P api bash dev/pytest/pytest_workflow.sh