action.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Entry conditions:
  2. # - `setup/checkout` has already happened
  3. # - working dir is the root directory of your project (e.g. `reflex/`).
  4. # - You have a `uv.lock` file in the root directory of your project
  5. # - You have a `pyproject.toml` file in the root directory of your project
  6. #
  7. # Exit conditions:
  8. # - Python of version `python-version` is ready to be invoked as `python`.
  9. # - Uv of version `uv-version` is ready to be invoked as `uv`.
  10. # - If `run-uv-sync` is true, deps as defined in `pyproject.toml` will have been installed into the venv at `create-venv-at-path`.
  11. name: "Setup Reflex build environment"
  12. description: "Sets up Python, install uv (cached), install project deps (cached)"
  13. inputs:
  14. python-version:
  15. description: "Python version setup"
  16. required: true
  17. uv-version:
  18. description: "Uv version to install"
  19. required: false
  20. default: "0.6.5"
  21. run-uv-sync:
  22. description: "Whether to run uv sync on current dir"
  23. required: false
  24. default: false
  25. create-venv-at-path:
  26. description: "Path to venv (if uv sync is enabled)"
  27. required: false
  28. default: ".venv"
  29. runs:
  30. using: "composite"
  31. steps:
  32. - name: Install UV
  33. uses: astral-sh/setup-uv@v5
  34. with:
  35. version: ${{ inputs.uv-version }}
  36. python-version: ${{ inputs.python-version }}
  37. enable-cache: true
  38. prune-cache: false
  39. cache-dependency-glob: "uv.lock"
  40. - name: Restore cached project python deps
  41. id: restore-pydeps-cache
  42. uses: actions/cache/restore@v4
  43. with:
  44. path: ${{ inputs.create-venv-at-path }}
  45. key: ${{ runner.os }}-python-${{ inputs.python-version }}-pydeps-${{ hashFiles('**/uv.lock') }}
  46. - if: ${{ inputs.run-uv-sync == 'true' && steps.restore-pydeps-cache.outputs.cache-hit != 'true' }}
  47. name: Run uv sync (will get cached)
  48. # We skip over installing the root package (the current project code under CI)
  49. # Root package should not be cached - its content is not reflected in uv.lock / cache key
  50. shell: bash
  51. run: |
  52. uv sync --all-extras --dev --no-install-project
  53. - if: steps.restore-pydeps-cache.outputs.cache-hit != 'true'
  54. name: Save Python deps to cache
  55. uses: actions/cache/save@v4
  56. with:
  57. path: ${{ inputs.create-venv-at-path }}
  58. key: ${{ steps.restore-pydeps-cache.outputs.cache-primary-key }}
  59. - if: ${{ inputs.run-uv-sync == 'true' }}
  60. name: Run uv sync (root package)
  61. # Here we really install the root package (the current project code under CI).env:
  62. # This should not be cached.
  63. shell: bash
  64. run: |
  65. uv sync --all-extras --dev