Skip to content

[CI] Reuse stubtest workflows #2802

[CI] Reuse stubtest workflows

[CI] Reuse stubtest workflows #2802

Workflow file for this run

name: Daily tests
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
pull_request:
paths:
- "requirements-tests.txt"
- ".github/workflows/daily.yml"
# Please keep the permissions minimal, as stubtest runs arbitrary code from pypi.
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# A few env vars to speedup brew install
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTOUPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Environments are isolated, no need to cleanup old versions
NONINTERACTIVE: 1 # Required for brew install on CI
PIP_DISABLE_PIP_VERSION_CHECK: 1
FORCE_COLOR: 1
TERM: xterm-256color # needed for FORCE_COLOR to work on mypy on Ubuntu, see https://github.com/python/mypy/issues/13817
jobs:
stubtest-stdlib:
uses: $/.github/workflows/stubtest_stdlib.yml
stubtest-third-party:
uses: $/.github/workflows/stubtest_third_party.yml
with:
all-stubs: true
sharded: true
stub-uploader:
name: stub_uploader tests
if: ${{ github.repository == 'python/typeshed' || github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout typeshed
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: typeshed
persist-credentials: false
- name: Checkout stub_uploader
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: typeshed-internal/stub_uploader
path: stub_uploader
persist-credentials: false
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
version-file: "typeshed/requirements-tests.txt"
- name: Run tests
run: |
cd stub_uploader
# Keep Python version in sync with stub_uploader's check_scripts.yml workflow.
uv run --python=3.13 --locked --group dev -m pytest tests
# https://github.community/t/run-github-actions-job-only-if-previous-job-has-failed/174786/2
create-issue-on-failure:
name: Create issue on failure
runs-on: ubuntu-latest
needs: [stubtest-stdlib, stubtest-third-party, stub-uploader]
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') }}
permissions:
issues: write
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.create({
owner: "python",
repo: "typeshed",
title: `Daily tests failed on ${new Date().toDateString()}`,
body: "Run listed here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
})