Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "github-actions"
commit-message:
prefix: "chore(ci)"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
commit-message:
prefix: "chore(deps)"
directory: "/"
schedule:
interval: "weekly"
versioning-strategy: "increase"
44 changes: 44 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Dependabot on pre-commit hooks

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref_name }}

on:
schedule:
- cron: 13 2 * * 0 # weekly

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.5.0
- uses: actions/setup-python@v4.5.0
with:
cache: pip
cache-dependency-path: pyproject.toml
check-latest: true
python-version: 3.11
- env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: python -m pip install -e ".[dev]"
- run: pre-commit autoupdate
- id: cache-pre-commit
uses: actions/cache@v3.3.1
with:
key: ${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
- if: ${{ ! steps.cache-pre-commit.outputs.cache-hit }}
run: pre-commit install-hooks
- uses: peter-evans/create-pull-request@v4.2.4
with:
author: "GitHub <noreply@github.com>"
base: ${{ github.ref_name }}
branch: dependabot/pre-commit/${{ github.ref_name }}
committer: "GitHub <noreply@github.com>"
commit-message: "chore(dev): bump pre-commit hooks"
labels: |
dependencies
pre-commit
title: "chore(dev): bump pre-commit hooks"
39 changes: 16 additions & 23 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
name: CD - Release Please

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref_name }}

on:
push:
branches: [main]

jobs:
release-please:
name: Release Please
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
- uses: GoogleCloudPlatform/release-please-action@v3.7.6
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: python
default-branch: main
- name: Checkout
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v2
- name: Set up Python
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Cache python env
if: ${{ steps.release.outputs.release_created }}
uses: actions/cache@v2
- if: steps.release.outputs.release_created
uses: actions/checkout@v3.5.0
- if: steps.release.outputs.release_created
uses: actions/setup-python@v4.5.0
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install deps
if: ${{ steps.release.outputs.release_created }}
cache: pip
cache-dependency-path: pyproject.toml
check-latest: true
python-version: 3.11
- if: steps.release.outputs.release_created
env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: |
python -m pip install pip flit
- name: Build and publish with Flit
if: ${{ steps.release.outputs.release_created }}
run: python -m pip install -e ".[dev]"
- if: steps.release.outputs.release_created
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.FLIT_TOKEN }}
Expand Down
111 changes: 46 additions & 65 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,63 @@
name: CI - Test package

concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}

on:
push:
branches: [main]
paths: [pyproject.toml, incipyt/**, tests/**, .github/workflows/test.yml]

pull_request:
branches: [main]
types: [opened, reopened, synchronize, ready_for_review]
types: [opened, reopened, synchronize, ready_for_review, unlocked]
paths: [pyproject.toml, incipyt/**, tests/**, .github/workflows/test.yml]


jobs:
lint:
name: Lint
pre-commit:
name: Pre-commit (include linter)
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Cache python env
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install deps
env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: |
python -m pip install pip flit
python -m flit install --pth-file --deps develop
- name: Check format with black
run: python -m black -v --check .
- name: Lint with flakeheaven
run: python -m flakeheaven lint -v incipyt

- uses: actions/checkout@v3.5.0
- uses: actions/setup-python@v4.5.0
with:
cache: pip
cache-dependency-path: pyproject.toml
check-latest: true
python-version: 3.11
- env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: python -m pip install -e ".[dev]"
- uses: actions/cache@v3.3.1
with:
key: ${{ hashFiles('.pre-commit-config.yaml') }}
path: ~/.cache/pre-commit
- run: pre-commit run --all-files
test:
name: Tests
needs: lint
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
fail-fast: false
runs-on: ${{ matrix.os }}
env:
_OS: ${{ matrix.os }}
_PY: ${{ matrix.python-version }}

name: Run all tests
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Cache python env
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install deps
env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: |
python -m pip install pip flit
python -m flit install --pth-file --deps develop
- name: Run tests with pytest
run: pytest -v --cov=incipyt --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
env_vars: _OS,_PY
- uses: actions/checkout@v3.5.0
- uses: actions/setup-python@v4.5.0
with:
cache: pip
cache-dependency-path: pyproject.toml
check-latest: true
python-version: ${{ matrix.python-version }}
- env:
PIP_UPGRADE: True
PIP_UPGRADE_STRATEGY: eager
run: python -m pip install -e ".[test]"
- run: python -m pytest --cov=incipyt --cov-report=xml
- uses: codecov/codecov-action@v3.1.1
with:
fail_ci_if_error: true
env_vars: _OS,_PY
48 changes: 23 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
repos:
- repo: https://github.com/psf/black
rev: 22.1.0
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
hooks:
- id: black
- id: conventional-pre-commit
stages: [commit-msg]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.260
hooks:
- id: ruff
args: [--exit-non-zero-on-fix, --fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-case-conflict
- id: detect-private-key
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: debug-statements
- id: check-toml
- id: check-yaml
- repo: https://github.com/flakeheaven/flakeheaven
rev: 0.11.0
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: flakeheaven
additional_dependencies: [
flake8,
flake8-bandit,
flake8-bugbear,
flake8-builtins,
flake8-comprehensions,
flake8-docstrings,
flake8-simplify,
flake8-use-fstring,
pep8-naming,
]
- id: black
24 changes: 18 additions & 6 deletions incipyt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import click

from incipyt import tools, project

from incipyt import project, tools
from incipyt._internal.utils import EnvValue

logger = logging.getLogger(__name__)
DEFAULT_LOGGING_LEVEL = logging.WARNING
Expand Down Expand Up @@ -62,7 +62,15 @@ def choice_callback(_ctx, _param, _choice):
is_flag=True,
help="Build the package after initialization of all files and folders.",
)
def main(folder, verbose, silent, vcs, env, build, check_build):
@click.option(
"--license",
required=True,
default="Copyright",
type=click.Choice(tools.license.classifiers, case_sensitive=False),
help="Software license",
prompt=True,
)
def main(folder, verbose, silent, vcs, env, build, check_build, license): # noqa: A002
log_level = DEFAULT_LOGGING_LEVEL - verbose * 10 + silent * 10
setup_logging(max(logging.NOTSET, min(log_level, logging.CRITICAL)))

Expand All @@ -77,7 +85,11 @@ def main(folder, verbose, silent, vcs, env, build, check_build):
raise click.BadArgumentUsage(f"FOLDER {folder} is not empty.")
project.environ["PROJECT_NAME"] = folder.name

tools_to_install = [tool for tool in [vcs(), env(), build(check_build)] if tool]
project.environ["LICENSE"] = EnvValue(license, confirmed=True)

tools_to_install = [
tool for tool in [tools.License(), vcs(), env(), build(check_build)] if tool
]

for tool in tools_to_install:
logger.info("Using %s", tool)
Expand Down Expand Up @@ -139,14 +151,14 @@ def setup_logging(verbosity):
root_logger.level = max(verbosity, logging.DEBUG)
logger.level = root_logger.level - 10
if verbosity < logging.DEBUG:
logging.captureWarnings(True)
logging.captureWarnings(capture=True)
warnings.filterwarnings("default")


# Remove '' and current working directory from the first entry of sys.path, if
# present to avoid using current directory in incipyt commands, when invoked as
# python -m incipyt <command>
if sys.path[0] in ("", os.getcwd()):
if sys.path[0] in ("", os.getcwd()): # noqa: PTH109
sys.path.pop(0)

if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion incipyt/_internal/dumpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import configparser
import os
import pathlib

from abc import ABC, abstractmethod

import toml
Expand Down
Loading