From 992b67c8e67942b2a2a5107b438d9419f702571a Mon Sep 17 00:00:00 2001 From: Suvayu Ali Date: Mon, 24 Jun 2024 09:56:10 +0000 Subject: [PATCH] CI: format, lint, test, and type check --- .github/workflows/python-tests.yml | 97 ++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/python-tests.yml diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000..1c765c9 --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -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