From bd1a5522f324b77984873f517364c8ce59d2e44b Mon Sep 17 00:00:00 2001 From: drewoldag <47493171+drewoldag@users.noreply.github.com> Date: Fri, 10 Feb 2023 14:50:28 -0800 Subject: [PATCH] Fix CI issues (#46) * Fixed issues with codecov reporting, copier answer validation. Updated github action versions. * Keeping the raw/endraw tags so that copier does not try to replace {{ matrix.python-version }}. --- .github/workflows/ci.yml | 4 ++-- copier.yml | 8 ++++++++ .../.github/workflows/python-package.yml.jinja | 8 +++++--- python-project-template/.pre-commit-config.yaml | 2 +- python-project-template/pyproject.toml.jinja | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8362e2a1..3b645204 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,9 +25,9 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install Python dependencies diff --git a/copier.yml b/copier.yml index 92ac3069..3511d3d3 100644 --- a/copier.yml +++ b/copier.yml @@ -2,11 +2,19 @@ project_name: type: str help: What is the name of your project? default: example_project + validator: >- + {% if not (project_name | regex_search('^[a-zA-Z][a-zA-Z0-9\_]+$')) %} + project_name must start with a letter, followed one or more letters, digits or underscores all lowercase. + {% endif %} module_name: type: str help: What is your python module name? If left blank, will default to project_name. default: "{{project_name}}" + validator: >- + {% if not (module_name | regex_search('^[a-zA-Z][a-zA-Z0-9\_]+$')) %} + module_name must start with a letter, followed one or more letters, digits or underscores all lowercase. + {% endif %} author_name: type: str diff --git a/python-project-template/.github/workflows/python-package.yml.jinja b/python-project-template/.github/workflows/python-package.yml.jinja index 2ab100b1..1f2fdc8e 100644 --- a/python-project-template/.github/workflows/python-package.yml.jinja +++ b/python-project-template/.github/workflows/python-package.yml.jinja @@ -18,9 +18,9 @@ jobs: python-version: ['3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - name: Install dependencies @@ -32,7 +32,9 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run unit tests with pytest run: | - python -m pytest --cov=. --cov-report=xml + python -m pytest tests --cov={{module_name}} --cov-report=xml + - name: Upload coverage report to codecov + uses: codecov/codecov-action@v3 - name: Analyze code with pylint run: | pylint -rn -sn --recursive=y ./src \ No newline at end of file diff --git a/python-project-template/.pre-commit-config.yaml b/python-project-template/.pre-commit-config.yaml index 7f8a8ce9..2d78ba75 100644 --- a/python-project-template/.pre-commit-config.yaml +++ b/python-project-template/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: pytest-check name: pytest-check description: Run unit tests with pytest. - entry: pytest --cov=. --cov-report=html + entry: pytest --cov=./src --cov-report=html language: system pass_filenames: false always_run: true diff --git a/python-project-template/pyproject.toml.jinja b/python-project-template/pyproject.toml.jinja index c7741162..7a6a1f1c 100644 --- a/python-project-template/pyproject.toml.jinja +++ b/python-project-template/pyproject.toml.jinja @@ -40,3 +40,4 @@ build-backend = "setuptools.build_meta" disable = """ missing-module-docstring, """ +ignore-patterns = "^_.*" # Ignore files that start with an underscore, i.e. _version.py