|
| 1 | +name: Daily test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 0 * * *" |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - "requirements-tests.txt" |
| 10 | + - ".github/workflows/daily.yml" |
| 11 | + |
| 12 | +# Please keep the permissions minimal, as stubtest runs arbitrary code from pypi. |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +env: |
| 21 | + # A few env vars to speedup brew install |
| 22 | + HOMEBREW_NO_ANALYTICS: 1 |
| 23 | + HOMEBREW_NO_AUTOUPDATE: 1 |
| 24 | + HOMEBREW_NO_INSTALL_CLEANUP: 1 # Environments are isolated, no need to cleanup old versions |
| 25 | + NONINTERACTIVE: 1 # Required for brew install on CI |
| 26 | + PIP_DISABLE_PIP_VERSION_CHECK: 1 |
| 27 | + FORCE_COLOR: 1 |
| 28 | + TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817 |
| 29 | + |
| 30 | +jobs: |
| 31 | + stubtest-stdlib: |
| 32 | + name: "stubtest: stdlib" |
| 33 | + if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} |
| 34 | + runs-on: ${{ matrix.os }} |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + os: ["ubuntu-latest", "windows-latest", "macos-latest"] |
| 38 | + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"] |
| 39 | + exclude: |
| 40 | + # https://github.com/python/typeshed/issues/15694 |
| 41 | + - os: "windows-latest" |
| 42 | + python-version: "3.10" |
| 43 | + fail-fast: false |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v7 |
| 47 | + - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} |
| 48 | + uses: actions/setup-python@v6 |
| 49 | + with: |
| 50 | + python-version: ${{ matrix.python-version }} |
| 51 | + cache: pip |
| 52 | + cache-dependency-path: requirements-tests.txt |
| 53 | + allow-prereleases: true |
| 54 | + check-latest: true |
| 55 | + - name: Install dependencies |
| 56 | + run: pip install -r requirements-tests.txt |
| 57 | + - name: Run stubtest |
| 58 | + run: python tests/stubtest_stdlib.py |
| 59 | + |
| 60 | + stubtest-third-party: |
| 61 | + name: "stubtest: third party" |
| 62 | + if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} |
| 63 | + runs-on: ${{ matrix.os }} |
| 64 | + strategy: |
| 65 | + matrix: |
| 66 | + os: ["ubuntu-latest", "windows-latest", "macos-latest"] |
| 67 | + shard-index: [0, 1, 2, 3] |
| 68 | + fail-fast: false |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v7 |
| 71 | + - uses: actions/setup-python@v6 |
| 72 | + with: |
| 73 | + python-version: "3.13" |
| 74 | + cache: pip |
| 75 | + cache-dependency-path: | |
| 76 | + requirements-tests.txt |
| 77 | + stubs/**/METADATA.toml |
| 78 | + - name: Install dependencies |
| 79 | + run: pip install -r requirements-tests.txt |
| 80 | + - name: Install required system packages |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + PACKAGES=$(python tests/get_stubtest_system_requirements.py) |
| 84 | +
|
| 85 | + if [ "${{ runner.os }}" = "Linux" ]; then |
| 86 | + if [ -n "$PACKAGES" ]; then |
| 87 | + printf "Installing APT packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" |
| 88 | + sudo apt-get update -q && sudo apt-get install -qy $PACKAGES |
| 89 | + fi |
| 90 | + else |
| 91 | + if [ "${{ runner.os }}" = "macOS" ] && [ -n "$PACKAGES" ]; then |
| 92 | + printf "Installing Homebrew packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" |
| 93 | + brew install -q $PACKAGES |
| 94 | + fi |
| 95 | +
|
| 96 | + if [ "${{ runner.os }}" = "Windows" ] && [ -n "$PACKAGES" ]; then |
| 97 | + printf "Installing Chocolatey packages:\n $(echo $PACKAGES | sed 's/ /\n /g')\n" |
| 98 | + choco install -y $PACKAGES |
| 99 | + fi |
| 100 | + fi |
| 101 | + - name: Run stubtest |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + if [ "${{ runner.os }}" = "Linux" ]; then |
| 105 | + PYTHON_EXECUTABLE="xvfb-run python" |
| 106 | + else |
| 107 | + PYTHON_EXECUTABLE="python" |
| 108 | + fi |
| 109 | +
|
| 110 | + $PYTHON_EXECUTABLE tests/stubtest_third_party.py --ci-platforms-only --num-shards 4 --shard-index ${{ matrix.shard-index }} |
| 111 | +
|
| 112 | + stub-uploader: |
| 113 | + name: stub_uploader tests |
| 114 | + if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }} |
| 115 | + runs-on: ubuntu-latest |
| 116 | + steps: |
| 117 | + - name: Checkout typeshed |
| 118 | + uses: actions/checkout@v7 |
| 119 | + with: |
| 120 | + path: typeshed |
| 121 | + - name: Checkout stub_uploader |
| 122 | + uses: actions/checkout@v7 |
| 123 | + with: |
| 124 | + repository: typeshed-internal/stub_uploader |
| 125 | + path: stub_uploader |
| 126 | + - uses: astral-sh/setup-uv@v8.2.0 |
| 127 | + with: |
| 128 | + version-file: "typeshed/requirements-tests.txt" |
| 129 | + - name: Run tests |
| 130 | + run: | |
| 131 | + cd stub_uploader |
| 132 | + # Keep Python version in sync with stub_uploader's check_scripts.yml workflow. |
| 133 | + uv run --python=3.13 --no-project --with-requirements=requirements.txt -m pytest tests |
| 134 | +
|
| 135 | + # https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2 |
| 136 | + create-issue-on-failure: |
| 137 | + name: Create issue on failure |
| 138 | + runs-on: ubuntu-latest |
| 139 | + needs: [stubtest-stdlib, stubtest-third-party, stub-uploader] |
| 140 | + if: ${{ github.repository == 'python/typeshed' && always() && github.event_name == 'schedule' && (needs.stubtest-stdlib.result == 'failure' || needs.stubtest-third-party.result == 'failure' || needs.stub-uploader.result == 'failure') }} |
| 141 | + permissions: |
| 142 | + issues: write |
| 143 | + steps: |
| 144 | + - uses: actions/github-script@v9 |
| 145 | + with: |
| 146 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 147 | + script: | |
| 148 | + await github.rest.issues.create({ |
| 149 | + owner: "python", |
| 150 | + repo: "typeshed", |
| 151 | + title: `Daily tests failed on ${new Date().toDateString()}`, |
| 152 | + body: "Run listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", |
| 153 | + labels: ["help wanted"], |
| 154 | + }) |
0 commit comments