Skip to content

Commit

Permalink
[Core] Initial Commit
Browse files Browse the repository at this point in the history
Create a template repository for python manager plugins.
This should drastically cut down the work required to startup a new
python manager, and avoid re-arbitrating lint/CI/deployment
paradigms.

Signed-off-by: Elliot Morris <[email protected]>
  • Loading branch information
elliotcmorris committed Feb 17, 2023
0 parents commit 274c194
Show file tree
Hide file tree
Showing 16 changed files with 1,157 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # See docs, they say not to use '.github'
schedule:
interval: "weekly"
commit-message:
prefix: "[CI]"
39 changes: 39 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Wheels

on:
push:
branches:
- main
workflow_dispatch:
pull_request:

concurrency:
# Shared with `deploy-pypi`.
group: wheel-${{ github.ref }}
# Cancel any in-progress build or publish.
cancel-in-progress: true

jobs:
build_wheels:
name: Build wheel
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build wheels
run: pip wheel --no-deps --wheel-dir wheelhouse .

- uses: actions/upload-artifact@v3
with:
name: my_asset_manager_wheels
path: ./wheelhouse/*.whl
44 changes: 44 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Code quality
on: pull_request

jobs:
pylint:
runs-on: ubuntu-latest
name: Pylint
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install .
python -m pip install -r tests/requirements.txt
- name: Lint
uses: TheFoundryVisionmongers/[email protected]
with:
pylint-rcfile: "./pyproject.toml"
pylint-paths: >
plugin
tests
black:
runs-on: ubuntu-latest
name: Python formatting
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install black
- name: Check Python formatting
run: black --check .
53 changes: 53 additions & 0 deletions .github/workflows/deploy-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Deploy PyPI

concurrency:
# Shared with `build-wheels`.
group: wheel-${{ github.ref }}
# Allow `build-wheels` to finish.
cancel-in-progress: false

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish_testpypi:
name: Publish distribution 📦 to TestPyPI
runs-on: ubuntu-20.04
steps:
- name: Download wheels from commit ${{ github.sha }}
uses: dawidd6/action-download-artifact@v2
with:
workflow: build-wheels.yml
workflow_conclusion: success
commit: ${{ github.sha }}
name: my_asset_manager_wheels
path: dist

- name: Upload to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_ACCESS_TOKEN }}
repository_url: https://test.pypi.org/legacy/

publish_pypi:
name: Publish distribution 📦 to PyPI
needs: publish_testpypi
runs-on: ubuntu-20.04
steps:
- name: Download wheels from commit ${{ github.sha }}
uses: dawidd6/action-download-artifact@v2
with:
workflow: build-wheels.yml
workflow_conclusion: success
commit: ${{ github.sha }}
name: my_asset_manager_wheels
path: dist

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_ACCESS_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Runs pytest on the matrix of supported platforms any Python versions.
name: Test
on:
pull_request:

jobs:
# You may remove this test, this merely assures that the template
# works when you find-and-replace the MyAssetManager strings.
test_project_rename:
name: Project Rename
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- run: |
grep -RIl 'MyAssetManager' | xargs sed -i 's/MyAssetManager/RenamedAssetManager/g'
grep -RIl 'my_asset_manager' | xargs sed -i 's/my_asset_manager/renamed_asset_manager/g'
grep -RIl 'My Asset Manager' | xargs sed -i 's/My Asset Manager/Renamed Asset Manager/g'
grep -RIl 'myorg' | xargs sed -i 's/myorg/renamedorg/g'
mv plugin/my_asset_manager/MyAssetManagerInterface.py \
plugin/my_asset_manager/RenamedAssetManagerInterface.py
mv plugin/my_asset_manager plugin/renamed_asset_manager
python -m pip install .
python -m pip install -r tests/requirements.txt
python -m pytest -v ./tests
test:
name: ${{ matrix.os }} ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["windows-latest", "ubuntu-latest", "macos-latest"]
python: ["3.7", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: |
python -m pip install .
python -m pip install -r tests/requirements.txt
python -m pytest -v ./tests
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# 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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
Loading

0 comments on commit 274c194

Please sign in to comment.