Skip to content

Commit

Permalink
Add template updates to this project. (#148)
Browse files Browse the repository at this point in the history
* Add template updates to this project.

Incorporate learnings for project structuring from template.py.

* Fix pre-commit failures.

* More pre-commit fixes.

* More pre-commit fixes.
  • Loading branch information
alunduil authored Dec 11, 2022
1 parent 1a9c1b3 commit 8da722f
Show file tree
Hide file tree
Showing 47 changed files with 644 additions and 442 deletions.
9 changes: 1 addition & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
RUN su vscode -c "curl -sSL https://install.python-poetry.org | python3 -"

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
Expand All @@ -16,8 +14,3 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

RUN su vscode -c "curl -sSL https://install.python-poetry.org | python3 -"
28 changes: 6 additions & 22 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
// Options
"NODE_VERSION": "none"
}
},

Expand All @@ -21,34 +19,20 @@
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.analysis.typeCheckingMode": "basic",
"python.pythonPath": "${workspaceFolder}/.venv/bin/python",
"python.poetryPath": "/home/vscode/.local/bin/poetry",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.provider": "black",
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "${workspaceFolder}/.venv/bin/pylint",
"python.testing.pytestArgs": [
"--no-cov", "zfs_test"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"zeshuaro.vscode-python-poetry",
"ms-azuretools.vscode-docker",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
"elagil.pre-commit-helper",
"ms-azuretools.vscode-docker",
"DavidAnson.vscode-markdownlint",
"tamasfe.even-better-toml"
]
}
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
20 changes: 20 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependency Review Action
#
# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v2
41 changes: 41 additions & 0 deletions .github/workflows/poetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow runs poetry against the repository.
#
# You can adjust the behavior by modifying this file.
name: Run poetry

on: [pull_request]

permissions:
contents: read

jobs:
poetry:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python-version:
- "3.7" # EOL 2023-06-27
- "3.8" # EOL 2024-10
- "3.9" # EOL 2025-10
- "3.10" # EOL 2026-10
- "3.11" # EOL 2027-10
experimental: [false]
include:
- python-version: 3.x
experimental: true
steps:
- uses: actions/checkout@v3
- name: install poetry
run: pipx install poetry
- name: setup python-${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: poetry build
run: |
poetry build
tar -zvtf dist/zfs_replicate-*.tar.gz | grep zfs/replicate/
- name: poetry check
run: poetry check
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
50 changes: 25 additions & 25 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
---
name: pypi publish
on: # yamllint disable-line
release:
types: [created]
# This workflow runs poetry against the repository.
#
# You can adjust the behavior by modifying this file.
name: Publish to PyPi

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: build and publish
env:
PYPI_USER: ${{ secrets.PYPI_USERNAME }}
PYPI_PASS: ${{ secrets.PYPI_PASSWORD }}
run: |
poetry config http-basic.pypi $PYPI_USER $PYPI_PASS
poetry build
poetry publish
poetry:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install poetry
run: pipx install poetry
- name: setup python
uses: actions/setup-python@v4
with:
cache: poetry
- name: poetry build
run: poetry build
- name: poetry publish
run: poetry publish --username __token__ --password=${{ secrets.PYPI_API_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow runs pytest against the repository.
#
# You can adjust the behavior by modifying this file.
name: Run pytest

on: [push, pull_request]

permissions:
contents: read

jobs:
pytest:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python-version:
- "3.7" # EOL 2023-06-27
- "3.8" # EOL 2024-10
- "3.9" # EOL 2025-10
- "3.10" # EOL 2026-10
- "3.11" # EOL 2027-10
experimental: [false]
include:
- python-version: 3.x
experimental: true
steps:
- uses: actions/checkout@v3
- name: install poetry
run: pipx install poetry
- name: setup python-${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: poetry install
run: poetry install
- name: poetry run pytest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry run pytest
poetry run coveralls --service=github
64 changes: 0 additions & 64 deletions .github/workflows/python-checks.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow runs scripts.
#
# You can adjust the behavior by modifying this file.
name: Run scripts with --help

on: [pull_request]

permissions:
contents: read

jobs:
scripts:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
python-version:
- "3.7" # EOL 2023-06-27
- "3.8" # EOL 2024-10
- "3.9" # EOL 2025-10
- "3.10" # EOL 2026-10
- "3.11" # EOL 2027-10
experimental: [false]
include:
- python-version: 3.x
experimental: true
steps:
- uses: actions/checkout@v3
- name: install poetry
run: pipx install poetry
- name: setup python-${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: poetry install
run: poetry install
- name: initiliase --help
run: poetry run -- zfs-replicate --help
27 changes: 27 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests

on:
schedule:
- cron: '18 10 * * *'

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
Loading

0 comments on commit 8da722f

Please sign in to comment.