tests #1325
This file contains 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 | |
paths-ignore: | |
- "examples/**" | |
- "scripts/**" | |
- "stats_website/**" | |
- "**.md" | |
- "**.json" | |
- "**.csv" | |
- "**.html" | |
pull_request: | |
paths-ignore: | |
- "examples/**" | |
- "scripts/**" | |
- "stats_website/**" | |
- "**.md" | |
- "**.json" | |
- "**.csv" | |
- "**.html" | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" | |
permissions: | |
contents: read | |
env: | |
FORCE_COLOR: 1 # Request colored output from CLI tools supporting it | |
PY_COLORS: 1 # Recognized by the `py` package, dependency of `pytest` | |
# TERM is needed for FORCE_COLOR to work on mypy on Ubuntu, | |
# see https://github.com/python/mypy/issues/13817 | |
TERM: xterm-256color | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
pytest-tests: | |
name: Run tests with pytest | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] | |
python-version: ["3.10", "3.11", "3.12", "3.13"] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
allow-prereleases: true | |
- uses: hynek/setup-cached-uv@v2 | |
- name: Install dependencies | |
run: uv pip install -e ".[pytest]" --system | |
- run: uv pip freeze | |
- name: Run tests under coverage | |
shell: bash | |
run: | | |
coverage run -m pytest --doctest-modules | |
coverage report --no-skip-covered | |
create-issue-on-failure: | |
name: Create an issue if daily test failed | |
runs-on: ubuntu-latest | |
needs: pytest-tests | |
if: >- | |
${{ | |
github.repository == 'AlexWaygood/typeshed-stats' | |
&& always() | |
&& github.event_name == 'schedule' | |
&& needs.pytest-tests.result == 'failure' | |
}} | |
permissions: | |
issues: write | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.issues.create({ | |
owner: "AlexWaygood", | |
repo: "typeshed-stats", | |
title: `Daily test failed on ${new Date().toDateString()}`, | |
body: "Runs are listed here: https://github.com/AlexWaygood/typeshed-stats/actions/workflows/test.yml", | |
}) |