Skip to content

Commit

Permalink
Enhanced user input (#260)
Browse files Browse the repository at this point in the history
* use a new toolkit for user prompting: questionary (patched).
* multiline questions.
* conditional questions.
* new toolkit for ui tests: pexpect.
* fix lots of tests.
* fix windows builds with newer poetry-dynamic-versioning.
* linters and mypy are now tests, to have faster ci.
* update deprecated ci commands.
* removed dependencies from old times.
* Remove toml 0.5+ syntax (dotted keys)
* Use powershell where syntax is compatible
* Change skip to xfail
* xfail pexpect tests on windows. I'm tired of trying to make it work
* more docs
* possibly something more.
  • Loading branch information
yajo authored Oct 12, 2020
1 parent a06ca18 commit cda9327
Show file tree
Hide file tree
Showing 22 changed files with 1,277 additions and 850 deletions.
30 changes: 8 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ jobs:
- name: Enable msys binaries
if: ${{ runner.os == 'Windows' }}
run: |
echo "::add-path::C:\msys64\usr\bin"
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
rm C:\msys64\usr\bin\bash.exe
- run: git config --global user.name copier-ci
shell: bash
- run: git config --global user.email copier@copier
shell: bash
- run: git config --global core.autocrlf input
shell: bash
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand All @@ -58,8 +55,8 @@ jobs:
- name: generate cache key PY
shell: bash
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- uses: actions/[email protected]
with:
path: |
Expand All @@ -69,22 +66,11 @@ jobs:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
shell: bash
run: |
python -m pip install poetry poetry-dynamic-versioning poethepoet
poetry run python -m pip install pip -U
poetry install
- name: Run pre-commit
shell: bash
run: poe lint --color=always
# FIXME Make pre-commit pass reliably on Windows, and remove this
continue-on-error: ${{ runner.os == 'Windows' }}
- name: Run mypy
shell: bash
run: poe types
python -m pip install poetry
poetry install -vvv
- name: Run pytest
shell: bash
run: poe test -ra .
run: poetry run poe test -ra .

publish:
if: github.event_name == 'release'
Expand All @@ -98,8 +84,8 @@ jobs:
python-version: 3.8
- name: generate cache key PY
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- uses: actions/[email protected]
with:
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
- run: python -m pip install poetry poetry-dynamic-versioning
- name: generate cache key PY
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
- uses: actions/[email protected]
with:
path: |
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ repos:
# hooks running from local virtual environment
- repo: local
hooks:
- id: autoflake
name: autoflake
entry: poetry run autoflake
language: system
types: [python]
args: ["-i", "--remove-all-unused-imports", "--ignore-init-module-imports"]
- id: black
name: black
entry: poetry run black
Expand Down
2 changes: 2 additions & 0 deletions copier/config/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def make_config(
{k: v for k, v in questions_data.items() if k in data},
{},
data,
init_args["data_from_template_defaults"],
False,
init_args["envops"],
),
Expand All @@ -141,6 +142,7 @@ def make_config(
questions_data,
init_args["data_from_answers_file"],
init_args["data_from_init"],
init_args["data_from_template_defaults"],
not force,
init_args["envops"],
)
Expand Down
13 changes: 5 additions & 8 deletions copier/config/objects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Pydantic models, exceptions and default values."""

import datetime
from collections import ChainMap
from copy import deepcopy
Expand All @@ -8,7 +7,7 @@
from pathlib import Path
from typing import Any, ChainMap as t_ChainMap, Sequence, Tuple, Union

from pydantic import BaseModel, Extra, StrictBool, validator
from pydantic import BaseModel, Extra, Field, StrictBool, validator

from ..types import AnyByStrDict, OptStr, PathSeq, StrOrPathSeq, StrSeq

Expand All @@ -35,8 +34,6 @@
class UserMessageError(Exception):
"""Exit the program giving a message to the user."""

pass


class NoSrcPathError(UserMessageError):
pass
Expand Down Expand Up @@ -91,10 +88,10 @@ class ConfigData(BaseModel):
migrations: Sequence[Migrations] = ()
secret_questions: StrSeq = ()
answers_file: Path = Path(".copier-answers.yml")
data_from_init: AnyByStrDict = {}
data_from_asking_user: AnyByStrDict = {}
data_from_answers_file: AnyByStrDict = {}
data_from_template_defaults: AnyByStrDict = {}
data_from_init: AnyByStrDict = Field(default_factory=dict)
data_from_asking_user: AnyByStrDict = Field(default_factory=dict)
data_from_answers_file: AnyByStrDict = Field(default_factory=dict)
data_from_template_defaults: AnyByStrDict = Field(default_factory=dict)

# Private
_data_mutable: AnyByStrDict
Expand Down
Loading

0 comments on commit cda9327

Please sign in to comment.