Repository navigation
Update pre-commit hook astral-sh/ty-pre-commit to v0.0.85 #1164
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 12 * * *" | |
| permissions: {} | |
| env: | |
| FORCE_COLOR: 1 # Request colored output from CLI tools supporting it | |
| CLICOLOR_FORCE: 1 # recognized by uv | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| DEFAULT_PYTHON_VERSION: "3.13" # Default Python version for uvx | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| stdlib: | |
| name: Check typeshed stdlib | |
| runs-on: ${{ matrix.platform }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] | |
| platform: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| path: docstring-adder | |
| persist-credentials: false | |
| - name: Checkout typeshed | |
| run: git clone --depth=1 https://github.com/python/typeshed.git || git clone --depth=1 https://github.com/python/typeshed.git | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - name: Check a basic run doesn't fail | |
| run: uvx --python=${{ matrix.python-version }} --force-reinstall --from=./docstring-adder add-docstrings --stdlib-path ./typeshed/stdlib | |
| - name: Check typeshed's mypy_test.py passes | |
| run: uv run --directory=typeshed --no-project --python="${DEFAULT_PYTHON_VERSION}" --with-requirements=requirements-tests.txt python tests/mypy_test.py stdlib -p "${{ matrix.python-version }}" | |
| - name: Check running it again doesn't produce any changes | |
| # Some weird thing with distutils means that it does actually add docstrings | |
| # when run the second time that it didn't add when run the first time. | |
| # I have no appetite to figure out what cursed thing in distutils is causing this, | |
| # and it doesn't seem to be a major issue in general. | |
| if: ${{ (matrix.python-version != '3.10') && (matrix.python-version != '3.11') }} | |
| shell: bash | |
| run: | | |
| cd typeshed | |
| git config --global user.email "you@example.com" | |
| git config --global user.name "Your Name" | |
| test -n "$(git status --porcelain)" | |
| git commit -am "." | |
| uvx --python=${{ matrix.python-version }} --force-reinstall --from=../docstring-adder add-docstrings --stdlib-path ./stdlib | |
| test -z "$(git status --porcelain)" | |
| typeshed-third-party: | |
| name: Check typeshed third-party stubs | |
| runs-on: ubuntu-latest | |
| # Too slow to run on every PR | |
| if: ${{ github.event_name != 'pull_request' }} | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| path: docstring-adder | |
| persist-credentials: false | |
| - name: Checkout typeshed | |
| run: git clone --depth=1 https://github.com/python/typeshed.git || git clone --depth=1 https://github.com/python/typeshed.git | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - name: Check a basic run doesn't fail | |
| run: uvx --python="${DEFAULT_PYTHON_VERSION}" python ./docstring-adder/.github/scripts/typeshed_third_party.py --typeshed-dir ./typeshed --docstring-adder-dir ./docstring-adder | |
| - name: Check typeshed's mypy_test.py passes | |
| run: uv run --directory=typeshed --no-project --python="${DEFAULT_PYTHON_VERSION}" --with-requirements=requirements-tests.txt python tests/mypy_test.py stubs -p "${DEFAULT_PYTHON_VERSION}" | |
| # Ideally we'd now check that running it again doesn't produce any changes, but it fails for some third-party packages. | |
| # I believe this is because some badly-behaved packages make persistent changes to the Python environment when they're imported. | |
| # Stubs packages for which this fails are: `Authlib`, `aws-xray-sdk`, `beautifulsoup4`, `html5lib`, `python-jose`, `qrcode` | |
| # A fairly arbitrary check, but it's good to enforce that it works on a non-typeshed stubs package. | |
| pandas-stubs: | |
| name: Check running on pandas-stubs | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| path: docstring-adder | |
| persist-credentials: false | |
| - name: Checkout typeshed | |
| run: git clone --depth=1 https://github.com/pandas-dev/pandas-stubs.git || git clone --depth=1 https://github.com/pandas-dev/pandas-stubs.git | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - name: Check a basic run doesn't fail | |
| run: uvx --python="${DEFAULT_PYTHON_VERSION}" --force-reinstall --with=pandas --from=./docstring-adder add-docstrings --packages ./pandas-stubs/pandas-stubs | |
| - name: Check running it again doesn't produce any changes | |
| shell: bash | |
| run: | | |
| git config --global user.email "you@example.com" | |
| git config --global user.name "Your Name" | |
| cd pandas-stubs | |
| test -n "$(git status --porcelain)" | |
| git commit -am "." | |
| uvx --python="${DEFAULT_PYTHON_VERSION}" --force-reinstall --with=pandas --from=../docstring-adder add-docstrings --packages . | |
| test -z "$(git status --porcelain)" | |
| pytest: | |
| name: Run pytest on Python ${{ matrix.python-version }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - name: Run tests | |
| run: | | |
| uv python pin ${{ matrix.python-version }} | |
| uv run --locked coverage run -m pytest | |
| uv run --locked coverage report | |
| mypy: | |
| name: Run mypy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - run: uv run --locked mypy | |
| prek: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 | |
| with: | |
| # renovate: datasource=github-releases depName=astral-sh/uv | |
| version: "0.12.23" | |
| - run: uv run --locked prek run --all-files | |
| create-issue-on-failure: | |
| name: Create an issue if the daily test run failed | |
| runs-on: ubuntu-latest | |
| needs: | |
| - stdlib | |
| - typeshed-third-party | |
| - pytest | |
| - mypy | |
| - prek | |
| - pandas-stubs | |
| if: ${{ github.repository == 'astral-sh/docstring-adder' && always() && github.event_name == 'schedule' && ((needs.stdlib.result == 'failure') || (needs.typeshed-third-party.result == 'failure') || (needs.pytest.result == 'failure') || (needs.mypy.result == 'failure') || (needs.prek.result == 'failure') || (needs.pandas-stubs.result == 'failure')) }} | |
| permissions: | |
| issues: write # to create issues through actions/github-script | |
| steps: | |
| - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| await github.rest.issues.create({ | |
| owner: "astral-sh", | |
| repo: "docstring-adder", | |
| title: `Daily test run failed on ${new Date().toDateString()}`, | |
| body: "Run listed here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
| labels: ["bug"], | |
| }) |