Skip to content

ENG-34: Run scripts under a PTY so terminal-aware tools work #1495

ENG-34: Run scripts under a PTY so terminal-aware tools work

ENG-34: Run scripts under a PTY so terminal-aware tools work #1495

Workflow file for this run

name: Code Quality & Tests
on:
push:
pull_request:
env:
PYTHON_VERSION: "3.11"
jobs:
black:
name: Black Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check formatting with Black
run: black . --check
isort:
name: Import Sorting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install isort
- name: Sort imports with isort
run: isort . --check-only --diff
flake8:
name: Flake8 Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: flake8 .
mypy:
name: MyPy Type Checking (${{ matrix.platform }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# --platform is a static narrowing setting, so every target is checked from
# one runner: code is verified under the platform where it runs and proven
# guarded under the platforms where it does not.
platform: [linux, darwin, win32]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Type check with mypy
run: mypy . --check-untyped-defs --platform ${{ matrix.platform }}
tests:
name: Run Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: requirements.txt
# Every step below runs a single command. Windows runners default to
# PowerShell, where a failing native command does not abort the remaining
# commands of a multi-command run block; one command per step makes a
# failure fail the job on every OS without shell-specific workarounds.
- name: Configure git user email
run: git config --global user.email "test@example.com"
- name: Configure git user name
run: git config --global user.name "Test Runner"
- name: Configure git default branch
run: git config --global init.defaultBranch main
- name: Upgrade pip
run: python -m pip install --upgrade pip
- name: Install requirements
run: pip install -r requirements.txt
- name: Install coverage
run: pip install coverage
- name: Run tests with coverage
run: coverage run -m pytest tests/ -v
- name: Generate coverage XML
run: coverage xml
- name: Show coverage report
run: coverage report
- name: Upload coverage reports
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3