Skip to content

Commit

Permalink
Update CI configuration to ensure checks run on PRs (#5)
Browse files Browse the repository at this point in the history
* Update CI configuration to ensure checks run on PRs

* Empty commit to trigger CI

* Try making trigger more generic

* Empty commit to trigger CI

* Format with Black

* Improve clarity of Black check

* Reduce job matrix size

* Address failures due to repo being private

* Tweak job/step name
  • Loading branch information
lbianchi-lbl authored May 29, 2024
1 parent a15a1b7 commit e4b93ee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
36 changes: 23 additions & 13 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@

name: Checks
on:
push:
branches: [main]
pull_request:

env:
PYTEST_ADDOPTS: --color=yes --pyargs watertap_contrib.rENRTL
PYTEST_ADDOPTS: --color=yes
PIP_PROGRESS_BAR: "off"

jobs:

linting:
code-formatting:
name: Check code is formatted (Black)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
- uses: actions/checkout@v4
- name: Run Black in check mode
uses: psf/black@stable
with:
options: "--check --verbose"
options: "--check"
version: "~= 22.0"

pytest:
name: pytest (${{ matrix.os }}/${{ matrix.python-version }}/${{ matrix.install-mode }})
runs-on: ${{ matrix.os-version }}
needs: [linting]
needs: [code-formatting]
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
# keep additional Python versions commented while private to reduce number of jobs
# (CI jobs run in private repos are counted towards monthly usage limits for the entire org)
# - "3.9"
# - "3.10"
- "3.11"
os:
- linux
- win64
install-mode:
- editable
- noneditable
# noneditable will fail unless the repo is public
# - noneditable
include:
- os: linux
os-version: ubuntu-latest
- os: win64
os-version: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
if: matrix.install-mode == 'editable'
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install (editable)
Expand All @@ -52,10 +61,11 @@ jobs:
- name: Install (noneditable)
if: matrix.install-mode == 'noneditable'
run: |
pip install .
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: |
pytest
pip install pytest # ensure pytest is installed (should do nothing if already present from requirements-dev.txt
pytest --pyargs watertap_contrib.rENRTL
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ def common(b, pobj):

# Add beta constant, which represents the radius of
# electrostricted water in the hydration shell of ions and it
# is specific to the type of electrolyte.
# is specific to the type of electrolyte.
# Beta is a parameter determined by the charge of the ion pairs, like NaCl is 1-1, Na2SO4 is 1-2
# Beta is obtained using parameter estimation by Xi Yang ref[3] (page 35 values multiplied by 5.187529),
# Beta is obtained using parameter estimation by Xi Yang ref[3] (page 35 values multiplied by 5.187529),
# original data used for parameter estimation are from ref[4].
b.add_component(
"beta",
Expand Down Expand Up @@ -594,7 +594,7 @@ def rule_Xp(b, e):
),
)
# Function to calculate Volume of Solution [m3], this function is a combination of Eqn 9 & 10 from ref [3]

# Average molar volume of solvent
def rule_vol_mol_solvent(b):
# Equation from ref[3], page 14
Expand Down Expand Up @@ -710,8 +710,8 @@ def rule_eps_solvent(b): # Eqn 78 from ref[1]
),
)

# Distance of Closest Approach (m)
# Eqn 12 from ref [3]
# Distance of Closest Approach (m)
# Eqn 12 from ref [3]
def rule_ar(b):

b.distance_species = pyo.Param(
Expand Down Expand Up @@ -741,7 +741,7 @@ def rule_ar(b):
pname + "_ar",
pyo.Expression(rule=rule_ar, doc="Distance of closest approach [m]"),
)

# Functions to calculate parameters for long-range equations
# b term
# ref[3] eq#[2] first line
Expand Down Expand Up @@ -1757,7 +1757,7 @@ def log_gamma_lc(b, pname, s, X, G, tau):
else:
m = s

# Eqn 8 from ref[2]
# Eqn 8 from ref[2]
return (
sum(X[i] * G[i, m] * tau[i, m] for i in aqu_species)
/ sum(X[i] * G[i, m] for i in aqu_species)
Expand Down

0 comments on commit e4b93ee

Please sign in to comment.