Skip to content

Github action installation differs from local #13550

@atinary-bvollmer

Description

@atinary-bvollmer

Summary

Hey,

thanks for doing such a great job with uv/ruff/ty. I'm currently struggling with an issue that I have even trouble to explain fully. I will do my best to give a good description here. Please don't hesitate to ask for more information.

We are currently working on a python monorepo that has libraries and projects. The monorepo is inside a backend folder. The setup follows roughly this architecture. So far locally all works fine. The problem is that when I want to add a Github action our typing system (currently based on basedpyright) fails in the action whereas it would work well locally. After some investigation we could pin it down to how we installed the packages before running basedpyright.

Locally we would install the project with uv sync --all-packages and then run the typing with uv run basedpyright from the backend root with the following setting:

[tool.basedpyright]
include = ["libraries/**", "projects/**"]

exclude = [
    "**/__pycache__/**",
    "**/.venv/**",
    "**/migrations/**",
]
extraPaths = ["projects/django_server/apps"]
verboseOutput = true

typeCheckingMode = "strict"

reportIncompatibleVariableOverride = "none"

while the github action is this:

name: 'Code Quality'

on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize

jobs:
  code_changes:
    name: "Identify changes in sub-directories"
    runs-on: ubuntu-latest
    permissions:
      pull-requests: read
    outputs:
      backend: ${{ steps.filter.outputs.backend }}
    
    steps:
    - uses: dorny/paths-filter@v3
      id: filter
      with:
        filters: |
          backend:
            - 'backend/**'

  code_quality_backend:
    name: "Code Quality Checks Backend"
    needs: code_changes
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./backend
    if: ${{ needs.code_changes.outputs.backend == 'true' }}

    steps:
    - uses: actions/checkout@v4
    - name: Run Ruff
      uses: astral-sh/ruff-action@v3
      with:
        version: "0.11.9"
    - run: ruff check --output-format=github .
    - run: ruff format --check --diff .

    - name: Install uv and run pyright
      uses: astral-sh/setup-uv@v6
      with:
        version: "0.6.17"
        working-directory: ./backend
        enable-cache: false
    - run: uv sync --all-extras --locked --all-packages
    - run: uv run basedpyright

The problem is that when using --all-packages it would fail sometimes with some types missing. I cannot explain to myself why sometimes though.

Further we noticed that when running the sync with --package=django-server it would work but only if I remove the libraries/** from the include of basedpyright. But not because of typing errors in a library but in a project which are unrelated to any library.

My guess would be that somehow the workspace setup is not correct or wrongly applied in the action and thus leads to a problematic package installation.

The root pyproject.toml:

[project]
name = "backend"
version = "0.0.1"
description = "xxx"
readme = "README.md"
dependencies = []

[tool.uv.workspace]
members = ["libraries/*", "projects/*"]

[dependency-groups]
dev = [
    "basedpyright>=1.29.1",
    "pre-commit>=4.2.0",
    "pytest >= 8.3.4",
    "ruff >= 0.11.9",
]


[tool.ruff]
line-length = 120
target-version = "py312"

[tool.ruff.format]
...

[tool.basedpyright]
include = ["projects/**"]

exclude = [
    "**/__pycache__/**",
    "**/.venv/**",
    "**/migrations/**",
]
extraPaths = ["projects/django_server/apps"]
verboseOutput = true

typeCheckingMode = "strict"

reportIncompatibleVariableOverride = "none"

The project toml (renamed to django_server):

[project]
name = "django_server"
version = "0.0.1"
description = "xxxx"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "django>=5.2",
    "django-filter>=25.1",
    "djangorestframework>=3.16.0",
    "logging_library",
    "python-decouple>=3.8",
    "django-unfold>=0.57.0",
]

[tool.uv.sources]
logging_library = { workspace = true }

[dependency-groups]
dev = [
    "drf-spectacular>=0.28.0",
    "django-filter-stubs>=0.1.3",
    "django-types>=0.20.0",
    "djangorestframework-types>=0.9.0",
    "django-stubs>=5.2.0",
    "djangorestframework-stubs>=3.16.0",
    "factory-boy>=3.3.3",
    "faker>=37.1.0",
    "basedpyright>0",
    "pytest>0",
    "pytest-django>=4.11.1",
    "pytest-factoryboy>=2.7.0",
    "ruff>0",
]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "config.settings.test"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["config", "apps"]

Platform

macos and ubuntu

Version

0.6.17

Python version

python 3.12.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions