unit_tests.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. name: unit-tests
  2. concurrency:
  3. group: ${{ github.workflow }}-${{ github.event.pull_request.id }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. branches: ["main"]
  8. paths-ignore:
  9. - "**/*.md"
  10. pull_request:
  11. branches: ["main"]
  12. paths-ignore:
  13. - "**/*.md"
  14. permissions:
  15. contents: read
  16. defaults:
  17. run:
  18. shell: bash
  19. jobs:
  20. unit-tests:
  21. timeout-minutes: 30
  22. strategy:
  23. fail-fast: false
  24. matrix:
  25. os: [ubuntu-latest, windows-latest]
  26. python-version: ["3.10", "3.11", "3.12", "3.13"]
  27. runs-on: ${{ matrix.os }}
  28. # Service containers to run with `runner-job`
  29. services:
  30. # Label used to access the service container
  31. redis:
  32. image: ${{ matrix.os == 'ubuntu-latest' && 'redis' || '' }}
  33. # Set health checks to wait until redis has started
  34. options: >-
  35. --health-cmd "redis-cli ping"
  36. --health-interval 10s
  37. --health-timeout 5s
  38. --health-retries 5
  39. ports:
  40. # Maps port 6379 on service container to the host
  41. - 6379:6379
  42. steps:
  43. - uses: actions/checkout@v4
  44. - uses: ./.github/actions/setup_build_env
  45. with:
  46. python-version: ${{ matrix.python-version }}
  47. run-uv-sync: true
  48. - name: Run unit tests
  49. run: |
  50. export PYTHONUNBUFFERED=1
  51. uv run pytest tests/units --cov --no-cov-on-fail --cov-report=
  52. - name: Run unit tests w/ redis
  53. if: ${{ matrix.os == 'ubuntu-latest' }}
  54. run: |
  55. export PYTHONUNBUFFERED=1
  56. export REDIS_URL=redis://localhost:6379
  57. uv run pytest tests/units --cov --no-cov-on-fail --cov-report=
  58. # Change to explicitly install v1 when reflex-hosting-cli is compatible with v2
  59. - name: Run unit tests w/ pydantic v1
  60. run: |
  61. export PYTHONUNBUFFERED=1
  62. uv pip install "pydantic~=1.10"
  63. uv run pytest tests/units --cov --no-cov-on-fail --cov-report=
  64. - name: Generate coverage report
  65. run: uv run coverage html
  66. unit-tests-macos:
  67. timeout-minutes: 30
  68. if: github.event_name == 'push' && github.ref == 'refs/heads/main'
  69. strategy:
  70. fail-fast: false
  71. matrix:
  72. python-version: ["3.10", "3.11", "3.12", "3.13"]
  73. runs-on: macos-latest
  74. steps:
  75. - uses: actions/checkout@v4
  76. - uses: ./.github/actions/setup_build_env
  77. with:
  78. python-version: ${{ matrix.python-version }}
  79. run-uv-sync: true
  80. - name: Run unit tests
  81. run: |
  82. export PYTHONUNBUFFERED=1
  83. uv run pytest tests/units --cov --no-cov-on-fail --cov-report=
  84. - name: Run unit tests w/ pydantic v1
  85. run: |
  86. export PYTHONUNBUFFERED=1
  87. uv pip install "pydantic~=1.10"
  88. uv run pytest tests/units --cov --no-cov-on-fail --cov-report=