Skip to content

Commit

Permalink
Split web server into separate package (#98)
Browse files Browse the repository at this point in the history
* Split web server into separate package

- Eliminated npm part in setup.py commands
- Created separate package

TODO
- rename to helics_cli_extras
- move observer stuff to helics_cli_extras
- move testing if necessary
- setup ci/cd and PyPI package

* Run formatter

* Add CI for web

* Move folder

* Rename in setup.py

* Rename in cli.py and improve test

* Stop duplication of push and pull request

* Move observer and database into cli_extras

* Fix imports on observer and change ci-web to ci-cli.yml

* .github/workflows/ci-cli.yml

* Rename and create cd

* Add NPM and environment name

* Fix cd-cli-extras.yml

* Run on workflow dispatch

* Fix typo in helics_cli_extras/pyproject.toml

Co-authored-by: Ryan Mast <[email protected]>

* Remove pypi package 'install'

* Add import check for helics_cli_extras. Direct to helics[cli]

* Remove sqlalchemy, pandas, and requests

* Make cd-cli-extras happen only on workflow dispatch (will require manual version updates)

---------

Co-authored-by: Joseph McKinsey <[email protected]>
Co-authored-by: Ryan Mast <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent c98928a commit cfe4eb2
Show file tree
Hide file tree
Showing 44 changed files with 486 additions and 212 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/cd-cli-extras.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CD - CLI Extras

on:
push:
branches:
- main
workflow_dispatch:
inputs:
publish_to_pypi:
description: 'Publish to TestPyPI and PyPI'
required: true
type: boolean
default: false

jobs:
build-wheels:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4

- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: 3.8

- name: Install python3 dependencies
run: |
python -m pip install -U pip wheel setuptools cffi build
- name: Build cli_extras wheel
run: |
cd helics_cli_extras/client
npm install
npm run build
cp -r build ../helics_cli_extras/static
cd ..
python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: python-cli-extras-dist
path: helics_cli_extras/dist/*

publish-helics:
needs: [build-wheels]
runs-on: ubuntu-latest
environment:
name: pypi-cli-extras
url: https://pypi.org/p/helics-cli-extras
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Get the built packages
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: helics_cli_extras/dist

- name: Publish package to TestPyPI
if: ${{ github.event.inputs.publish_to_pypi == true }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository-url: https://test.pypi.org/legacy/
packages-dir: helics_cli_extras/dist

- name: Publish package to PyPI
if: ${{ github.event.inputs.publish_to_pypi == true }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: helics_cli_extras/dist
5 changes: 3 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
tags:
- v*
workflow_dispatch:

jobs:
build-wheels:
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:

- name: Install python3 dependencies
run: |
python -m pip install -U pip install wheel setuptools cffi
python -m pip install -U pip wheel setuptools cffi
- name: Download helics library
run: python setup.py download --plat-name=${{ matrix.target }}
Expand Down Expand Up @@ -97,7 +98,7 @@ jobs:
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/

- name: Publish package to PyPI
if: startsWith(github.ref, 'refs/tags/')
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/ci-cli-extras.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: CI - CLI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip wheel setuptools cffi
- name: Build NPM
run: |
cd helics_cli_extras/client
npm install
npm run build
cp -r build ../helics_cli_extras/static
- name: Build the web interface first
run: |
cd helics_cli_extras
pip install .
- name: Download helics library and run pip install
run: |
python setup.py download
python setup.py build_ext
pip install -e ".[cli]"
- name: Run Server
run: |
helics server &
sleep 5
curl http://localhost:5000
kill %+
- name: Run Observer
run: |
mkdir db
helics observer &
sleep 5
kill %+
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
Expand All @@ -19,7 +25,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip install wheel setuptools cffi
python -m pip install -U pip wheel setuptools cffi
- name: Download helics library and run pip install
run: |
python setup.py download
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install -U pip install wheel setuptools
python -m pip install -U pip wheel setuptools
python setup.py download
pip install -e ".[cli,docs]"
- name: Copy README.md
Expand Down
Loading

0 comments on commit cfe4eb2

Please sign in to comment.