Skip to content

Commit

Permalink
Build system for pipenv, docs, CI
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed May 6, 2021
1 parent af652c2 commit 536f51e
Show file tree
Hide file tree
Showing 19 changed files with 1,062 additions and 396 deletions.
9 changes: 9 additions & 0 deletions .github/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to master branch</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./master/index.html">
<link rel="canonical" href="master/index.html">
</head>
</html>
79 changes: 79 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Code CI

on:
push:
pull_request:

jobs:
build:
name: ${{ matrix.os }}/${{ matrix.python }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: true

- name: Display structure of downloaded files
run: ls -R

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.7'

- name: Install Python Dependencies
run: pip install twine build

- name: Build Sdist
run: python -m build --sdist .

- name: Build Wheel
uses: joerick/[email protected]
env:
CIBW_BEFORE_TEST: pip install pipenv && pipenv install --dev --deploy && pipenv graph
CIBW_TEST_COMMAND: pytest {project} --cov={package} --cov-report xml:cov.xml
CIBW_REPAIR_WHEEL_COMMAND: ''

- name: Display structure of produced files
run: ls -R dist wheelhouse

- name: Upload Wheel and Sdist
uses: actions/upload-artifact@v2
with:
path: |
./wheelhouse/*.whl
dist/*
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
name: ${{ matrix.os }}/${{ matrix.python }}
files: cov.xml

upload_pypi:
needs: [build]
runs-on: ubuntu-latest
# upload to PyPI on every tag
#if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v2
with:
path: dist

- name: Display structure of downloaded files
run: ls -R

- name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_token }}
run: twine upload dist/*

69 changes: 69 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

name: Docs CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
# require all of history to see all tagged versions' docs
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"

- name: Install Packages
# Can delete this if you don't use graphviz in your docs
run: sudo apt-get install graphviz

- name: Install Python Dependencies
run: |
pip install pipenv
pipenv install --dev --deploy --python $(which python) && pipenv graph
- name: Deploy index
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .github/pages
keep_files: true

- name: Checkout gh-pages
# As we already did a deploy of gh-pages above, it is guaranteed to be there
# so check it out so we can selectively build docs below
uses: actions/checkout@v2
with:
ref: gh-pages
path: build/html

- name: Maybe use sphinx-multiversion
# If we are building master or a tag we will publish
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
# So use the args we normally pass to sphinx-build, but run sphinx-multiversion
run: mv $(pipenv --venv)/bin/sphinx-multiversion $(pipenv --venv)/bin/sphinx-build

- name: Build Docs
run: pipenv run docs

- name: Publish Docs to gh-pages
# Only master and tags are published
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/html
keep_files: true

69 changes: 57 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,67 @@
/.vscode
/venv
*.pyc
/docs/html/
/softioc/_extension.*

# Dist build output
/build
/dist
/softioc.egg-info/

# Coverage reports
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.mypy_cache
*.pytest_cache
cov.xml

# DLS build dir and virtual environment
/prefix/
/venv/
/lightweight-venv/
/installed.files

# Docs output
/docs/papers/*/*.aux
/docs/papers/*/*.pdf
/docs/papers/*/*.nav
/docs/papers/*/*.out
/docs/papers/*/*.snm
/docs/papers/*/*.toc
/docs/papers/*/*.vrb

# setup.py develop (via pipenv install) places this link here
# so editable installs work. Related:
# https://github.com/mdavidsaver/setuptools_dso/issues/11
/epicscorelibs
14 changes: 11 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ sphinx-rtd-theme = "*"
# switch to main repo after PR https://github.com/Holzhaus/sphinx-multiversion/pull/60 is merged
sphinx-multiversion = {editable = true,git = "https://github.com/dls-controls/sphinx-multiversion.git",ref = "only-arg"}
setuptools-dso = "*"
# Same version of wheel as inside DLS
wheel = "0.33.1"
aioca = "*"

[packages]
# All other package requirements from setup.py
softioc = {editable = true,path = "."}
softioc = {editable = true, path = "."}
# Apart from the epicscorelibs which comes from pyproject.toml so needs to be here too
epicscorelibs = "*"
# And some other useful libs that pythonIocs might needs
scipy = "*"
cothread = "*"

[scripts]
# Put coverage here so we don't interfere with debugging in the IDE
tests = "python -m pytest --cov=epicsdbbuilder --cov-report term"
tests = "python -m pytest --cov=softioc --cov-report term"
docs = "sphinx-build -EWT --keep-going docs build/html"
clean = "rm -rf build prefix */__pycache__ .coverage cov.xml *.egg-info .mypy_cache .pytest_cache"
gitclean = "git clean -fdX"
Loading

0 comments on commit 536f51e

Please sign in to comment.