Skip to content

Use black version in REFLO environment for GHA (#125) #34

Use black version in REFLO environment for GHA (#125)

Use black version in REFLO environment for GHA (#125) #34

Workflow file for this run

name: Checks
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
PYTEST_ADDOPTS: --color=yes --pyargs watertap_contrib.reflo
PIP_PROGRESS_BAR: "off"
jobs:
linting:
name: Check code is formatted (Black)
# OS and/or Python version don't make a difference, so we choose ubuntu and 3.10 as defaults
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Black
# unlike the other jobs, we don't need to install watertap-reflo and/or all the dev dependencies,
# but we still want to specify the Black version to use in requirements-dev.txt for local development
# so we extract the relevant line and pass it to a simple `pip install`
run: |
black_requirement="$(grep '^black==' requirements-dev.txt)"
pip --no-cache-dir install "$black_requirement"
- name: Run Black to verify that the committed code is formatted
run: |
black --check .
pytest:
name: pytest (${{ matrix.os }}/${{ matrix.python-version }}/${{ matrix.install-mode }})
runs-on: ${{ matrix.os-version }}
needs: [linting]
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
os:
- linux
- win64
install-mode:
- editable
- noneditable
include:
- os: linux
os-version: ubuntu-latest
- os: win64
os-version: windows-latest
steps:
- uses: actions/checkout@v4
if: matrix.install-mode == 'editable'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install (editable)
if: matrix.install-mode == 'editable'
run: |
pip install -r requirements-dev.txt
- name: Install (noneditable)
if: matrix.install-mode == 'noneditable'
run: |
pip install "git+${{ format('{0}/{1}@{2}', github.server_url, github.repository, github.ref) }}"
- name: Set up IDAES solvers
run: |
idaes get-extensions --verbose
- name: Run pytest
run: |
pip install pytest # ensure pytest is installed (should do nothing if already present from requirements-dev.txt
pytest --pyargs watertap_contrib.reflo