Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Tests

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# REFPROP is proprietary (NIST license), so the compiled library lives in a
# private repository and is fetched with a read-only deploy key stored as
# the REFPROP_DEPLOY_KEY secret. Secrets are never exposed to workflows
# triggered by pull requests from forks, so the test job is skipped there:
# forks need their own private REFPROP repository and secret to run CI.
# Do NOT convert the pull_request trigger to pull_request_target - that
# would expose the secret to arbitrary code from fork PRs.
check-secret:
name: Check REFPROP secret
runs-on: ubuntu-latest
outputs:
has-key: ${{ steps.check.outputs.has-key }}
steps:
- id: check
env:
KEY: ${{ secrets.REFPROP_DEPLOY_KEY }}
run: |
if [ -n "$KEY" ]; then
echo "has-key=true" >> "$GITHUB_OUTPUT"
else
echo "has-key=false" >> "$GITHUB_OUTPUT"
fi

test:
name: Tests (REFPROP)
needs: check-secret
if: needs.check-secret.outputs.has-key == 'true'
runs-on: ubuntu-latest
timeout-minutes: 40
env:
RPPREFIX: ${{ github.workspace }}/refprop
steps:
- uses: actions/checkout@v4

- name: Fetch REFPROP (private repository)
uses: actions/checkout@v4
with:
repository: raphaeltimbo/refprop-linux
ssh-key: ${{ secrets.REFPROP_DEPLOY_KEY }}
path: refprop

- name: Install libgfortran
run: sudo apt-get update -q && sudo apt-get install -y -q libgfortran5

- uses: astral-sh/setup-uv@v6
with:
python-version: "3.12"

- name: Install dependencies
run: uv sync --all-extras

- name: Check REFPROP is loaded
run: |
uv run python -c "
import ccp
assert ccp.REFPROP_AVAILABLE, 'librefprop.so not found at RPPREFIX'
print(ccp.__version__full)
"

- name: Run tests
run: uv run pytest ccp/tests -n 4 --dist loadfile
4 changes: 3 additions & 1 deletion ccp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@

# Auto-switch to HEOS if REFPROP is not available

if not _library_path.is_file():
REFPROP_AVAILABLE = _library_path.is_file()

if not REFPROP_AVAILABLE:
_warnings.warn(
f"{_library_path}.\nREFPROP not configured. "
f"Automatically switching to EOS='HEOS' (CoolProp backend)."
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ dev = [

[tool.uv]
package = true
# Dev/CI resolution constraint only (does not affect published metadata):
# CoolProp 8 changed the exception type raised for unknown fluids and the
# cubic-EOS roundoff, breaking three tests. Remove once ccp is adapted.
constraint-dependencies = ["coolprop<8"]
Loading