Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit ededf00

Browse files
committed
Initial structure
0 parents  commit ededf00

39 files changed

+1431
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/*/_version_git.py export-subst

.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: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Code CI
2+
3+
on:
4+
push:
5+
branches:
6+
# Restricting to these branches and tags stops duplicate jobs on internal
7+
# PRs but stops CI running on internal branches without a PR. Delete the
8+
# next 5 lines to restore the original behaviour
9+
- master
10+
- main
11+
tags:
12+
- "*"
13+
pull_request:
14+
schedule:
15+
# Run every Monday at 8am to check latest versions of dependencies
16+
- cron: '0 8 * * MON'
17+
18+
jobs:
19+
lint:
20+
runs-on: "ubuntu-latest"
21+
steps:
22+
- name: Run black, flake8, mypy
23+
uses: dls-controls/pipenv-run-action@v1
24+
with:
25+
pipenv-run: lint
26+
27+
wheel:
28+
runs-on: "ubuntu-latest"
29+
steps:
30+
- uses: actions/checkout@v2
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Create Sdist and Wheel
35+
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
36+
# https://reproducible-builds.org/
37+
# Set group writable and umask to do the same to match inside DLS
38+
run: |
39+
chmod -R g+w .
40+
umask 0002
41+
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel
42+
43+
- name: Test cli works from the installed wheel
44+
# Can remove the repository reference after https://github.com/pypa/pipx/pull/733
45+
run: pipx run --spec dist/*.whl ${GITHUB_REPOSITORY##*/} --version
46+
47+
- name: Upload Wheel and Sdist as artifacts
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: dist
51+
path: dist/*
52+
53+
test:
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
os: ["ubuntu-latest"] # can add windows-latest, macos-latest
58+
python: ["3.7", "3.8", "3.9"]
59+
pipenv: ["skip-lock"]
60+
61+
include:
62+
# Add an extra Python3.7 runner to use the lockfile
63+
- os: "ubuntu-latest"
64+
python: "3.7"
65+
pipenv: "deploy"
66+
67+
runs-on: ${{ matrix.os }}
68+
env:
69+
# https://github.com/pytest-dev/pytest/issues/2042
70+
PY_IGNORE_IMPORTMISMATCH: "1"
71+
72+
steps:
73+
- name: Setup repo and test
74+
uses: dls-controls/pipenv-run-action@v1
75+
with:
76+
python-version: ${{ matrix.python }}
77+
pipenv-install: --dev --${{ matrix.pipenv }}
78+
allow-editable-installs: ${{ matrix.pipenv == 'deploy' }}
79+
pipenv-run: tests
80+
81+
- name: Upload coverage to Codecov
82+
uses: codecov/codecov-action@v2
83+
with:
84+
name: ${{ matrix.python }}/${{ matrix.os }}/${{ matrix.pipenv }}
85+
files: cov.xml
86+
87+
release:
88+
needs: [lint, wheel, test]
89+
runs-on: ubuntu-latest
90+
# upload to PyPI and make a release on every tag
91+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
92+
steps:
93+
- uses: actions/download-artifact@v2
94+
with:
95+
name: dist
96+
path: dist
97+
98+
- name: Github Release
99+
# We pin to the SHA, not the tag, for security reasons.
100+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
101+
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
102+
with:
103+
files: dist/*
104+
generate_release_notes: true
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
108+
- name: Publish to PyPI
109+
env:
110+
TWINE_USERNAME: __token__
111+
TWINE_PASSWORD: ${{ secrets.pypi_token }}
112+
run: pipx run twine upload dist/*

.github/workflows/docs.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docs CI
2+
3+
on:
4+
push:
5+
branches:
6+
# Add more branches here to publish docs from other branches
7+
- master
8+
- main
9+
tags:
10+
- "*"
11+
pull_request:
12+
13+
jobs:
14+
docs:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Avoid git conflicts when tag and branch pushed at same time
19+
if: startsWith(github.ref, 'refs/tags')
20+
run: sleep 60
21+
22+
- name: Install Packages
23+
# Can delete this if you don't use graphviz in your docs
24+
run: sudo apt-get install graphviz
25+
26+
- name: Build docs
27+
uses: dls-controls/pipenv-run-action@v1
28+
with:
29+
pipenv-run: docs
30+
31+
- name: Move to versioned directory
32+
# e.g. master or 0.1.2
33+
run: mv build/html ".github/pages/${GITHUB_REF##*/}"
34+
35+
- name: Write versions.txt
36+
run: pipenv run sphinx_rtd_theme_github_versions .github/pages
37+
38+
- name: Publish Docs to gh-pages
39+
if: github.event_name == 'push'
40+
# We pin to the SHA, not the tag, for security reasons.
41+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
42+
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
43+
with:
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
publish_dir: .github/pages
46+
keep_files: true

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
cov.xml
45+
.pytest_cache/
46+
.mypy_cache/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
55+
# Sphinx documentation
56+
docs/_build/
57+
58+
# PyBuilder
59+
target/
60+
61+
# DLS build dir and virtual environment
62+
/prefix/
63+
/venv/
64+
/lightweight-venv/
65+
/installed.files

.gitlab-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include:
2+
- project: 'controls/reports/ci_templates'
3+
ref: master
4+
file: 'python3/dls_py3_template.yml'

.gitremotes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github [email protected]:dls-controls/dls-python3-skeleton.git

.pre-commit-config.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-yaml
7+
- id: check-merge-conflict
8+
9+
- repo: local
10+
hooks:
11+
- id: black
12+
name: Run black
13+
stages: [commit]
14+
language: system
15+
entry: pipenv run black --check --diff
16+
types: [python]
17+
18+
- id: flake8
19+
name: Run flake8
20+
stages: [commit]
21+
language: system
22+
entry: pipenv run flake8
23+
types: [python]
24+
exclude: setup.py
25+
26+
- id: mypy
27+
name: Run mypy
28+
stages: [commit]
29+
language: system
30+
entry: pipenv run mypy src tests
31+
pass_filenames: false

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"ms-python.vscode-pylance",
4+
"ms-python.python",
5+
"ryanluker.vscode-coverage-gutters"
6+
]
7+
}

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug Unit Test",
9+
"type": "python",
10+
"request": "launch",
11+
"justMyCode": false,
12+
"program": "${file}",
13+
"purpose": ["debug-test"],
14+
"console": "integratedTerminal",
15+
"env": {
16+
// The default config in setup.cfg's "[tool:pytest]" adds coverage.
17+
// Cannot have coverage and debugging at the same time.
18+
// https://github.com/microsoft/vscode-python/issues/693
19+
"PYTEST_ADDOPTS": "--no-cov"
20+
},
21+
}
22+
]
23+
}

0 commit comments

Comments
 (0)