Skip to content

Merge branches 'dependabot/github_actions/actions/checkout-4.2.0', 'd… #2669

Merge branches 'dependabot/github_actions/actions/checkout-4.2.0', 'd…

Merge branches 'dependabot/github_actions/actions/checkout-4.2.0', 'd… #2669

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: ci
on:
push:
branches: [ "*" ]
schedule:
# Every day at 2:02.
- cron: '2 2 * * *'
permissions:
contents: read
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 20 # stop runaway job after 20 minutes
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04, ubuntu-22.04, macos-14, macos-13, windows-2022 ]
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
env:
SHELLOUS_TRACE: all
BUILD_NAME: build (${{ matrix.os }},${{ matrix.python-version }})
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.python-version }}
check-latest: true
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Lint
if: matrix.python-version != '3.13-dev'
run: |
ruff check --exit-zero .
pylint -v --fail-under 9.5 shellous
# Run pylint on tests directory with some checks disabled.
pylint --disable=C0116,C0103,R0903,W0212,C0302,C0415,R1735 --fail-under 9.1 tests
pyright || echo "Failed."
- name: Run Tests
run: |
if ! pytest -vv -s --durations=20 --log-cli-level=DEBUG | ./ci/annotate.awk -v step=Run_Tests; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --durations=20 --log-cli-level=DEBUG --last-failed
fi
- name: Run Code Coverage (Linux and MacOS)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version != '3.13-dev'
run: |
# Run coverage.
coverage run --source shellous -m pytest --log-cli-level=DEBUG
# Re-run with coverage for shellous/watcher.py
SHELLOUS_CHILDWATCHER_TYPE=default coverage run --source shellous -m pytest
# Re-run with coverage for shellous/watcher.py and ThreadStrategy.
SHELLOUS_CHILDWATCHER_TYPE=default SHELLOUS_THREADSTRATEGY=1 coverage run --source shellous -m pytest
- name: Upload Code Coverage
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version != '3.13-dev'
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.SHELLOUS_CODECOV_TOKEN }}
verbose: true
- name: Run Tests with uvloop (Linux and MacOS)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-13') && matrix.python-version != '3.13-dev'
run: |
pip3 install --require-hashes -r ./ci/requirements-uvloop.txt
# Ignore ResourceWarning with uvloop for now (TODO).
if ! pytest -vv -s --log-cli-level=DEBUG -W ignore::ResourceWarning; then
echo "::warning title=uvloop Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG -W ignore::ResourceWarning --last-failed
fi
env:
SHELLOUS_LOOP_TYPE: "uvloop"
- name: Run Tests with eager task factory
if: matrix.python-version == '3.12'
run: |
if ! pytest -vv -s --durations=20 --log-cli-level=DEBUG | ./ci/annotate.awk -v step=Run_Tests; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --durations=20 --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_LOOP_TYPE: "eager_task_factory"
- name: Run Tests with PidfdWatcher (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG; then
echo "::warning title=PidfdChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "pidfd"
- name: Run Tests with SafeChildWatcher (Linux and MacOS; Python 3.11 only)
if: (matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12') && matrix.python-version == '3.11'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG; then
echo "::warning title=SafeChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "safe"
- name: Run Tests with DefaultChildWatcher (Linux and MacOS)
if: matrix.os == 'ubuntu-22.04' || matrix.os == 'macos-12'
run: |
if ! pytest -vv -s --log-cli-level=DEBUG | ./ci/annotate.awk -v step=DefaultChildWatcher; then
echo "::warning title=DefaultChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -vv -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
- name: Verify Types
if: matrix.python-version != '3.13-dev'
run: |
PYTHONPATH=. pyright --verifytypes shellous
- name: Format Check
run: |
black --check .
isort --check .
build-alpine:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
strategy:
fail-fast: false
matrix:
image-tag: ['python:3.10-alpine', 'python:3.11-alpine', 'python:3.12-alpine']
container:
image: ${{ matrix.image-tag }}
env:
SHELLOUS_TRACE: all
BUILD_NAME: build (${{ matrix.image-tag }})
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Dependencies
run: |
apk add --update gcc musl-dev python3-dev bash grep
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
ps ; echo "alpine" `cat /etc/alpine-release` ; env
if ! pytest -v -s --log-cli-level=DEBUG; then
echo "::warning title=Run Tests Warning::Re-running failed tests in $BUILD_NAME"
pytest -v -s --log-cli-level=DEBUG --last-failed
fi
- name: Run Tests with DefaultChildWatcher
run: |
if ! pytest -v -s --log-cli-level=DEBUG; then
echo "::warning title=DefaultChildWatcher Warning::Re-running failed tests in $BUILD_NAME"
pytest -v -s --log-cli-level=DEBUG --last-failed
fi
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
build-pypy:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
strategy:
fail-fast: false
matrix:
pypy-version: [ 'pypy-3.9', 'pypy-3.10']
env:
SHELLOUS_TRACE: all
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python ${{ matrix.pypy-version }}
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ matrix.pypy-version }}
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
pytest -vv -s --durations=20 --log-cli-level=DEBUG -W ignore::pytest.PytestUnraisableExceptionWarning
- name: Run Tests with DefaultChildWatcher
run: |
pytest -vv -s --log-cli-level=DEBUG -W ignore::pytest.PytestUnraisableExceptionWarning
env:
SHELLOUS_CHILDWATCHER_TYPE: "default"
build-13:
runs-on: ubuntu-latest
timeout-minutes: 20 # stop runaway job after 20 minutes
env:
SHELLOUS_TRACE: all
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python 3.13
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.13-dev'
- name: Install dependencies
run: |
pip3 install --require-hashes -r ./ci/requirements-dev.txt
- name: Run Tests
run: |
pytest -vv -s --log-cli-level=DEBUG