From db5d1b7dd3d73e4c7dd2193493fcac2e56850cfa Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Fri, 11 Aug 2023 17:00:15 +0800 Subject: [PATCH] Better consistency check. (#87) --- .github/workflows/ci.yml | 12 ++++++++++-- .github/workflows/ci.yml.jinja | 12 ++++++++++-- src/{{ module_name }}/settings.py.jinja | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b53ded7f..d228dcdc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,14 +45,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Git + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: cache: pip python-version: ${{ matrix.python-version }} - run: env | sort - - run: pip install copier - - run: copier copy -r HEAD -f . . + - name: Install copier for template rendering + run: python -m pip install --user copier + - name: Generate the project with the default value + run: | + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | diff --git a/.github/workflows/ci.yml.jinja b/.github/workflows/ci.yml.jinja index 1eae4abd..d5fb1735 100644 --- a/.github/workflows/ci.yml.jinja +++ b/.github/workflows/ci.yml.jinja @@ -63,14 +63,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Git + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com - name: Set up Python {{ '${{ matrix.python-version }}' }} uses: actions/setup-python@v4 with: cache: pip python-version: {{ '${{ matrix.python-version }}' }} - run: env | sort - - run: pip install copier - - run: copier copy -r HEAD -f . . + - name: Install copier for template rendering + run: python -m pip install --user copier + - name: Generate the project with the default value + run: | + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | diff --git a/src/{{ module_name }}/settings.py.jinja b/src/{{ module_name }}/settings.py.jinja index e64fade3..fbccfc79 100644 --- a/src/{{ module_name }}/settings.py.jinja +++ b/src/{{ module_name }}/settings.py.jinja @@ -18,14 +18,15 @@ class GlobalSettings(BaseSettings): class Settings(BaseSettings): """Project specific settings.""" - {%- if version_lt(minimal_python_version, "3.10") | bool %} + # NOTE(huxuan): Pydantic cannot leverage future annotations at runtime prior to # Python 3.10, so `from __future__ import annotations` cannot be used here, and the # lint error need to be ignored unless the minimal Python version >= 3.10. # Reference: https://github.com/pydantic/pydantic/issues/3300#issuecomment-1034007897 logging_level: Optional[str] = getLevelName(logging.INFO) # noqa: FA100 {%- else %} + logging_level: str | None = getLevelName(logging.INFO) {%- endif %} """Default logging level for the project."""