Skip to content

Commit

Permalink
feat(init): Initial commit of CI
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Mar 19, 2024
1 parent d5837ed commit f40f116
Show file tree
Hide file tree
Showing 25 changed files with 1,183 additions and 1 deletion.
106 changes: 106 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
name: CI

on: [push, pull_request]

jobs:

test:
name: Unit tests
strategy:
matrix:
python-version: ['3.7', '3.10']
os: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: run tests
run: python -m pytest tests/

deploy:
name: Deploy to GitHub and PyPI
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master' && github.repository_owner == 'ladybug-tools'
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: set up node # we need node for for semantic release
uses: actions/[email protected]
with:
node-version: 14.2.0
- name: install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: install semantic-release
run:
npm install @semantic-release/exec
- name: run semantic release
id: new_release
run: |
nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`"
npx semantic-release@^17.0.0
echo "::set-output name=tag::$nextRelease"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
- name: sleep for 5 minutes for PyPI update
if: contains(steps.new_release.outputs.tag, '.')
run: sleep 300s
shell: bash
- name: Update lbt-dragonfly
if: contains(steps.new_release.outputs.tag, '.')
env:
DISPATCH_REPO: ladybug-tools/lbt-dragonfly
DEPS_TOKEN: ${{ secrets.DEPS_UPDATING }}
run: |
curl -X POST https://api.github.com/repos/$DISPATCH_REPO/dispatches \
-H "Accept: application/vnd.github.everest-preview+json" \
-d '{"event_type": "dragonfly_display_release", "client_payload": {"version": "${{ steps.new_release.outputs.tag }}"}}' \
-u ladybugbot:$DEPS_TOKEN
docs:
name: Generate docs
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master' && github.repository_owner == 'ladybug-tools'
steps:
- uses: actions/checkout@v2
- name: set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: install dependencies
run: |
pip install -U .
pip install -r dev-requirements.txt
sphinx-apidoc -f -e -d 4 -o ./docs ./dragonfly_display
sphinx-build -b html ./docs ./docs/_build/docs
- name: deploy to github pages
uses: peaceiris/actions-gh-pages@v3
with:
# this will use ladybugbot token
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: docs/_build/
force_orphan: true
keep_files: false
full_commit_message: 'deploy: update docs'
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.pyc
test.py
.pytest_cache
*__pycache__
.coverage
*.ipynb
.ipynb_checkpoints
.tox
*.egg-info
tox.ini
/.cache
/.vscode
.eggs
*.code-workspace
/build
13 changes: 13 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
[
"@semantic-release/exec",
{
"publishCmd": "bash deploy.sh ${nextRelease.version}"
}
]
]
}
4 changes: 4 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributor Covenant Code of Conduct
=========================================

This project follows Ladybug Tools contributor covenant code of conduct. See our [contributor covenant code of conduct](https://github.com/ladybug-tools/contributing/blob/master/CODE-OF-CONDUCT.md).
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Contributing
------------
We welcome contributions from anyone, even if you are new to open source we will be happy to help you to get started. Most of the Ladybug Tools developers started learning programming through developing for Ladybug Tools.

### Code contribution
This project follows Ladybug Tools contributing guideline. See [contributing to Ladybug Tools projects](https://github.com/ladybug-tools/contributing/blob/master/README.md).
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM python:3.10-slim

LABEL maintainer="Ladybug Tools" email="[email protected]"

ENV HOMEDIR='/home/ladybugbot'
ENV PATH="${HOMEDIR}/.local/bin:${PATH}"
ENV LIBRARYDIR="${HOMEDIR}/lib"
ENV RUNDIR="${HOMEDIR}/run"

RUN apt-get update \
&& apt-get -y install ffmpeg libsm6 libxext6 xvfb --no-install-recommends git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN adduser ladybugbot --uid 1000 --disabled-password --gecos ""
USER ladybugbot
WORKDIR ${HOMEDIR}
RUN mkdir ladybug_tools && touch ladybug_tools/config.json

# Install dragonfly-display
COPY dragonfly_display ${LIBRARYDIR}/dragonfly_display
COPY .git ${LIBRARYDIR}/.git
COPY setup.py ${LIBRARYDIR}
COPY setup.cfg ${LIBRARYDIR}
COPY requirements.txt ${LIBRARYDIR}
COPY extras-requirements.txt ${LIBRARYDIR}
COPY README.md ${LIBRARYDIR}
COPY LICENSE ${LIBRARYDIR}

USER root
RUN pip3 install --no-cache-dir setuptools wheel xvfbwrapper \
&& pip3 install --no-cache-dir ${LIBRARYDIR}[full] \
&& apt-get -y --purge remove git \
&& apt-get -y clean \
&& apt-get -y autoremove \
&& rm -rf ${LIBRARYDIR}/.git

USER ladybugbot
# Set up working directory
RUN mkdir -p ${RUNDIR}/simulation
WORKDIR ${RUNDIR}
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
[![Build Status](https://github.com/ladybug-tools/dragonfly-display/workflows/CI/badge.svg)](https://github.com/ladybug-tools/dragonfly-display/actions)

[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/) [![Python 2.7](https://img.shields.io/badge/python-2.7-green.svg)](https://www.python.org/downloads/release/python-270/) [![IronPython](https://img.shields.io/badge/ironpython-2.7-red.svg)](https://github.com/IronLanguages/ironpython2/releases/tag/ipy-2.7.8/)

# dragonfly-display
:dragon: 💻 Adds methods to translate dragonfly objects to VisualizationSets

Adds methods and a CLI to translate dragonfly objects to VisualizationSets.

## Installation

```console
pip install -U dragonfly-display
```

If you want to also include all dependencies needed to produce VTK visualizations
from dragonfly Models use.

```console
pip install -U dragonfly-display[full]
```

To check if the command line interface is installed correctly use `dragonfly-display --help`

## QuickStart

```python
import dragonfly_display

```

## [API Documentation](http://ladybug-tools.github.io/dragonfly-display/docs)

## Local Development

1. Clone this repo locally
```console
git clone [email protected]:ladybug-tools/dragonfly-display

# or

git clone https://github.com/ladybug-tools/dragonfly-display
```
2. Install dependencies:
```console
cd dragonfly-display
pip install -r dev-requirements.txt
pip install -r requirements.txt
```

3. Run Tests:
```console
python -m pytest tests/
```

4. Generate Documentation:
```console
sphinx-apidoc -f -e -d 4 -o ./docs ./dragonfly_display
sphinx-build -b html ./docs ./docs/_build/docs
```
28 changes: 28 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

if [ -n "$1" ]
then
NEXT_RELEASE_VERSION=$1
else
echo "A release version must be supplied"
exit 1
fi

CONTAINER_NAME="ladybugtools/dragonfly-display"

echo "PyPi Deployment..."
echo "Building distribution"
python setup.py sdist bdist_wheel
echo "Pushing new version to PyPi"
twine upload dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD


echo "Docker Deployment..."
echo "Login to Docker"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

docker build . -t $CONTAINER_NAME:$NEXT_RELEASE_VERSION
docker tag $CONTAINER_NAME:$NEXT_RELEASE_VERSION $CONTAINER_NAME:latest

docker push $CONTAINER_NAME:latest
docker push $CONTAINER_NAME:$NEXT_RELEASE_VERSION
23 changes: 23 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
coverage==5.5
coveralls==1.7.0;python_version<'3.0'
coveralls==2.2.0;python_version>='3.6'
pytest==4.6.9;python_version<'3.0'
pytest==6.2.4;python_version>='3.6'
pytest-cov==2.12.0
Sphinx==1.8.5;python_version<'3.0'
Sphinx==5.3.0;python_version>='3.6'
docutils==0.17;python_version>='3.6'
sphinx-bootstrap-theme==0.8.1
sphinxcontrib-fulltoc==1.2.0
sphinxcontrib-websupport==1.1.2;python_version<'3.0'
sphinxcontrib-websupport==1.2.4;python_version>='3.6'
sphinx-click==4.4.0
twine==1.13.0;python_version<'3.0'
twine==3.4.1;python_version>='3.6'
wheel==0.38.1
setuptools==44.1.0;python_version<'3.0'
setuptools==65.5.1;python_version>='3.6'
importlib-metadata==2.0.0;python_version<'3.0'
importlib-metadata==4.8.0;python_version>='3.6'
jinja2==3.0.3;python_version>='3.6'
markupsafe==2.0.1;python_version>='3.6'
14 changes: 14 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

## Usage
For generating the documents locally use commands below from the root folder.

```shell
# install dependencies
cd dragonfly_display
pip install -r dev-requirements.txt

# generate rst files for modules
sphinx-apidoc -f -e -d 4 -o ./docs ./dragonfly_display
# build the documentation under _build/docs folder
sphinx-build -b html ./docs ./docs/_build/docs
```
1 change: 1 addition & 0 deletions docs/_build/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions docs/_build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# documentation
1 change: 1 addition & 0 deletions docs/_build/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# documentation
48 changes: 48 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* bootstrap-sphinx.css
* ~~~~~~~~~~~~~~~~~~~~
*
* Sphinx stylesheet -- Bootstrap theme.
*/


/* The code below is based on the bootstrap website sidebar */


/* Show and affix the side nav when space allows it */
@media screen and (min-width: 992px) {
.bs-sidenav .nav > .active > ul {
display: block;
}
div.bs-sidenav ul {
margin-bottom: 0;
padding-left: 5px;
list-style: none;
}
div.bs-sidenav a {
color: #333333;
}
/* Widen the fixed sidenav */
.bs-sidenav.affix,
.bs-sidenav.affix-bottom {
width: 292px;
}
.bs-sidenav.affix {
position: fixed; /* Undo the static from mobile first approach */
}
.bs-sidenav.affix-bottom {
position: absolute; /* Undo the static from mobile first approach */
}
.bs-sidenav.affix-bottom .bs-sidenav,
.bs-sidenav.affix .bs-sidenav {
margin-top: 0;
margin-bottom: 0;
}
}
@media screen and (min-width: 1200px) {
/* Widen the fixed sidenav again */
.bs-sidenav.affix-bottom,
.bs-sidenav.affix {
width: 360px;
}
}
Loading

0 comments on commit f40f116

Please sign in to comment.