From 8a12443f1cdd13b887c4b5114fbf9aeb9993b55c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 3 Sep 2024 18:36:46 +0100 Subject: [PATCH] Use uv to simplify various CI jobs --- .github/workflows/daily.yml | 6 +-- .github/workflows/meta_tests.yml | 30 ++++++++++----- .github/workflows/tests.yml | 63 +++++++++++++++++--------------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/.github/workflows/daily.yml b/.github/workflows/daily.yml index 2062b58e0869..88ef923ee2aa 100644 --- a/.github/workflows/daily.yml +++ b/.github/workflows/daily.yml @@ -115,16 +115,12 @@ jobs: with: repository: typeshed-internal/stub_uploader path: stub_uploader - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Run tests run: | cd stub_uploader - uv pip install -r requirements.txt --system - python -m pytest tests + uv run --python 3.12 --no-project --with-requirements requirements.txt 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 8586ba4f4f0c..19cade860795 100644 --- a/.github/workflows/meta_tests.yml +++ b/.github/workflows/meta_tests.yml @@ -35,12 +35,17 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - 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 run \ + --python=3.12 \ + --no-project \ + --with-requirements requirements-tests.txt \ + ./tests/typecheck_typeshed.py \ + --platform=${{ matrix.platform }} + ) + pyright: name: Run pyright against the scripts and tests directories runs-on: ubuntu-latest @@ -63,18 +68,23 @@ jobs: python-platform: ${{ matrix.python-platform }} python-version: "3.9" # The Python version to test against. project: ./pyrightconfig.scripts_and_tests.json + stubsabot-dry-run: name: Stubsabot dry run runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - 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 run \ + --python=3.12 \ + --no-project \ + --with-requirements requirements-tests.txt \ + scripts/stubsabot.py \ + --action-level local + ) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a1b0dc0ab409..6d48dc11707c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,13 +26,8 @@ jobs: name: Check typeshed structure runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - 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 run --no-project --python 3.12 --with-requirements requirements-tests.txt tests/check_typeshed_structure.py pytype: name: Run pytype against the stubs @@ -66,12 +61,17 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@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 run \ + --python ${{ matrix.python-version }} \ + --no-project \ + --with-requirements requirements-tests.txt \ + tests/mypy_test.py \ + --platform=${{ matrix.platform }} \ + --python-version=${{ matrix.python-version }} + ) # Run this as a separate job, as the other versions in the matrix are # (and should be) run *using* the Python version we're testing the stubs for, @@ -85,27 +85,36 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.12 - allow-prereleases: true - 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=3.13 + - run: | + ( + uv run \ + --python=3.12 \ + --no-project \ + --with-requirements requirements-tests.txt \ + tests/mypy_test.py \ + --platform=${{ matrix.platform }} \ + --python-version=3.13 + ) regression-tests: name: Run mypy on the test cases runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@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" + # Use py311 for now, as py312 seems to be around 30s slower in CI + # TODO: figure out why that is (#11590) - 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 run \ + --python=3.11 \ + --no-project \ + --with-requirements requirements-tests.txt \ + tests/regr_test.py \ + --all \ + --verbosity QUIET + ) pyright: name: Test typeshed with pyright @@ -176,13 +185,9 @@ jobs: with: repository: typeshed-internal/stub_uploader path: stub_uploader - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - name: Install uv run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Run tests run: | cd stub_uploader - uv pip install -r requirements.txt --system - python -m pytest tests + uv run --python=3.12 --no-project --with-requirements requirements.txt pytest tests