Skip to content

Commit

Permalink
Merge pull request #243 from simonsobs/koopman/pypi-builds
Browse files Browse the repository at this point in the history
Build and Deploy to PyPI
  • Loading branch information
BrianJKoopman committed Nov 19, 2021
2 parents e1d89f0 + 561ea36 commit 2c459e7
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Build Official Docker Images
name: Deploy Builds

on:
release:
types: [ released ]

jobs:
build:
test:
name: pytest with coverage
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -63,6 +64,18 @@ jobs:
coverage report
coveralls --service=github
docker:
name: build and deploy docker images
needs: test
runs-on: ubuntu-latest

steps:
- name: clone ocs
uses: actions/checkout@v2
# Fetch all history for all tags and branches
with:
fetch-depth: 0

# Dockerize
- name: Build all docker images
run: |
Expand All @@ -85,3 +98,45 @@ jobs:
docker-compose config | grep 'image: ' | awk -F ': ' '{ print $2 }' | xargs -I {} docker push ${DOCKERHUB_ORG}/{}:latest
docker-compose config | grep 'image: ' | awk -F ': ' '{ print $2 }' | xargs -I {} docker push ${DOCKERHUB_ORG}/{}:${DOCKER_TAG}
docker-compose config | grep 'image: ' | awk -F ': ' '{ print $2 }' | xargs -I {} echo ${DOCKERHUB_ORG}/{}:${DOCKER_TAG} pushed
wheel:
name: build and deploy to PyPI
needs: test
runs-on: ubuntu-latest
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}

steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: clone ocs
uses: actions/checkout@v2

- name: install build dependencies
run: |
python3 -m pip install --upgrade build twine
- name: build wheel
run: |
python3 -m build
- name: install wheel
run: |
python3 -m pip install dist/ocs*.whl
- name: install testing requirements
run: |
pip3 install -r requirements/testing.txt
- name: Run unit tests
working-directory: ./tests
run: |
python3 -m pytest -m 'not (integtest or spt3g)'
- name: upload to test PyPI
run: |
python3 -m twine upload --repository testpypi dist/*
15 changes: 14 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches: [ develop ]

jobs:
build:
test:
name: pytest with coverage
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -63,6 +64,18 @@ jobs:
coverage report
coveralls --service=github
build:
name: build and deploy dev images
needs: test
runs-on: ubuntu-latest

steps:
- name: clone ocs
uses: actions/checkout@v2
# Fetch all history for all tags and branches
with:
fetch-depth: 0

# Dockerize
- name: Build all docker images
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
pull_request:

jobs:
build:
test:
name: pytest with coverage
runs-on: ubuntu-latest

steps:
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN pip3 install dumb-init
# Copy in and install requirements
# This will leverage the cache for rebuilds when modifying OCS, avoiding
# downloading all the requirements again
COPY requirements/ /app/ocs/requirements
COPY requirements.txt /app/ocs/requirements.txt
WORKDIR /app/ocs/
RUN pip3 install -r requirements.txt
Expand Down
46 changes: 25 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,37 @@ historical look back of the housekeeping data.
Dependencies
------------

This code targets Python 3.5+.
This code targets Python 3.6+.

There are also several Python package dependencies, which are listed in the
`requirements.txt`_ file.
* `so3g`_ - Required for using the HK Aggregator Agent.
* `crossbar`_ (optional) - The supported WAMP router. Controllable via
`ocsbow`. Can be installed with pip
or run via Docker.

.. _requirements.txt: requirements.txt

Additionally ``crossbar`` is a required dependency which is not automatically
installed. It can be installed with pip or run via Docker.
.. _so3g: https://github.com/simonsobs/so3g
.. _crossbar: https://pypi.org/project/crossbar/

Installation
------------
Clone this repository and install using pip::

Install and update with pip::

$ pip3 install -U ocs

Installing from Source
``````````````````````

If you are considering contributing to OCS, or would like to use the
development branch, you will want to install from source. To do so, clone this
repository and install using pip::

$ git clone https://github.com/simonsobs/ocs.git
$ cd ocs/
$ pip3 install -r requirements.txt
$ python3 setup.py install
$ pip3 install .

**Note:** If you want to install locally, not globally, throw the `--user` flag
on both the pip3 and setup.py commands.

**Warning:** The master branch is not guaranteed to be stable, you might want
to checkout a particular version tag before installation depending on which
other software you are working with. See the latest `tags`_.

.. _tags: https://github.com/simonsobs/ocs/tags
on the pip3 commands.

Docker Images
-------------
Expand Down Expand Up @@ -118,7 +122,7 @@ then use docker run::

For more details see `tests/README.rst <tests_>`_.

.. _tests: tests/README.rst
.. _tests: https://github.com/simonsobs/ocs/blob/master/tests/README.rst

Example
-------
Expand All @@ -127,18 +131,18 @@ A self contained example, demonstrating the operation of a small observatory
with a single OCS Agent is contained in `example/miniobs/`_. See the `readme`_
in that directory for details.

.. _example/miniobs/: example/miniobs/
.. _readme: example/miniobs/README.rst
.. _example/miniobs/: https://github.com/simonsobs/ocs/tree/master/example/miniobs
.. _readme: https://github.com/simonsobs/ocs/blob/master/example/miniobs/README.rst

Contributing
------------
For guidelines on how to contribute to OCS see `CONTRIBUTING.rst`_.

.. _CONTRIBUTING.rst: CONTRIBUTING.rst
.. _CONTRIBUTING.rst: https://github.com/simonsobs/ocs/blob/master/CONTRIBUTING.rst

License
--------
This project is licensed under the BSD 2-Clause License - see the
`LICENSE.txt`_ file for details.

.. _LICENSE.txt: LICENSE.txt
.. _LICENSE.txt: https://github.com/simonsobs/ocs/blob/master/LICENSE.txt
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"versioneer-518",
]
build-backend = "setuptools.build_meta"
15 changes: 4 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
autobahn
twisted
deprecation
msgpack
influxdb
PyYAML

# InfluxDB Publisher
influxdb

# FakeDataAgent
numpy

# Lakeshore240
pyserial

# Documentation generation
# see docs/requirements.txt

Expand All @@ -22,9 +20,4 @@ colorama
tqdm

# testing
pytest
pytest-cov
docker
pytest-docker-compose
pytest-dependency
pytest-twisted
-r requirements/testing.txt
6 changes: 6 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pytest
pytest-cov
docker
pytest-docker-compose
pytest-dependency
pytest-twisted
30 changes: 29 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import versioneer

with open("README.rst", "r", encoding="utf-8") as fh:
long_description = fh.read()

setup (name = 'ocs',
description='Observatory Control System',
long_description=long_description,
long_description_content_type="text/x-rst",
package_dir={'ocs': 'ocs'},
packages=find_packages(include=['ocs', 'ocs.*']),
scripts=['bin/ocsbow'],
Expand All @@ -14,4 +19,27 @@
},
package_data={'': ['support/*json']},
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass())
cmdclass=versioneer.get_cmdclass(),
url="https://github.com/simonsobs/ocs",
project_urls={
"Source Code": "https://github.com/simonsobs/ocs",
"Documentation": "https://ocs.readthedocs.io/",
"Bug Tracker": "https://github.com/simonsobs/ocs/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Astronomy",
"Framework :: Twisted",
],
python_requires=">=3.6",
install_requires=[
'autobahn',
'twisted',
'deprecation',
'PyYAML',
'influxdb',
'numpy',
],
)

0 comments on commit 2c459e7

Please sign in to comment.