You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api-tests.yml 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. defaults:
  18. run:
  19. shell: bash
  20. strategy:
  21. matrix:
  22. python-version:
  23. - "3.11"
  24. - "3.12"
  25. steps:
  26. - name: Checkout code
  27. uses: actions/checkout@v4
  28. with:
  29. fetch-depth: 0
  30. persist-credentials: false
  31. - name: Setup UV and Python
  32. uses: ./.github/actions/setup-uv
  33. with:
  34. python-version: ${{ matrix.python-version }}
  35. uv-lockfile: api/uv.lock
  36. - name: Check UV lockfile
  37. run: uv lock --project api --check
  38. - name: Install dependencies
  39. run: uv sync --project api --group dev
  40. - name: Run Unit tests
  41. run: uv run --project api bash dev/pytest/pytest_unit_tests.sh
  42. - name: Run dify config tests
  43. run: uv run --project api dev/pytest/pytest_config_tests.py
  44. - name: MyPy Cache
  45. uses: actions/cache@v4
  46. with:
  47. path: api/.mypy_cache
  48. key: mypy-${{ matrix.python-version }}-${{ runner.os }}-${{ hashFiles('api/uv.lock') }}
  49. - name: Run MyPy Checks
  50. run: dev/mypy-check
  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: uv run --project api bash dev/pytest/pytest_workflow.sh