Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CI checks for non-editable install #41

Merged
merged 27 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7736b08
remove sensitive info
CopyDemon Nov 14, 2023
4a57eb2
version should not be 1.0.0 should be 0.1.0, update git ui all point …
CopyDemon Nov 15, 2023
78c02b8
Merge branch 'IDAES:main' into main
CopyDemon Nov 28, 2023
dc5d0c2
Add missing pydantic requirement
lbianchi-lbl Nov 28, 2023
9c60921
Move bulk of pytest config to conftest.py
lbianchi-lbl Nov 28, 2023
3b7a5a8
Add pytest skip logic for fastapi
lbianchi-lbl Nov 28, 2023
08aeac6
Add test to verify presence of frontend assets
lbianchi-lbl Nov 28, 2023
72f0354
Add CI job for running pytest on non-editable install
lbianchi-lbl Nov 28, 2023
e5e2950
Bypass local action for installation
lbianchi-lbl Nov 28, 2023
aa1e0ad
Disable other jobs while WIP
lbianchi-lbl Nov 28, 2023
61651ca
Revert "Disable other jobs while WIP"
lbianchi-lbl Nov 28, 2023
d9276f9
Try reworking install action to abstract installation variants
lbianchi-lbl Nov 29, 2023
ce666a2
Fix invalid workflow schema
lbianchi-lbl Nov 29, 2023
2ec101c
Try hardcoding action source since contexts are not available
lbianchi-lbl Nov 29, 2023
9f5f44b
Add missing context
lbianchi-lbl Nov 29, 2023
3a0bd9d
Try using head of PR ref to get current version of action
lbianchi-lbl Nov 29, 2023
f59dde5
Investigate why variant arg is ignored
lbianchi-lbl Nov 29, 2023
8533beb
Try making argument required
lbianchi-lbl Nov 29, 2023
991b9d5
Reduce job matrix size while WIP
lbianchi-lbl Nov 29, 2023
2d74487
Fix job matrix key
lbianchi-lbl Nov 29, 2023
d6ca581
Revert "Try making argument required"
lbianchi-lbl Nov 29, 2023
edeb000
Add missing pip install flag
lbianchi-lbl Nov 29, 2023
33b58e2
Add missing quote
lbianchi-lbl Nov 29, 2023
cc98ab4
Fix pip install command
lbianchi-lbl Nov 29, 2023
29ace9f
Try making Cypress jobs variant-agnostic
lbianchi-lbl Nov 29, 2023
fda2e50
Try resolving Cypress action error
lbianchi-lbl Nov 29, 2023
32294c1
Add missing Cypress config file to partial checkout
lbianchi-lbl Nov 29, 2023
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
76 changes: 51 additions & 25 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,70 @@
name: Set up IDAES
description: Install IDAES and extensions

inputs:
install-target:
description: 'Command-line arguments and options to pass to the install command, e.g. pip install'

variant:
description: "Which installation variant to use. Choices: standard (default); dev"
required: false
default: standard

python-version:
description: "Python version to use for installation"
required: true
install-command:
description: 'Command to use to install `install-target`'

conda-environment:
description: "Name of the Conda environment to use for installation."
required: false
default: idaes-ui-env

info-packages:
description: Packages to show info for
required: false
default: pip --no-cache-dir install --progress-bar off
default: pyomo idaes-pse idaes-ui

runs:
using: "composite"
steps:
# IMPORTANT this requires the Conda env setup to be run before this action
- name: Update pip and other packaging tools using Conda
# -l: login shell, needed when using Conda run:

- name: Set up Conda environment
uses: conda-incubator/[email protected]
with:
activate-environment: ${{ inputs.conda-environment }}
python-version: ${{ inputs.python-version }}

- name: Check out repository
if: inputs.variant == 'dev'
uses: actions/checkout@v3
- name: Install using pip (requirements-dev.txt)
if: inputs.variant == 'dev'
shell: bash -l {0}
run: |
echo '::group::Output of "conda install" command'
conda install --yes --quiet pip setuptools wheel
conda list
echo '::endgroup::'
- name: Install idaes and dependencies
pip install --progress-bar off -r requirements-dev.txt

- name: Install using pip (git+... URL)
if: inputs.variant == 'standard'
shell: bash -l {0}
env:
_pip_install_url: ${{ github.server_url }}/${{ github.repository }}@${{ github.ref }}
run: |
echo '::group::Output of "pip install" command'
${{ inputs.install-command }} ${{ inputs.install-target}}
pip install --progress-bar off "git+$_pip_install_url" idaes-pse pytest

- name: Install extensions
shell: bash -l {0}
run: |
echo '::group::Output of "idaes get-extensions" command'
idaes get-extensions --verbose
echo '::endgroup::'

- name: Display environment info
shell: bash -l {0}
run: |
echo '::group::Output of "conda list"'
conda list
echo '::endgroup::'
echo '::group::Output of "pip list"'
pip list
echo '::endgroup::'
echo '::group::Output of "pip show pyomo idaes-pse"'
pip show pyomo idaes-pse
echo '::endgroup::'
# idaes --version
- name: Install extensions
shell: bash -l {0}
run: |
echo '::group::Output of "idaes get-extensions" command'
idaes get-extensions --extra petsc --verbose
echo '::endgroup::'
echo '::group::Output of "pip show ${{ inputs.info-packages }}"'
pip show ${{ inputs.info-packages }}
echo '::endgroup::'
66 changes: 31 additions & 35 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ concurrency:
cancel-in-progress: true

env:
# default Python version to use for checks that do not require multiple versions
DEFAULT_PYTHON_VERSION: '3.8'
IDAES_CONDA_ENV_NAME_DEV: idaes-ui-dev
PYTEST_ADDOPTS: "--color=yes"

defaults:
Expand All @@ -44,17 +41,21 @@ defaults:
shell: bash -l {0}

jobs:

pytest:
# description: Run pytest with dev dependencies
name: pytest (py${{ matrix.python-version }}/${{ matrix.os }})
# description: Run pytest test suite
name: pytest (${{ matrix.install-variant }}/py${{ matrix.python-version }}/${{ matrix.os }})
runs-on: ${{ matrix.runner-image }}
strategy:
fail-fast: false
matrix:
install-variant:
- standard
- dev
python-version:
- '3.8'
- '3.9'
- '3.10'
# - '3.9'
# - '3.10'
- '3.11'
os:
- linux
Expand All @@ -65,32 +66,27 @@ jobs:
- os: win64
runner-image: windows-2022
steps:
- uses: actions/checkout@v3
- name: Set up Conda environment
uses: conda-incubator/[email protected]
- uses: IDAES/idaes-ui/.github/actions/install@refs/pull/41/head
with:
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }}
variant: ${{ matrix.install-variant }}
python-version: ${{ matrix.python-version }}
- name: Install additional dependencies
run: pip install idaes-pse
- name: Install the code
uses: ./.github/actions/install
with:
install-target: -r requirements-dev.txt
- name: Run pytest
run: pytest -v -s -m "not integration"
run: pytest -v --pyargs idaes_ui.fv

cypress:
name: cypress (py${{ matrix.python-version }}/${{ matrix.os }})
name: cypress (${{ matrix.install-variant }}/py${{ matrix.python-version }}/${{ matrix.os }})
#setup python environment for python server, install UI
runs-on: ${{ matrix.runner-image }}
strategy:
fail-fast: false
matrix:
install-variant:
- standard
- dev
python-version:
- '3.8'
- '3.9'
- '3.10'
# - '3.9'
# - '3.10'
- '3.11'
os:
- linux
Expand All @@ -102,29 +98,29 @@ jobs:
runner-image: windows-2022
steps:
#python starts here
- uses: actions/checkout@v3
- name: Set up Conda environment
uses: conda-incubator/[email protected]
- name: Install python code
uses: IDAES/idaes-ui/.github/actions/install@refs/pull/41/head
with:
activate-environment: ${{ env.IDAES_CONDA_ENV_NAME_DEV }}
variant: ${{ matrix.install-variant }}
python-version: ${{ matrix.python-version }}
- name: Install the code
uses: ./.github/actions/install
with:
install-target: -r requirements-dev.txt
#cypress starts here
- name: Check out files needed to run cypress tests
if: matrix.install-variant != 'dev'
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
cypress
package.json
package-lock.json
cypress.config.js
- name: Install node packages
run: npm install
- name: Start UI
run: npm run ui & echo "UI Server started"
- name: Extract server port
run: |
echo "Reading port from shared_variable.json"
echo 'URL='$(node -pe "require('./shared_variable.json').url") >> $GITHUB_ENV
- name: Cypress run
uses: cypress-io/github-action@v5
with:
wait-on: ${{ env.URL }}
wait-on-timeout: 20
command: npm run test
browser: chrome
16 changes: 16 additions & 0 deletions idaes_ui/fv/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pytest import Config


IDAES_MARKERS = {
"unit": "Quick tests that do not require a solver, must run in < 2 s",
"component": "Quick tests that may require a solver",
"integration": "Long duration tests",
}


def pytest_configure(config: Config):

for spec, descr in IDAES_MARKERS.items():
config.addinivalue_line(
"markers", f"{spec}: {descr}"
)
2 changes: 2 additions & 0 deletions idaes_ui/fv/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Tests for the IDAES FV app, using FastAPI TestClient
"""
import pytest

pytest.importorskip("fastapi", reason="fastapi not available")
from fastapi.testclient import TestClient
from ..app import FlowsheetApp
from idaes_ui.fv.tests.flowsheets import idaes_demo_flowsheet
Expand Down
24 changes: 24 additions & 0 deletions idaes_ui/fv/tests/test_model_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Tests for model_server module
"""
# stdlib
from pathlib import Path
# ext
import pytest
from pyomo.environ import ConcreteModel
Expand All @@ -27,6 +28,29 @@
from idaes.models.unit_models import Flash
from .test_fsvis import flash_model



@pytest.fixture
def _frontend_assets_dir() -> Path:
from idaes_ui.fv.model_server import _static_dir
return Path(_static_dir).resolve()


@pytest.mark.unit
@pytest.mark.parametrize(
"relpath",
[
"",
"index.html",
"idaes-logo.ico",
"data/demo_flowsheet.json",
]
)
def test_packaged_frontend_assets(_frontend_assets_dir: Path, relpath):
path = _frontend_assets_dir / relpath
assert path.exists()


@pytest.mark.unit
def test_flowsheet_server_class():
srv = model_server.FlowsheetServer()
Expand Down
13 changes: 3 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ build-backend = "setuptools.build_meta"
# For running tests
"pytest",
# dependency 'requests' module for standalone idaes-ui package
"requests"
"requests",
"pydantic", # idaes_ui.fv.models
]
keywords = ["IDAES", "energy systems", "chemical engineering", "process modeling"]

Expand Down Expand Up @@ -93,12 +94,4 @@ idaes_ui = [

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra"
testpaths = [
"idaes_ui"
]
markers = [
"component: between unit and integration test",
"unit: test one small unit of functionality",
"integration: test integrated functionality"
]
addopts = "-ra --pyargs idaes_ui.fv"
Loading