tests #1391
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 uv | |
uses: astral-sh/setup-uv@v3 | |
with: | |
version: "latest" | |
- name: Run tests under coverage | |
shell: bash | |
run: | | |
uv python pin ${{ matrix.python-version }} | |
uv run --extra=dev coverage run -m pytest --doctest-modules | |
uv run --extra=dev 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", | |
}) |