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

Commit a6e3fd5

Browse files
committed
Added initial structure
0 parents  commit a6e3fd5

40 files changed

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

.github/workflows/docs.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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: Build docs
23+
uses: dls-controls/pipenv-run-action@v1
24+
with:
25+
pipenv-run: docs
26+
27+
- name: Move to versioned directory
28+
# e.g. master or 0.1.2
29+
run: mv build/html ".github/pages/${GITHUB_REF##*/}"
30+
31+
- name: Write versions.txt
32+
run: pipenv run sphinx_rtd_theme_github_versions .github/pages
33+
34+
- name: Publish Docs to gh-pages
35+
if: github.event_name == 'push'
36+
# We pin to the SHA, not the tag, for security reasons.
37+
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
38+
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
publish_dir: .github/pages
42+
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)