66 - main
77 pull_request :
88 workflow_dispatch :
9+ schedule :
10+ - cron : " 0 12 * * *"
911
1012permissions :
1113 contents : read
1416 FORCE_COLOR : 1 # Request colored output from CLI tools supporting it
1517 CLICOLOR_FORCE : 1 # recognized by uv
1618 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
19+ DEFAULT_PYTHON_VERSION : " 3.13" # Default Python version for uvx
1720
1821concurrency :
1922 group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
2023 cancel-in-progress : true
2124
2225jobs :
23- check :
24- name : Check
26+ stdlib :
27+ name : Check typeshed stdlib
2528 runs-on : ${{ matrix.platform }}
2629 strategy :
2730 fail-fast : false
3942 - name : Check a basic run doesn't fail
4043 run : uvx --python=${{ matrix.python-version }} --force-reinstall --from=./docstring-adder add-docstrings --stdlib-path ./typeshed/stdlib
4144 - name : Check typeshed's mypy_test.py passes
42- run : uv run --directory=typeshed --no-project --python=3.13 --with-requirements=requirements-tests.txt python tests/mypy_test.py stdlib -p "${{ matrix.python-version }}"
45+ 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 }}"
4346 - name : Check running it again doesn't produce any changes
4447 # Some weird thing with distutils means that it does actually add docstrings
4548 # when run the second time that it didn't add when run the first time.
@@ -51,10 +54,57 @@ jobs:
5154 cd typeshed
5255 git config --global user.email "you@example.com"
5356 git config --global user.name "Your Name"
57+ test -n "$(git status --porcelain)"
5458 git commit -am "."
5559 uvx --python=${{ matrix.python-version }} --force-reinstall --from=../docstring-adder add-docstrings --stdlib-path ./stdlib
5660 test -z "$(git status --porcelain)"
5761
62+ typeshed-third-party :
63+ name : Check typeshed third-party stubs
64+ runs-on : ubuntu-latest
65+ # Too slow to run on every PR
66+ if : ${{ github.event_name != 'pull_request' }}
67+ steps :
68+ - uses : actions/checkout@v4
69+ with :
70+ path : docstring-adder
71+ persist-credentials : false
72+ - name : Checkout typeshed
73+ run : git clone --depth=1 https://github.com/python/typeshed.git || git clone --depth=1 https://github.com/python/typeshed.git
74+ - uses : astral-sh/setup-uv@v6
75+ - name : Check a basic run doesn't fail
76+ run : uvx --python="${DEFAULT_PYTHON_VERSION}" python ./docstring-adder/.github/scripts/typeshed_third_party.py --typeshed-dir ./typeshed --docstring-adder-dir ./docstring-adder
77+ - name : Check typeshed's mypy_test.py passes
78+ 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}"
79+ # Ideally we'd now check that running it again doesn't produce any changes, but it fails for some third-party packages.
80+ # I believe this is because some badly-behaved packages make persistent changes to the Python environment when they're imported.
81+ # Stubs packages for which this fails are: `Authlib`, `aws-xray-sdk`, `beautifulsoup4`, `html5lib`, `python-jose`, `qrcode`
82+
83+ # A fairly arbitrary check, but it's good to enforce that it works on a non-typeshed stubs package.
84+ pandas-stubs :
85+ name : Check running on pandas-stubs
86+ runs-on : ubuntu-latest
87+ steps :
88+ - uses : actions/checkout@v4
89+ with :
90+ path : docstring-adder
91+ persist-credentials : false
92+ - name : Checkout typeshed
93+ 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
94+ - uses : astral-sh/setup-uv@v6
95+ - name : Check a basic run doesn't fail
96+ run : uvx --python="${DEFAULT_PYTHON_VERSION}" --force-reinstall --with=pandas --from=./docstring-adder add-docstrings --packages ./pandas-stubs
97+ - name : Check running it again doesn't produce any changes
98+ shell : bash
99+ run : |
100+ git config --global user.email "you@example.com"
101+ git config --global user.name "Your Name"
102+ cd pandas-stubs
103+ test -n "$(git status --porcelain)"
104+ git commit -am "."
105+ uvx --python="${DEFAULT_PYTHON_VERSION}" --force-reinstall --with=pandas --from=../docstring-adder add-docstrings --packages .
106+ test -z "$(git status --porcelain)"
107+
58108 mypy :
59109 name : Run mypy
60110 runs-on : ubuntu-latest
@@ -73,3 +123,28 @@ jobs:
73123 persist-credentials : false
74124 - uses : actions/setup-python@v5
75125 - uses : pre-commit/action@v3.0.1
126+
127+ create-issue-on-failure :
128+ name : Create an issue if the daily test run failed
129+ runs-on : ubuntu-latest
130+ needs :
131+ - stdlib
132+ - typeshed-third-party
133+ - mypy
134+ - pre-commit
135+ - pandas-stubs
136+ if : ${{ github.repository == 'astral-sh/docstring-adder' && always() && github.event_name == 'schedule' && ((needs.stdlib.result == 'failure') || (needs.typeshed-third-party.result == 'failure') || (needs.mypy.result == 'failure') || (needs.pre-commit.result == 'failure') || (needs.pandas-stubs.result == 'failure')) }}
137+ permissions :
138+ issues : write
139+ steps :
140+ - uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
141+ with :
142+ github-token : ${{ secrets.GITHUB_TOKEN }}
143+ script : |
144+ await github.rest.issues.create({
145+ owner: "astral-sh",
146+ repo: "docstring-adder",
147+ title: `Daily test run failed on ${new Date().toDateString()}`,
148+ body: "Run listed here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
149+ labels: ["bug"],
150+ })
0 commit comments