From 4c8e27f096201a791a33f340fa6b54969a0b0220 Mon Sep 17 00:00:00 2001 From: Michiel Tukker Date: Thu, 30 May 2024 09:54:37 +0200 Subject: [PATCH 01/29] changed version list to list of strings Python 3.10 is interpreted as 3.1 due to issue in yaml interpretation: https://github.com/actions/runner/issues/1989 --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 24bf1b0..2f2157d 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.10, 3.11] + python-version: ['3.8', '3.10', '3.11'] name: Test cookiecutter template steps: From a10374e10d6d4e9e9b5a97a60b53a27f4d26a1d5 Mon Sep 17 00:00:00 2001 From: Michiel Tukker Date: Thu, 30 May 2024 09:54:37 +0200 Subject: [PATCH 02/29] changed version list to list of strings Python 3.10 is interpreted as 3.1 due to issue in yaml interpretation: https://github.com/actions/runner/issues/1989 --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 24bf1b0..2f2157d 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.10, 3.11] + python-version: ['3.8', '3.10', '3.11'] name: Test cookiecutter template steps: From 7258a65cc8ed41ad87192886f88253508d94c48a Mon Sep 17 00:00:00 2001 From: Michiel Tukker Date: Thu, 30 May 2024 10:07:56 +0200 Subject: [PATCH 03/29] Cookiecutter shouldn't prompt for user input --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 2f2157d..9b42f7a 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -22,7 +22,7 @@ jobs: - name: Run cookiecutter run: | pip install cookiecutter - cookiecutter $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA + cookiecutter --no-input $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA cd design_toolkit_application - name: flake8 Lint From b86bf04f9ce00308a31b5dc4cd9b452f4303e1d0 Mon Sep 17 00:00:00 2001 From: Michiel Tukker Date: Thu, 30 May 2024 13:08:38 +0200 Subject: [PATCH 04/29] Fixed template error in github action, causing template instatntiation to fail --- .../.github/workflows/publish_container_image.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml index 9191860..129e54e 100644 --- a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml +++ b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml @@ -13,19 +13,19 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - +{% raw %} - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io - username: {% raw %}${{ github.actor }}{% endraw %} - password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} - + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} +{% endraw %} - name: Build the container image run: | docker build . --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:${{github.ref_name}} docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest - docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:${{github.ref_name}} + docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} {%- else -%} {% endif %} From 9b6ff3e0d56d90c7979825871c424e1ce5bc6f08 Mon Sep 17 00:00:00 2001 From: Michiel Tukker Date: Thu, 30 May 2024 13:12:20 +0200 Subject: [PATCH 05/29] missed one --- .../.github/workflows/publish_container_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml index 129e54e..76a6d95 100644 --- a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml +++ b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml @@ -23,7 +23,7 @@ jobs: {% endraw %} - name: Build the container image run: | - docker build . --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:${{github.ref_name}} + docker build . --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} {%- else -%} From d587c251a630b2e05430e9740e8906591ad30da2 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Mon, 24 Jun 2024 17:11:10 +0200 Subject: [PATCH 06/29] Allow pytest suite to be empty. --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 9b42f7a..34f43f8 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -55,7 +55,7 @@ jobs: # Fail the workflow if no JUnit XML was found. # Default: true - fail-on-empty: true + fail-on-empty: false - name: Add mypy annotator uses: pr-annotators/mypy-pr-annotator@v1.0.0 From 13095b2343d5de9509e2abeb90e7832648775745 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Mon, 24 Jun 2024 17:13:54 +0200 Subject: [PATCH 07/29] Attempt to move .bat post hook to see if this fixes generation. --- hooks/post_gen_project.bat => post_gen_project.bat | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hooks/post_gen_project.bat => post_gen_project.bat (100%) diff --git a/hooks/post_gen_project.bat b/post_gen_project.bat similarity index 100% rename from hooks/post_gen_project.bat rename to post_gen_project.bat From cb7672f9be381b4a0a2ef8e3cee9fe0af09f680d Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 09:45:11 +0200 Subject: [PATCH 08/29] Remove spotty git-versioning config parameters. --- {{cookiecutter.repo_name}}/pyproject.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index ab2d272..4057b78 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -57,10 +57,6 @@ requires = [ [tool.setuptools-git-versioning] enabled = true -version_file = "VERSION" -count_commits_from_version_file = true -dev_template = "{tag}.dev{ccount}" -dirty_template = "{tag}.dev{ccount}" [tool.pytest.ini_options] addopts = "--cov={{cookiecutter.python_import_name}} --cov-report html --cov-report term-missing --cov-fail-under 80" From e3ee2c601f370fcec7674c217443ffd49db71ae6 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:00:55 +0200 Subject: [PATCH 09/29] Overwrite default python version with current version in github CI matrix prior to cookiecutter test. --- .github/workflows/run_template_checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 34f43f8..e877808 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -22,6 +22,7 @@ jobs: - name: Run cookiecutter run: | pip install cookiecutter + sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json cookiecutter --no-input $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA cd design_toolkit_application From fb59336eeb87ca9ddb2f3c294d8defabf15e1015 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:04:01 +0200 Subject: [PATCH 10/29] Some debug stuff. --- .github/workflows/run_template_checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index e877808..f191fac 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -23,6 +23,8 @@ jobs: run: | pip install cookiecutter sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json + ls -alh + cat cookiecutter.json cookiecutter --no-input $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA cd design_toolkit_application From ebfe2e32708b075d6b95545452e56fa1bf64cfff Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:26:52 +0200 Subject: [PATCH 11/29] Use checked out cookiecutter instead of cloning it from remote. --- .github/workflows/run_template_checks.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index f191fac..e83837d 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -23,9 +23,7 @@ jobs: run: | pip install cookiecutter sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json - ls -alh - cat cookiecutter.json - cookiecutter --no-input $GITHUB_SERVER_URL/$GITHUB_REPOSITORY -c $GITHUB_SHA + cookiecutter --no-input ./ cd design_toolkit_application - name: flake8 Lint From be160b0bebcb7d2ff149ce1e797f477519d652e9 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:29:24 +0200 Subject: [PATCH 12/29] Add some debug stuff. --- .github/workflows/run_template_checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index e83837d..fe1281a 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -24,6 +24,7 @@ jobs: pip install cookiecutter sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json cookiecutter --no-input ./ + ls -alh cd design_toolkit_application - name: flake8 Lint From 43b448580c33cf954f8ab208c21623feec95c5be Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:31:13 +0200 Subject: [PATCH 13/29] Fix dir name of cookiecutter template output. --- .github/workflows/run_template_checks.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index fe1281a..665b764 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -24,8 +24,7 @@ jobs: pip install cookiecutter sed -i 's/"python_version": "3\.[0-9]*"/"python_version": "${{ matrix.python-version }}"/gi' cookiecutter.json cookiecutter --no-input ./ - ls -alh - cd design_toolkit_application + cd design-toolkit-application - name: flake8 Lint uses: TrueBrain/actions-flake8@v2 From 1ead2068e5b5989bd6383178d36f6bf7ccf96bf6 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:46:29 +0200 Subject: [PATCH 14/29] Update template ci.yml with newest version. --- .../.github/workflows/ci.yml | 170 +++++++++++------- 1 file changed, 101 insertions(+), 69 deletions(-) diff --git a/{{cookiecutter.repo_name}}/.github/workflows/ci.yml b/{{cookiecutter.repo_name}}/.github/workflows/ci.yml index c5c16aa..b31de2b 100644 --- a/{{cookiecutter.repo_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.repo_name}}/.github/workflows/ci.yml @@ -3,110 +3,142 @@ name: Build-Test-Lint-etc (linux) on: [push] jobs: - - flake8-lint: + setup: runs-on: ubuntu-latest - name: Lint + strategy: + fail-fast: false + matrix: + python-version: ["{{cookiecutter.python_version}}"] + name: Setup steps: - - name: Check out source repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python environment + # {% raw %} + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: - python-version: {{cookiecutter.python_version}} - - name: flake8 Lint - uses: TrueBrain/actions-flake8@v2 + python-version: ${{ matrix.python-version }} + cache: 'pip' + - run: | + ./ci/linux/create_venv.sh + ./ci/linux/install_dependencies.sh + - name: 'Tar venv' + run: tar -cvf venv.tar ./.venv/ + - name: Save venv + uses: actions/upload-artifact@v4 with: - plugins: Flake8-pyproject==1.2.3 flake8-docstrings==1.7.0 flake8-quotes==3.3.2 flake8-bugbear==23.9.16 flake8-mock==0.4 flake8-tuple==0.4.1 - # only_warn: 1 #causes action to always be succesful, but still provide annotations + path: ./venv.tar + name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} + # {% endraw %} - test: + lint: + name: Lint runs-on: ubuntu-latest + needs: [ setup ] strategy: + fail-fast: false matrix: python-version: ["{{cookiecutter.python_version}}"] -# python-version: [3.8, 3.9, 3.10, 3.11] steps: - - uses: actions/checkout@v3 - - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v4 - with: - python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - cache: 'pip' - - run: | - ./ci/linux/create_venv.sh - ./ci/linux/install_dependencies.sh - - - name: run unit tests - run: | - ./ci/linux/test_unit.sh + # {% raw %} + - uses: actions/checkout@v3 + - name: Restore venv + uses: actions/download-artifact@v4 + with: + name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} + - name: Untar venv + run: tar -xvf venv.tar + - name: run unit tests + run: | + ./ci/linux/lint.sh + # {% endraw %} - - name: Surface failing tests - if: always() - uses: pmeier/pytest-results-action@main - with: - # A list of JUnit XML files, directories containing the former, and wildcard - # patterns to process. - # See @actions/glob for supported patterns. - path: test-results.xml + test: + name: Test + runs-on: ubuntu-latest + needs: [ setup ] + strategy: + fail-fast: false + matrix: + python-version: ["{{cookiecutter.python_version}}"] + steps: + # {% raw %} + - uses: actions/checkout@v3 + - name: Restore venv + uses: actions/download-artifact@v4 + with: + name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} + - name: Untar venv + run: tar -xvf venv.tar + - name: run unit tests + run: | + ./ci/linux/test_unit.sh + - name: Surface failing tests + if: always() + uses: pmeier/pytest-results-action@main + with: + # A list of JUnit XML files, directories containing the former, and wildcard + # patterns to process. + # See @actions/glob for supported patterns. + path: test-results.xml - # Add a summary of the results at the top of the report - # Default: true - summary: true + # Add a summary of the results at the top of the report + # Default: true + summary: true - # Select which results should be included in the report. - # Follows the same syntax as - # `pytest -r` - # Default: fEX - display-options: fEX + # Select which results should be included in the report. + # Follows the same syntax as + # `pytest -r` + # Default: fEX + display-options: fEX - # Fail the workflow if no JUnit XML was found. - # Default: true - fail-on-empty: true + # Fail the workflow if no JUnit XML was found. + # Default: true + fail-on-empty: true + # {% endraw %} typecheck: + name: Typecheck runs-on: ubuntu-latest + needs: [ setup ] strategy: + fail-fast: false matrix: python-version: ["{{cookiecutter.python_version}}"] -# python-version: [3.8, 3.9, 3.10, 3.11] steps: - - uses: actions/checkout@v3 - - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v4 - with: - python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - cache: 'pip' - - run: | - ./ci/linux/create_venv.sh - ./ci/linux/install_dependencies.sh - - - name: Add mypy annotator - uses: pr-annotators/mypy-pr-annotator@v1.0.0 - - - name: run typechecker - run: | - ./ci/linux/typecheck.sh + # {% raw %} + - uses: actions/checkout@v3 + - name: Restore venv + uses: actions/download-artifact@v4 + with: + name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} + - name: Untar venv + run: tar -xvf venv.tar + - name: Add mypy annotator + uses: pr-annotators/mypy-pr-annotator@v1.0.0 + - name: run typechecker + run: | + ./ci/linux/typecheck.sh + # {% endraw %} build: name: Build the python package runs-on: ubuntu-latest + needs: [ setup ] strategy: + fail-fast: false matrix: python-version: [ "{{cookiecutter.python_version}}" ] steps: + # {% raw %} - uses: actions/checkout@v3 - - name: Set up Python {% raw %}${{ matrix.python-version }}{% endraw %} - uses: actions/setup-python@v4 + - name: Restore venv + uses: actions/download-artifact@v4 with: - python-version: {% raw %}${{ matrix.python-version }}{% endraw %} - cache: 'pip' + name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} - run: | ./ci/linux/create_venv.sh ./ci/linux/install_dependencies.sh - - name: build run: | ./ci/linux/build_python_package.sh + # {% endraw %} From 208757ed680d31290ce8f1ae1c722eeac21dccae Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:51:02 +0200 Subject: [PATCH 15/29] Update ci.yaml. --- .github/workflows/run_template_checks.yml | 12 ++++++------ {{cookiecutter.repo_name}}/.github/workflows/ci.yml | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 665b764..ca209ca 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -26,10 +26,10 @@ jobs: cookiecutter --no-input ./ cd design-toolkit-application - - name: flake8 Lint - uses: TrueBrain/actions-flake8@v2 - with: - plugins: Flake8-pyproject==1.2.3 flake8-docstrings==1.7.0 flake8-quotes==3.3.2 flake8-bugbear==23.9.16 flake8-mock==0.4 flake8-tuple==0.4.1 + - name: Run lint + run: | + ls -alh + ./ci/linux/lint.sh - name: Run unit tests run: | @@ -42,7 +42,7 @@ jobs: # A list of JUnit XML files, directories containing the former, and wildcard # patterns to process. # See @actions/glob for supported patterns. - path: test-results.xml + path: ./design-toolkit-application/test-results.xml # Add a summary of the results at the top of the report # Default: true @@ -60,6 +60,6 @@ jobs: - name: Add mypy annotator uses: pr-annotators/mypy-pr-annotator@v1.0.0 - - name: run typechecker + - name: Run typechecker run: | ./ci/linux/typecheck.sh diff --git a/{{cookiecutter.repo_name}}/.github/workflows/ci.yml b/{{cookiecutter.repo_name}}/.github/workflows/ci.yml index b31de2b..afa63cf 100644 --- a/{{cookiecutter.repo_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.repo_name}}/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} - name: Untar venv run: tar -xvf venv.tar - - name: run unit tests + - name: Run lint run: | ./ci/linux/lint.sh # {% endraw %} @@ -69,7 +69,7 @@ jobs: name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} - name: Untar venv run: tar -xvf venv.tar - - name: run unit tests + - name: Run unit tests run: | ./ci/linux/test_unit.sh - name: Surface failing tests @@ -115,7 +115,7 @@ jobs: run: tar -xvf venv.tar - name: Add mypy annotator uses: pr-annotators/mypy-pr-annotator@v1.0.0 - - name: run typechecker + - name: Run typechecker run: | ./ci/linux/typecheck.sh # {% endraw %} @@ -135,10 +135,9 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}} - - run: | - ./ci/linux/create_venv.sh - ./ci/linux/install_dependencies.sh - - name: build + - name: Untar venv + run: tar -xvf venv.tar + - name: Build run: | ./ci/linux/build_python_package.sh # {% endraw %} From 252fe810cd6bdc8a4e01c34722f3f99eb7834bb3 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:52:33 +0200 Subject: [PATCH 16/29] cd to cookiecutter template output when running commands on cookiecutter template output in run_template_checks.yml --- .github/workflows/run_template_checks.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index ca209ca..7ce06e2 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -28,11 +28,12 @@ jobs: - name: Run lint run: | - ls -alh + cd design-toolkit-application ./ci/linux/lint.sh - name: Run unit tests run: | + cd design-toolkit-application ./ci/linux/test_unit.sh - name: Surface failing tests @@ -62,4 +63,5 @@ jobs: - name: Run typechecker run: | + cd design-toolkit-application ./ci/linux/typecheck.sh From 00be244dcab3a1935fbceb3ac6c1c505abbcf512 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 10:53:49 +0200 Subject: [PATCH 17/29] Fix lint errors by adding newlines to init and main files. --- .../src/{{cookiecutter.python_import_name}}/__init__.py | 2 +- .../src/{{cookiecutter.python_import_name}}/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__init__.py b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__init__.py index ad3c9ef..c608357 100644 --- a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__init__.py +++ b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__init__.py @@ -14,4 +14,4 @@ # along with this program. If not, see . """__init__.py file containing the defaults.""" -from {{cookiecutter.python_import_name}}.{{cookiecutter.python_import_name}} import start_app \ No newline at end of file +from {{cookiecutter.python_import_name}}.{{cookiecutter.python_import_name}} import start_app diff --git a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__main__.py b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__main__.py index 78c723b..7a5af6f 100644 --- a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__main__.py +++ b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/__main__.py @@ -16,4 +16,4 @@ """__main__.py file for testing/running application.""" from {{cookiecutter.python_import_name}} import start_app -start_app(loglevel="DEBUG", colors=True) \ No newline at end of file +start_app(loglevel="DEBUG", colors=True) From cb7300d52965f3c8893914c8f60f2bf7bea42f1f Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 11:01:34 +0200 Subject: [PATCH 18/29] Fix unit tests of template. --- {{cookiecutter.repo_name}}/unit_test/test_main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/{{cookiecutter.repo_name}}/unit_test/test_main.py b/{{cookiecutter.repo_name}}/unit_test/test_main.py index ad3a16a..5ccf867 100644 --- a/{{cookiecutter.repo_name}}/unit_test/test_main.py +++ b/{{cookiecutter.repo_name}}/unit_test/test_main.py @@ -33,7 +33,7 @@ def test__testable_function__is_correct(self) -> None: current_time = datetime(1970, 1, 1, 13, 00) # Act - result = simulator_worker.testable_function(current_time) + result = {{cookiecutter.python_import_name}}.testable_function(current_time) # Assert expected_result = datetime(1970, 1, 1, 14, 00) @@ -41,16 +41,16 @@ def test__testable_function__is_correct(self) -> None: def test_start_app_info(self) -> None: try: - simulator_worker.start_app(loglevel="INFO", colors=True) + {{cookiecutter.python_import_name}}.start_app(loglevel="INFO", colors=True) except Exception as e: - self.fail(f"simulator_worker.start_app() raised an exception: {e}") + self.fail(f"{{cookiecutter.python_import_name}}.start_app() raised an exception: {e}") def test_start_app_debug(self) -> None: try: - simulator_worker.start_app(loglevel="DEBUG", colors=False) + {{cookiecutter.python_import_name}}.start_app(loglevel="DEBUG", colors=False) except Exception as e: - self.fail(f"simulator_worker.start_app() raised an exception: {e}") + self.fail(f"{{cookiecutter.python_import_name}}.start_app() raised an exception: {e}") def test_start_app_wrong_logtype(self) -> None: with self.assertRaises(ValueError): - simulator_worker.start_app(loglevel="WRONG_LOG_TYPE", colors=False) + {{cookiecutter.python_import_name}}.start_app(loglevel="WRONG_LOG_TYPE", colors=False) From 6c84fc4d6e727ba72e6b66a09ce744cfcc1e88ac Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 11:03:33 +0200 Subject: [PATCH 19/29] Make type hinting in cookiecutter template python3.8 compatible. --- .../src/{{cookiecutter.python_import_name}}/app_logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py index 828a276..b9ea810 100644 --- a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py +++ b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py @@ -61,7 +61,7 @@ def parse(value: str) -> "LogLevel": return result -LOG_LEVEL: LogLevel | None = None +LOG_LEVEL: Optional[LogLevel] = None def setup_logging(log_level: LogLevel, colors: bool = True) -> None: From f7c07618e00127ab9f89919d549f94bb21dfc069 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 11:05:02 +0200 Subject: [PATCH 20/29] Add missing import for optional. --- .../src/{{cookiecutter.python_import_name}}/app_logging.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py index b9ea810..e4d9df9 100644 --- a/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py +++ b/{{cookiecutter.repo_name}}/src/{{cookiecutter.python_import_name}}/app_logging.py @@ -15,9 +15,10 @@ """Setup logging for this python application.""" +from enum import Enum import logging +from typing import Optional import sys -from enum import Enum import coloredlogs From c742407c9d41240d98c825c23a1317f277b73a18 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 25 Jun 2024 11:07:29 +0200 Subject: [PATCH 21/29] Fail unit tests if empty. --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 7ce06e2..ec3531f 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -57,7 +57,7 @@ jobs: # Fail the workflow if no JUnit XML was found. # Default: true - fail-on-empty: false + fail-on-empty: true - name: Add mypy annotator uses: pr-annotators/mypy-pr-annotator@v1.0.0 From a29f3e9d692fd496078aa3a04655c3e97550925a Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 11:50:58 +0100 Subject: [PATCH 22/29] Use github username when deploying container image to GHCR instead of dockerhub username. --- cookiecutter.json | 2 +- .../.github/workflows/publish_container_image.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookiecutter.json b/cookiecutter.json index 72d13ee..371d68d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,7 +6,7 @@ "python_import_name": "{{ cookiecutter.repo_name|replace('-', '') }}", "project_short_description": "A description on what this application within the Design Toolkit entails.", "publish_container": true, - "docker_username": "audrey", + "github_username": "project-omotes", "container_name": "design-toolkit-application", "python_version": "3.11", "_copy_without_render": [ diff --git a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml index 76a6d95..ef75b52 100644 --- a/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml +++ b/{{cookiecutter.repo_name}}/.github/workflows/publish_container_image.yml @@ -23,9 +23,9 @@ jobs: {% endraw %} - name: Build the container image run: | - docker build . --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} - docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:latest - docker push ghcr.io/{{ cookiecutter.docker_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} + docker build . --tag ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:latest --tag ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} + docker push ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:latest + docker push ghcr.io/{{ cookiecutter.github_username }}/{{ cookiecutter.container_name }}:{% raw %}${{github.ref_name}}{% endraw %} {%- else -%} {% endif %} From bb15e374d29f44213a92cb49a127913bd8c5c5f7 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:05:55 +0100 Subject: [PATCH 23/29] Add in improvements from other repos. --- .../ci/linux/_load_dot_env.sh | 5 +++ .../ci/linux/build_python_package.sh | 6 +++- .../ci/linux/install_dependencies.sh | 6 +++- {{cookiecutter.repo_name}}/ci/linux/lint.sh | 8 +++-- .../ci/linux/test_unit.sh | 6 +++- .../ci/linux/typecheck.sh | 6 +++- .../ci/linux/update_dependencies.sh | 8 +++-- {{cookiecutter.repo_name}}/pyproject.toml | 34 +++++++++++-------- 8 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 {{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh diff --git a/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh b/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh new file mode 100644 index 0000000..449595f --- /dev/null +++ b/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +set -a +source $1 +set +a diff --git a/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh b/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh index 5f4244f..0fb4d6c 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh @@ -1,4 +1,8 @@ #!/usr/bin/env sh -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + python -m build diff --git a/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh b/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh index 0447bed..f5afa3c 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh @@ -1,4 +1,8 @@ #!/usr/bin/env sh -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + pip-sync ./dev-requirements.txt ./requirements.txt diff --git a/{{cookiecutter.repo_name}}/ci/linux/lint.sh b/{{cookiecutter.repo_name}}/ci/linux/lint.sh index e5cd8ee..4ea291c 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/lint.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/lint.sh @@ -1,4 +1,8 @@ #!/usr/bin/env sh -. .venv/bin/activate -flake8 ./src/{{cookiecutter.python_import_name}} +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + +flake8 ./src/{{cookiecutter.python_import_name}} ./unit_test/ diff --git a/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh b/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh index b810a25..a0d9496 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh @@ -1,4 +1,8 @@ #!/usr/bin/env sh -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + PYTHONPATH='$PYTHONPATH:src/' pytest --junit-xml=test-results.xml unit_test/ diff --git a/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh b/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh index 5dfedef..01ff1a1 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh @@ -1,4 +1,8 @@ #!/usr/bin/env sh -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + python -m mypy ./src/{{cookiecutter.python_import_name}} ./unit_test/ diff --git a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh index cfb00aa..ea77045 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh @@ -1,5 +1,9 @@ #!/usr/bin/env sh -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi + pip-compile --output-file=requirements.txt pyproject.toml -pip-compile --extra=dev --output-file=dev-requirements.txt -c requirements.txt pyproject.toml +pip-compile --extra=dev -c requirements.txt --output-file=dev-requirements.txt pyproject.toml diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index bcf6b30..5d7f4ab 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -23,18 +23,19 @@ dependencies = ["coloredlogs~=15.0.1"] [project.optional-dependencies] dev = [ - "setuptools ~= 69.0.3", - "wheel ~= 0.40.0", + "setuptools ~= 75.6.0", + "wheel ~= 0.45.1", "setuptools-git-versioning < 2", - "black~=22.1.0", - "flake8==6.0.0", - "Flake8-pyproject==1.2.3", - "pytest ~=7.3.1", - "pytest-cov ~=4.0.0", - "bump2version==1.0.1", - "mypy ~= 1.5.1", - "isort==5.13.2", - "build ~= 1.0.3", + "black ~= 24.10.0", + "flake8 == 7.1.1", + "Flake8-pyproject == 1.2.3", + "flake8-docstrings ~= 1.7.0", + "flake8-quotes ~= 3.4.0", + "pytest ~= 8.3.4", + "pytest-cov ~= 6.0.0", + "mypy ~= 1.13.0", + "isort == 5.13.2", + "build ~= 1.2.2", ] [project.urls] @@ -49,13 +50,14 @@ changelog = "https://github.com/Nieuwe-Warmte-Nu/{{cookiecutter.repo_name}}/blob [build-system] build-backend = "setuptools.build_meta" requires = [ - "setuptools ~= 69.0.3", - "wheel ~= 0.40.0", - "setuptools-git-versioning<2", + "setuptools ~= 75.6.0", + "wheel ~= 0.45.1", + "setuptools-git-versioning < 2", ] [tool.setuptools-git-versioning] enabled = true +starting_version = "0.0.1" [tool.pytest.ini_options] addopts = "--cov={{cookiecutter.python_import_name}} --cov-report html --cov-report term-missing --cov-fail-under 80" @@ -72,8 +74,10 @@ ignore = [ 'E203', # Space before colon (not PEP-8 compliant, and conflicts with black) 'C408', # Suggestion to use dict() over {} 'W503', # Starting lines with operators. + 'D104', # Missing docstring in public package + 'D100' # Missing docstring in public module ] -per-file-ignores = ['__init__.py:F401', 'test_main.py:D100,D101,D102,D103'] +per-file-ignores = ['__init__.py:F401', 'test_*.py:D100,D101,D102,D103'] max-line-length = 100 count = true From 72ef07f82c6b98346ab2c522e5a4eabc6d767565 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:23:17 +0100 Subject: [PATCH 24/29] More improvements from other repos --- {{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh | 4 ++-- {{cookiecutter.repo_name}}/ci/win32/update_dependencies.cmd | 4 ++-- {{cookiecutter.repo_name}}/pyproject.toml | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh index ea77045..26ffec3 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh @@ -5,5 +5,5 @@ if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then . .venv/bin/activate fi -pip-compile --output-file=requirements.txt pyproject.toml -pip-compile --extra=dev -c requirements.txt --output-file=dev-requirements.txt pyproject.toml +pip-compile --upgrade --output-file=requirements.txt pyproject.toml +pip-compile --upgrade --extra=dev -c requirements.txt --output-file=dev-requirements.txt pyproject.toml diff --git a/{{cookiecutter.repo_name}}/ci/win32/update_dependencies.cmd b/{{cookiecutter.repo_name}}/ci/win32/update_dependencies.cmd index 061ee6d..f0f55a2 100644 --- a/{{cookiecutter.repo_name}}/ci/win32/update_dependencies.cmd +++ b/{{cookiecutter.repo_name}}/ci/win32/update_dependencies.cmd @@ -1,6 +1,6 @@ pushd . cd /D "%~dp0" -pip-compile --output-file=..\..\requirements.txt ..\..\pyproject.toml -pip-compile --extra=dev --output-file=..\..\dev-requirements.txt -c ..\..\requirements.txt ..\..\pyproject.toml +pip-compile --upgrade --output-file=..\..\requirements.txt ..\..\pyproject.toml +pip-compile --upgrade --extra=dev --output-file=..\..\dev-requirements.txt -c ..\..\requirements.txt ..\..\pyproject.toml popd \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index 5d7f4ab..29c569a 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -28,9 +28,12 @@ dev = [ "setuptools-git-versioning < 2", "black ~= 24.10.0", "flake8 == 7.1.1", - "Flake8-pyproject == 1.2.3", + "flake8-pyproject ~= 1.2.3", "flake8-docstrings ~= 1.7.0", "flake8-quotes ~= 3.4.0", + "flake8-bugbear ~= 24.10.31", + "flake8-mock ~= 0.4", + "flake8-tuple ~= 0.4.1", "pytest ~= 8.3.4", "pytest-cov ~= 6.0.0", "mypy ~= 1.13.0", From 8941d019aeab39c3ac1a21af560a232125f54445 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:37:38 +0100 Subject: [PATCH 25/29] Temp ls on test unit results. --- .github/workflows/run_template_checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index ec3531f..369d27b 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -35,6 +35,7 @@ jobs: run: | cd design-toolkit-application ./ci/linux/test_unit.sh + ls -alh - name: Surface failing tests if: always() From 511c79ee5965908dd87e5cc5a3f580ac1db28b29 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:40:00 +0100 Subject: [PATCH 26/29] Switch over to bash for ci scripts instead of sh. --- .github/workflows/run_template_checks.yml | 1 - {{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/build_python_package.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/create_venv.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/lint.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/test_unit.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/typecheck.sh | 2 +- {{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 369d27b..ec3531f 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -35,7 +35,6 @@ jobs: run: | cd design-toolkit-application ./ci/linux/test_unit.sh - ls -alh - name: Surface failing tests if: always() diff --git a/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh b/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh index 449595f..434c067 100644 --- a/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/_load_dot_env.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -a source $1 diff --git a/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh b/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh index 0fb4d6c..0d2d2af 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/build_python_package.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." diff --git a/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh b/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh index 4ab293e..36ccca3 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash python{{cookiecutter.python_version}} -m venv ./.venv . .venv/bin/activate diff --git a/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh b/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh index f5afa3c..e00b897 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/install_dependencies.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." diff --git a/{{cookiecutter.repo_name}}/ci/linux/lint.sh b/{{cookiecutter.repo_name}}/ci/linux/lint.sh index 4ea291c..776e064 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/lint.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/lint.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." diff --git a/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh b/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh index a0d9496..bff0c15 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/test_unit.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." diff --git a/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh b/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh index 01ff1a1..62d476f 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/typecheck.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." diff --git a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh index 26ffec3..fea6566 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/update_dependencies.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then echo "Activating .venv first." From 2acadf40826a9d3dfa185c89cdd509278728fd9d Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:49:54 +0100 Subject: [PATCH 27/29] Drop python 3.8 in favor of 3.9 and turn off fail fast on github actions. --- .github/workflows/run_template_checks.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index ec3531f..67d3b40 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -7,7 +7,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.10', '3.11'] + fail-fast: false + python-version: ['3.9', '3.10', '3.11'] name: Test cookiecutter template steps: From 8c551f2492ad8bea86a4b32518b57d41eee51447 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 10 Dec 2024 15:51:02 +0100 Subject: [PATCH 28/29] Fix fail fast location. --- .github/workflows/run_template_checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_template_checks.yml b/.github/workflows/run_template_checks.yml index 67d3b40..da4e9e6 100644 --- a/.github/workflows/run_template_checks.yml +++ b/.github/workflows/run_template_checks.yml @@ -6,8 +6,8 @@ jobs: build-lint-test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - fail-fast: false python-version: ['3.9', '3.10', '3.11'] name: Test cookiecutter template From e276fb369ff486485526a04652bdc85e54a45b13 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Wed, 11 Dec 2024 11:35:36 +0100 Subject: [PATCH 29/29] Update setuptools-git-versioning, add py.typed to package data and only activate venv on linux when creating a venv. --- {{cookiecutter.repo_name}}/ci/linux/create_venv.sh | 5 ++++- {{cookiecutter.repo_name}}/pyproject.toml | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh b/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh index 36ccca3..ca7dda1 100755 --- a/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh +++ b/{{cookiecutter.repo_name}}/ci/linux/create_venv.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash python{{cookiecutter.python_version}} -m venv ./.venv -. .venv/bin/activate +if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then + echo "Activating .venv first." + . .venv/bin/activate +fi pip3 install pip-tools diff --git a/{{cookiecutter.repo_name}}/pyproject.toml b/{{cookiecutter.repo_name}}/pyproject.toml index 29c569a..b08852c 100644 --- a/{{cookiecutter.repo_name}}/pyproject.toml +++ b/{{cookiecutter.repo_name}}/pyproject.toml @@ -25,7 +25,7 @@ dependencies = ["coloredlogs~=15.0.1"] dev = [ "setuptools ~= 75.6.0", "wheel ~= 0.45.1", - "setuptools-git-versioning < 2", + "setuptools-git-versioning >= 2.0, < 3", "black ~= 24.10.0", "flake8 == 7.1.1", "flake8-pyproject ~= 1.2.3", @@ -55,9 +55,12 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools ~= 75.6.0", "wheel ~= 0.45.1", - "setuptools-git-versioning < 2", + "setuptools-git-versioning >= 2.0, < 3", ] +[tool.setuptools.package-data] +"{{cookiecutter.python_import_name}}" = ["py.typed"] + [tool.setuptools-git-versioning] enabled = true starting_version = "0.0.1"