Skip to content

Commit

Permalink
CI: format, lint, test, and type check
Browse files Browse the repository at this point in the history
  • Loading branch information
suvayu authored Jun 24, 2024
1 parent 60289bc commit 992b67c
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Test esdl4tulipa

on:
push:
branches: [ "main" ]
paths-ignore:
- "docs/**"
- "*.md"
pull_request:
branches: [ "main" ]
paths-ignore:
- "docs/**"
- "*.md"

jobs:
format:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
allow-prereleases: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black toml
- name: Format source w/ black
# fail when file(s) would be formatted
run: black --check src tests

lint:
strategy:
matrix:
python-version: ["py310", "py311", "py312"]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Ruff with Python target version ${{ matrix.python-version }}
uses: chartboost/ruff-action@v1
with:
src: './src'
args: "check --target-version ${{ matrix.python-version }}"

test:
needs: [format, lint]
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ["3.10", "3.11", "3.12"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]
- name: Test with pytest
run: |
pytest
type-check:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
allow-prereleases: true
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy{,_extensions}
- name: Type check w/ mypy
run: echo y | mypy --install-types --check-untyped-defs --pretty src tests

0 comments on commit 992b67c

Please sign in to comment.