Skip to content

Commit a1c8ecc

Browse files
committed
Build system for pipenv, docs, CI
1 parent af652c2 commit a1c8ecc

File tree

22 files changed

+1101
-408
lines changed

22 files changed

+1101
-408
lines changed

.github/pages/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Redirecting to master branch</title>
5+
<meta charset="utf-8">
6+
<meta http-equiv="refresh" content="0; url=./master/index.html">
7+
<link rel="canonical" href="master/index.html">
8+
</head>
9+
</html>

.github/workflows/code.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Code CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
runs-on: "ubuntu-latest"
10+
steps:
11+
- name: Checkout Source
12+
uses: actions/checkout@v2
13+
14+
- name: Install Python
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: '3.7'
18+
19+
- name: Install Python Dependencies
20+
run: pip install flake8
21+
22+
- name: Lint
23+
run: flake8
24+
25+
build:
26+
name: ${{ matrix.os }}/${{ matrix.python }}
27+
runs-on: ${{ matrix.os }}
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
python: [cp27, cp37, cp38, cp39]
34+
35+
include:
36+
- os: macos-latest
37+
TEST_REQUIRES: pytest-cov cothread
38+
# Put coverage straight in the dist dir
39+
COV_FILE: '{project}/dist/coverage.xml'
40+
41+
- os: ubuntu-latest
42+
TEST_REQUIRES: pytest-cov cothread
43+
# Put coverage in the output dir mounted in docker
44+
COV_FILE: '/output/coverage.xml'
45+
46+
- os: windows-latest
47+
# cothread doesn't work on windows
48+
TEST_REQUIRES: pytest-cov
49+
# Put coverage straight in the dist dir
50+
COV_FILE: '{project}/dist/coverage.xml'
51+
52+
steps:
53+
- name: Checkout Source
54+
uses: actions/checkout@v2
55+
with:
56+
submodules: true
57+
58+
- name: Install Python
59+
uses: actions/setup-python@v2
60+
with:
61+
python-version: '3.7'
62+
63+
- name: Install Python Dependencies
64+
run: pip install twine build cibuildwheel
65+
66+
- name: Build Sdist
67+
run: python -m build --sdist .
68+
69+
- name: Build Wheel
70+
run: cibuildwheel --output-dir dist
71+
env:
72+
CIBW_BUILD: ${{ matrix.python }}*64
73+
CIBW_TEST_REQUIRES: ${{ matrix.TEST_REQUIRES }}
74+
CIBW_TEST_COMMAND: pytest --cov=softioc {project}/tests --cov-report xml:${{ matrix.COV_FILE }}
75+
# Disable auditwheel as it isn't compatible with setuptools_dso approach
76+
# https://github.com/mdavidsaver/setuptools_dso/issues/17
77+
CIBW_REPAIR_WHEEL_COMMAND: ''
78+
79+
- name: Upload Wheel and Sdist
80+
uses: actions/upload-artifact@v2
81+
with:
82+
path: dist/softioc*
83+
84+
- name: Upload coverage to Codecov
85+
uses: codecov/codecov-action@v1
86+
with:
87+
name: ${{ matrix.os }}/${{ matrix.python }}
88+
directory: dist
89+
90+
upload_pypi:
91+
needs: [build]
92+
runs-on: ubuntu-latest
93+
# upload to PyPI on every tag
94+
#if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
95+
steps:
96+
- uses: actions/download-artifact@v2
97+
with:
98+
path: dist
99+
100+
- name: Display structure of downloaded files
101+
run: ls -R
102+
103+
- name: Publish to PyPI
104+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
105+
env:
106+
TWINE_USERNAME: __token__
107+
TWINE_PASSWORD: ${{ secrets.pypi_token }}
108+
run: twine upload dist/*
109+

.github/workflows/docs.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
name: Docs CI
3+
4+
on:
5+
push:
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Source
14+
uses: actions/checkout@v2
15+
with:
16+
# require all of history to see all tagged versions' docs
17+
fetch-depth: 0
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: "3.7"
23+
24+
- name: Install Packages
25+
# Can delete this if you don't use graphviz in your docs
26+
run: sudo apt-get install graphviz
27+
28+
- name: Install Python Dependencies
29+
run: |
30+
pip install pipenv
31+
pipenv install --dev --deploy --python $(which python) && pipenv graph
32+
33+
- name: Deploy index
34+
# We pin to the SHA, not the tag, for security reasons.
35+
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
36+
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
37+
with:
38+
github_token: ${{ secrets.GITHUB_TOKEN }}
39+
publish_dir: .github/pages
40+
keep_files: true
41+
42+
- name: Checkout gh-pages
43+
# As we already did a deploy of gh-pages above, it is guaranteed to be there
44+
# so check it out so we can selectively build docs below
45+
uses: actions/checkout@v2
46+
with:
47+
ref: gh-pages
48+
path: build/html
49+
50+
- name: Maybe use sphinx-multiversion
51+
# If we are building master or a tag we will publish
52+
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
53+
# So use the args we normally pass to sphinx-build, but run sphinx-multiversion
54+
run: mv $(pipenv --venv)/bin/sphinx-multiversion $(pipenv --venv)/bin/sphinx-build
55+
56+
- name: Build Docs
57+
run: pipenv run docs
58+
59+
- name: Publish Docs to gh-pages
60+
# Only master and tags are published
61+
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
62+
# We pin to the SHA, not the tag, for security reasons.
63+
# https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
64+
uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3
65+
with:
66+
github_token: ${{ secrets.GITHUB_TOKEN }}
67+
publish_dir: build/html
68+
keep_files: true
69+

.gitignore

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,67 @@
1-
/.vscode
2-
/venv
3-
*.pyc
4-
/docs/html/
5-
/softioc/_extension.*
6-
7-
# Dist build output
8-
/build
9-
/dist
10-
/softioc.egg-info/
11-
12-
# Coverage reports
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
.Python
10+
env/
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
1339
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*,cover
45+
*.mypy_cache
46+
*.pytest_cache
1447
cov.xml
1548

49+
# DLS build dir and virtual environment
50+
/prefix/
51+
/venv/
52+
/lightweight-venv/
53+
/installed.files
54+
55+
# Docs output
1656
/docs/papers/*/*.aux
1757
/docs/papers/*/*.pdf
1858
/docs/papers/*/*.nav
1959
/docs/papers/*/*.out
2060
/docs/papers/*/*.snm
2161
/docs/papers/*/*.toc
2262
/docs/papers/*/*.vrb
63+
64+
# setup.py develop (via pipenv install) places this link here
65+
# so editable installs work. Related:
66+
# https://github.com/mdavidsaver/setuptools_dso/issues/11
67+
/epicscorelibs

Pipfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@ sphinx-rtd-theme = "*"
1010
# switch to main repo after PR https://github.com/Holzhaus/sphinx-multiversion/pull/60 is merged
1111
sphinx-multiversion = {editable = true,git = "https://github.com/dls-controls/sphinx-multiversion.git",ref = "only-arg"}
1212
setuptools-dso = "*"
13+
aioca = "*"
1314

1415
[packages]
1516
# All other package requirements from setup.py
16-
softioc = {editable = true,path = "."}
17+
softioc = {editable = true, path = "."}
18+
# Apart from the epicscorelibs which comes from pyproject.toml so needs to be here too
19+
epicscorelibs = "*"
20+
# Add some other useful extras
21+
cothread = "*"
22+
scipy = "*"
1723

1824
[scripts]
1925
# Put coverage here so we don't interfere with debugging in the IDE
20-
tests = "python -m pytest --cov=epicsdbbuilder --cov-report term"
26+
# Put flake8 here so we don't run it during cibuildwheel tests
27+
tests = "python -m pytest --cov=softioc --cov-report term --flake8"
2128
docs = "sphinx-build -EWT --keep-going docs build/html"
22-
clean = "rm -rf build prefix */__pycache__ .coverage cov.xml *.egg-info .mypy_cache .pytest_cache"
29+
gitclean = "git clean -fdX"

0 commit comments

Comments
 (0)