From 9cfe45039d0be07aeba36fab86ed85dd5fb52a32 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 4 Apr 2025 19:02:37 -0400 Subject: [PATCH] Try out setup-uv everywhere in CI --- .github/workflows/daily.yml | 17 ++++---- .github/workflows/meta_tests.yml | 20 +++++----- .github/workflows/mypy_primer.yml | 4 +- .github/workflows/stubsabot.yml | 7 ++-- .github/workflows/stubtest_third_party.yml | 11 +++--- .github/workflows/tests.yml | 45 +++++++++------------- 6 files changed, 48 insertions(+), 56 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index be0d5b7cad71..947a1f234c91 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -64,19 +64,20 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - cache: pip - cache-dependency-path: | + enable-cache: true + prune-cache: false # Can't prune cache if uv installs uv + cache-dependency-glob: | requirements-tests.txt stubs/**/METADATA.toml - name: Install dependencies - run: pip install -r requirements-tests.txt + run: uv pip install -r requirements-tests.txt - name: Run stubtest shell: bash run: | - PACKAGES=$(python tests/get_stubtest_system_requirements.py) + PACKAGES=$(uv run tests/get_stubtest_system_requirements.py) if [ "${{ runner.os }}" = "Linux" ]; then if [ -n "$PACKAGES" ]; then @@ -112,7 +113,7 @@ jobs: with: repository: typeshed-internal/stub_uploader path: stub_uploader - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: # Keep in sync with stub_uploader's check_scripts.yml workflow. python-version: "3.13" @@ -120,8 +121,8 @@ jobs: - name: Run tests run: | cd stub_uploader - uv pip install -r requirements.txt --system - python -m pytest tests + uv pip install -r requirements.txt + uv run -m pytest tests # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 create-issue-on-failure: diff --git a/.github/workflows/meta_tests.yml b/.github/workflows/meta_tests.yml index dd368ed0cdde..a8fcec7e6850 100644 --- a/.github/workflows/meta_tests.yml +++ b/.github/workflows/meta_tests.yml @@ -36,12 +36,11 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - run: uv pip install -r requirements-tests.txt --system - - run: python ./tests/typecheck_typeshed.py --platform=${{ matrix.platform }} + - run: uv pip install -r requirements-tests.txt + - run: uv run ./tests/typecheck_typeshed.py --platform=${{ matrix.platform }} pyright: name: Check scripts and tests with pyright runs-on: ubuntu-latest @@ -51,13 +50,13 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: # TODO: Since pytype is not available for Python 3.13, and # pytype_test.py imports pytype, we need to use Python 3.12 for now. python-version: "3.12" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - run: uv pip install -r requirements-tests.txt --system + prune-cache: false # Can't prune cache if uv installs uv + - run: uv pip install -r requirements-tests.txt - name: Run pyright on typeshed uses: jakebailey/pyright-action@v2 with: @@ -70,13 +69,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Git config run: | git config --global user.name stubsabot git config --global user.email '<>' - - run: uv pip install -r requirements-tests.txt --system - - run: python scripts/stubsabot.py --action-level local + - run: uv pip install -r requirements-tests.txt + - run: uv run scripts/stubsabot.py --action-level local diff --git a/.github/workflows/mypy_primer.yml b/.github/workflows/mypy_primer.yml index 6bddd58f8ded..2f70a72d8abb 100644 --- a/.github/workflows/mypy_primer.yml +++ b/.github/workflows/mypy_primer.yml @@ -29,11 +29,11 @@ jobs: with: path: typeshed_to_test fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - name: Install dependencies - run: pip install git+https://github.com/hauntsaninja/mypy_primer.git + run: uv pip install git+https://github.com/hauntsaninja/mypy_primer.git - name: Run mypy_primer shell: bash run: | diff --git a/.github/workflows/stubsabot.yml b/.github/workflows/stubsabot.yml index 3648d5168aba..2e992e4cf6c3 100644 --- a/.github/workflows/stubsabot.yml +++ b/.github/workflows/stubsabot.yml @@ -24,18 +24,17 @@ jobs: # use an ssh key so that checks automatically run on stubsabot PRs ssh-key: ${{ secrets.STUBSABOT_SSH_PRIVATE_KEY }} fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: git config run: | git config --global user.name stubsabot git config --global user.email '<>' - name: Install dependencies - run: uv pip install -r requirements-tests.txt --system + run: uv pip install -r requirements-tests.txt - name: Run stubsabot - run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python scripts/stubsabot.py --action-level everything + run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} uv run scripts/stubsabot.py --action-level everything # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 create-issue-on-failure: diff --git a/.github/workflows/stubtest_third_party.yml b/.github/workflows/stubtest_third_party.yml index 69ec7c6ac625..5c66f75851bd 100644 --- a/.github/workflows/stubtest_third_party.yml +++ b/.github/workflows/stubtest_third_party.yml @@ -39,15 +39,16 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - cache: pip - cache-dependency-path: | + enable-cache: true + prune-cache: false # Can't prune cache if uv installs uv + cache-dependency-glob: | requirements-tests.txt stubs/**/METADATA.toml - name: Install dependencies - run: pip install -r requirements-tests.txt + run: uv pip install -r requirements-tests.txt - name: Run stubtest shell: bash run: | @@ -62,7 +63,7 @@ jobs: if [ -n "$STUBS" ]; then echo "Testing $STUBS..." - PACKAGES=$(python tests/get_stubtest_system_requirements.py $STUBS) + PACKAGES=$(uv run tests/get_stubtest_system_requirements.py $STUBS) if [ "${{ runner.os }}" = "Linux" ]; then if [ -n "$PACKAGES" ]; then diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5031b000ddb5..cdc428d4c7ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,30 +27,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - run: uv pip install -r requirements-tests.txt --system - - run: python ./tests/check_typeshed_structure.py + - run: uv pip install -r requirements-tests.txt + - run: uv run ./tests/check_typeshed_structure.py pytype: name: "pytype: Check stubs" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: # Max supported Python version as of pytype 2024.10.11 python-version: "3.12" - uses: astral-sh/setup-uv@v5 - - run: uv pip install -r requirements-tests.txt --system + - run: uv pip install -r requirements-tests.txt - name: Install external dependencies for 3rd-party stubs run: | - DEPENDENCIES=$( python tests/get_external_stub_requirements.py ) + DEPENDENCIES=$(uv run tests/get_external_stub_requirements.py) if [ -n "$DEPENDENCIES" ]; then printf "Installing packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n" - uv pip install --system $DEPENDENCIES + uv pip install $DEPENDENCIES fi - run: uv pip freeze - run: ./tests/pytype_test.py --print-stderr @@ -65,26 +64,24 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - run: uv pip install -r requirements-tests.txt --system - - run: python ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }} + - run: uv pip install -r requirements-tests.txt + - run: uv run ./tests/mypy_test.py --platform=${{ matrix.platform }} --python-version=${{ matrix.python-version }} regression-tests: name: "mypy: Run test cases" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: # Use py311 for now, as py312 seems to be around 30s slower in CI # TODO: figure out why that is (#11590) python-version: "3.11" - - run: curl -LsSf https://astral.sh/uv/install.sh | sh - - run: uv pip install -r requirements-tests.txt --system - - run: python ./tests/regr_test.py --all --verbosity QUIET + - run: uv pip install -r requirements-tests.txt + - run: uv run ./tests/regr_test.py --all --verbosity QUIET pyright: name: "pyright: Run test cases" @@ -96,24 +93,20 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: python-version: "3.13" - uses: astral-sh/setup-uv@v5 - name: Install typeshed test-suite requirements # Install these so we can run `get_external_stub_requirements.py` - run: uv pip install -r requirements-tests.txt --system - - name: Create an isolated venv for testing - run: uv venv .venv + run: uv pip install -r requirements-tests.txt - name: Install 3rd-party stub dependencies run: | - DEPENDENCIES=$( python tests/get_external_stub_requirements.py ) + DEPENDENCIES=$(uv run tests/get_external_stub_requirements.py) if [ -n "$DEPENDENCIES" ]; then printf "Installing packages:\n $(echo $DEPENDENCIES | sed 's/ /\n /g')\n" uv pip install --python-version ${{ matrix.python-version }} $DEPENDENCIES fi - - name: Activate the isolated venv for the rest of the job - run: echo "$PWD/.venv/bin" >> $GITHUB_PATH - name: List 3rd-party stub dependencies installed run: uv pip freeze - name: Run pyright with basic settings on all the stubs @@ -153,7 +146,7 @@ jobs: with: repository: typeshed-internal/stub_uploader path: stub_uploader - - uses: actions/setup-python@v5 + - uses: astral-sh/setup-uv@v5 with: # Keep in sync with stub_uploader's check_scripts.yml workflow. python-version: "3.13" @@ -161,5 +154,5 @@ jobs: - name: Run tests run: | cd stub_uploader - uv pip install -r requirements.txt --system - python -m pytest tests + uv pip install -r requirements.txt + uv run -m pytest tests