diff --git a/.copier-answers.yml b/.copier-answers.yml index 78644df7..b416f8e0 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.0.9 +_commit: v0.0.13 _src_path: gh:LabAutomationAndScreening/copier-base-template.git description: Copier template for creating Python libraries and executables python_ci_versions: @@ -9,6 +9,7 @@ python_version: 3.12.7 repo_name: copier-python-package-template repo_org_name: LabAutomationAndScreening ssh_port_number: 55874 +template_uses_javascript: false template_uses_pulumi: false template_uses_python: true diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 303660e5..e15a1e26 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,7 @@ "features": { "ghcr.io/devcontainers/features/aws-cli:1": { // view latest version https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst - "version": "2.19.3" + "version": "2.24.24" }, "ghcr.io/devcontainers/features/python:1": { // https://github.com/devcontainers/features/tree/main/src/python @@ -31,6 +31,8 @@ "ms-vscode-remote.remote-containers@0.383.0", "charliermarsh.ruff@2024.54.0", + + // Misc file formats "bierner.markdown-mermaid@1.25.0", "samuelcolvin.jinjahtml@0.20.0", diff --git a/.devcontainer/install-ci-tooling.sh b/.devcontainer/install-ci-tooling.sh index f0c4f679..e2cf24db 100644 --- a/.devcontainer/install-ci-tooling.sh +++ b/.devcontainer/install-ci-tooling.sh @@ -2,6 +2,8 @@ # can pass in the full major.minor.patch version of python as an optional argument set -ex + + curl -LsSf https://astral.sh/uv/0.6.6/install.sh | sh uv --version # TODO: add uv autocompletion to the shell https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion diff --git a/.github/actions/install_deps_uv/action.yml b/.github/actions/install_deps_uv/action.yml index 017b8d05..dc7898e9 100644 --- a/.github/actions/install_deps_uv/action.yml +++ b/.github/actions/install_deps_uv/action.yml @@ -56,7 +56,7 @@ runs: - name: OIDC Auth for CodeArtifact if: ${{ inputs.code-artifact-auth-role-name != 'no-code-artifact' }} - uses: aws-actions/configure-aws-credentials@v4.0.2 + uses: aws-actions/configure-aws-credentials@v4.1.0 with: role-to-assume: arn:aws:iam::${{ inputs.code-artifact-auth-role-account-id }}:role/${{ inputs.code-artifact-auth-role-name }} aws-region: ${{ inputs.code-artifact-auth-region }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c97f0fc8..37910f4f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -29,6 +29,8 @@ jobs: - name: Checkout code uses: actions/checkout@v4.2.2 + + - name: Install latest versions of python packages uses: ./.github/actions/install_deps_uv with: @@ -42,7 +44,7 @@ jobs: timeout-minutes: 30 # this is the amount of time this action will wait to attempt to acquire the mutex lock before failing, e.g. if other jobs are queued up in front of it - name: Cache Pre-commit hooks - uses: actions/cache@v4.2.0 + uses: actions/cache@v4.2.2 env: cache-name: cache-pre-commit-hooks with: @@ -130,7 +132,7 @@ jobs: timeout-minutes: 30 # this is the amount of time this action will wait to attempt to acquire the mutex lock before failing, e.g. if other jobs are queued up in front of it - name: Cache Pre-commit hooks - uses: actions/cache@v4.2.0 + uses: actions/cache@v4.2.2 env: cache-name: cache-pre-commit-hooks with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d66717e9..54e0475e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,190 +2,206 @@ minimum_pre_commit_version: 4.0.1 # run `pre-commit autoupdate --freeze` to update all hooks default_install_hook_types: [pre-commit, post-checkout] repos: + # Git-related + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 38980559e3a605691d6579f96222c30778e5a69e # frozen: 3.0.0 + hooks: + - id: git-dirty -# Git-related -- repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 38980559e3a605691d6579f96222c30778e5a69e # frozen: 3.0.0 - hooks: - - id: git-dirty - -# package management -- repo: local - hooks: - - id: uv-check - name: check pyproject.toml for valid uv config - entry: bash -c 'uv lock --check' - language: system - pass_filenames: false - verbose: true - files: '^pyproject.toml$|^uv.lock$' - - - id: sync-dependencies-on-commit - name: ensure python dependencies are up to date during commits - stages: [pre-commit] - # When the install does change things, it exits 0, so needed to check for the phrase 'operations' in stdout in order to cause things pre-commit command to fail - entry: python -c "import subprocess,sys; results=subprocess.run(['uv', 'sync', '--frozen'],timeout=360,capture_output=True); print ('stdout- ' + results.stdout.decode('utf-8', 'strict')); print ('stderr- ' + results.stderr.decode('utf-8', 'strict')); sys.exit(int(results.returncode or int('Installed' in results.stdout.decode('utf-8', 'strict'))));" - # don't pass filenames else the command line sees them twice - pass_filenames: false - language: system - files: 'uv.lock$' - verbose: true - - - id: sync-dependencies-post-checkout - name: ensure python dependencies are up to date during checkouts - stages: [post-checkout] - entry: bash -c 'uv sync --frozen' - pass_filenames: false - language: system - always_run: true - verbose: true - - -# Reformatting (should generally come before any file format or other checks, because reformatting can change things) -- repo: https://github.com/crate-ci/typos - rev: 2300ad1b6b5c37da54bcafb1a06211196503eac9 # frozen: v1 + # package management + - repo: local + hooks: + - id: uv-check + name: check pyproject.toml for valid uv config + entry: bash -c 'uv lock --check' + language: system + pass_filenames: false + verbose: true + files: "^pyproject.toml$|^uv.lock$" + + - id: sync-dependencies-on-commit + name: ensure python dependencies are up to date during commits + stages: + [pre-commit] + # When the install does change things, it exits 0, so needed to check for the phrase 'operations' in stdout in order to cause things pre-commit command to fail + entry: python -c "import subprocess,sys; results=subprocess.run(['uv', 'sync', '--frozen'],timeout=360,capture_output=True); print ('stdout- ' + results.stdout.decode('utf-8', 'strict')); print ('stderr- ' + results.stderr.decode('utf-8', 'strict')); sys.exit(int(results.returncode or int('Installed' in results.stdout.decode('utf-8', 'strict'))));" + # don't pass filenames else the command line sees them twice + pass_filenames: false + language: system + files: "uv.lock$" + verbose: true + + - id: sync-dependencies-post-checkout + name: ensure python dependencies are up to date during checkouts + stages: [post-checkout] + entry: bash -c 'uv sync --frozen' + pass_filenames: false + language: system + always_run: true + verbose: true + + # Reformatting (should generally come before any file format or other checks, because reformatting can change things) + - repo: https://github.com/crate-ci/typos + rev: 2300ad1b6b5c37da54bcafb1a06211196503eac9 # frozen: v1 hooks: - id: typos -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer # the XML formatter hook doesn't leave a blank line at the end, so excluding XML files from this hook to avoid conflicts - exclude: | # the extra trailing newline in the pull request template makes it easier to click there in the github console. The CLI that programmatically generates devcontainer-lock.json always ends the file incompatible with this hook. - (?x)^( - .github/pull_request_template.md| - template/.github/pull_request_template.md| - template/.copier-answers.yml.jinja-base| - template/template/.copier-answers.yml.jinja| - template/.copier-answers.yml.jinja| - .devcontainer/devcontainer-lock.json| - .copier-answers.yml| - .*\.xml| - )$ + exclude: + | # the extra trailing newline in the pull request template makes it easier to click there in the github console. The CLI that programmatically generates devcontainer-lock.json always ends the file incompatible with this hook. + (?x)^( + .github/pull_request_template.md| + template/.github/pull_request_template.md| + template/.copier-answers.yml.jinja-base| + template/template/.copier-answers.yml.jinja| + template/.copier-answers.yml.jinja| + .devcontainer/devcontainer-lock.json| + .copier-answers.yml| + .*\.xml| + )$ - id: pretty-format-json exclude: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ args: [--autofix, --no-sort-keys] -- repo: https://github.com/myint/docformatter + - repo: https://github.com/pre-commit/mirrors-prettier # TODO: switch to a different approach...this was archived in 2024 + rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8 + hooks: + - id: prettier + # TODO: get template YAML and MD files more in line with prettier expectations so we can start using prettier on those too + exclude: | + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + .*.yaml| + .*.yml| + .*.md| + )$ + + - repo: https://github.com/myint/docformatter # black seems to be working on formatting docstrings, but use this for now - rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 # tip of main that is compatible with pre-commit v4 + rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 # tip of main that is compatible with pre-commit v4 hooks: - id: docformatter exclude: (tests*)|(exceptions\.py)|(warnings\.py) args: - - --in-place - - --wrap-summaries=150 - - --wrap-descriptions=150 + - --in-place + - --wrap-summaries=150 + - --wrap-descriptions=150 -- repo: https://github.com/pamoller/xmlformatter - rev: 47ae0fb9cf2a515f8a2666050fac66fd719ae530 # frozen: v0.2.8 + - repo: https://github.com/pamoller/xmlformatter + rev: 47ae0fb9cf2a515f8a2666050fac66fd719ae530 # frozen: v0.2.8 hooks: - id: xml-formatter exclude: | - (?x)^( - .*/__snapshots__/.*| - )$ - + (?x)^( + .*/__snapshots__/.*| + )$ -# Invalid File Checks -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + # Invalid File Checks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - - id: check-added-large-files - args: ['--maxkb=123'] + - id: check-added-large-files + args: ["--maxkb=123"] exclude: (uv.lock)|(pnpm-lock.yaml) - - id: check-json + - id: check-json # exclude JSON5 or JSONC files with comments - exclude: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ - - id: check-yaml + exclude: | + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ + - id: check-yaml exclude: .copier-answers.yml # This is an autogenerated YAML file by Copier that throws 'found unhashable key' errors - - id: check-xml - - id: check-merge-conflict - - id: check-case-conflict + - id: check-xml + - id: check-merge-conflict + - id: check-case-conflict -- repo: https://github.com/maresb/check-json5 + - repo: https://github.com/maresb/check-json5 rev: 893a2b5a0a27c3540bd8fcafe2968ccc05237179 # 1.0 hooks: - - id: check-json5 + - id: check-json5 files: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ - -- repo: local + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ + + - repo: local hooks: - - id: forbidden-files + - id: forbidden-files name: forbidden files entry: found copier update rejection files; review them and remove them language: fail files: "\\.rej$" -# Safety/Security Issues -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + # Safety/Security Issues + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - - id: detect-private-key + - id: detect-private-key -# Linting + # Linting -- repo: https://github.com/Lucas-C/pre-commit-hooks-markup + - repo: https://github.com/Lucas-C/pre-commit-hooks-markup rev: 501f3d60cee13c712492103343bc23efdc7b3d1f #v1.0.1 hooks: - - id: rst-linter + - id: rst-linter # this hook fails on Sphinx documentation https://github.com/Lucas-C/pre-commit-hooks-markup/issues/13 exclude: docs/.*\.rst$ -- repo: https://github.com/hadolint/hadolint - rev: c3dc18df7a501f02a560a2cc7ba3c69a85ca01d3 # frozen: v2.13.1-beta + - repo: https://github.com/hadolint/hadolint + rev: c3dc18df7a501f02a560a2cc7ba3c69a85ca01d3 # frozen: v2.13.1-beta hooks: - - id: hadolint-docker + - id: hadolint-docker name: Lint Dockerfiles description: Runs hadolint to lint Dockerfiles -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: 41d2daf392fbf43341a77f24a9c6481a4b66af98 # frozen: v0.9.10 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 99abe27a5a16f301d9e0a3828181399dfbf54ebd # frozen: v0.11.0 hooks: - - id: ruff + - id: ruff name: ruff-src - args: [ --fix, --config=./ruff.toml ] + args: [--fix, --config=./ruff.toml] files: src/.+\.py$ - - id: ruff + - id: ruff name: ruff-tests - args: [ --fix, --config=./ruff-test.toml ] + args: [--fix, --config=./ruff-test.toml] files: tests?/.+\.py$ - - id: ruff-format + - id: ruff-format -- repo: https://github.com/pylint-dev/pylint - rev: aaab3ccb541532d2bcdf0410ab93ff4fafc266f5 # frozen: v3.3.5 + - repo: https://github.com/pylint-dev/pylint + rev: aaab3ccb541532d2bcdf0410ab93ff4fafc266f5 # frozen: v3.3.5 hooks: - - id: pylint + - id: pylint name: pylint args: - - --rcfile=./pylintrc.toml + - --rcfile=./pylintrc.toml verbose: true -- repo: local + - repo: local hooks: - - id: pyright + - id: pyright name: pyright entry: bash -c "uv run pyright" files: '.+\.py$' diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..d7dc1d46 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 120, + "singleQuote": false, + "trailingComma": "all", + "semi": true, + "tabWidth": 2, + "useTabs": false, + "arrowParens": "always", + "bracketSpacing": true, + "quoteProps": "as-needed", + "proseWrap": "preserve" +} diff --git a/copier.yml b/copier.yml index ec7c606a..29ca6934 100644 --- a/copier.yml +++ b/copier.yml @@ -21,6 +21,7 @@ use_windows_in_ci: help: Should CI in the instantiated template also use Windows runners? default: no + python_version: type: str help: What version of Python is used for development? diff --git a/extensions/context.py b/extensions/context.py index 219c572f..3300d403 100644 --- a/extensions/context.py +++ b/extensions/context.py @@ -11,6 +11,7 @@ class ContextUpdater(ContextHook): @override def hook(self, context: dict[Any, Any]) -> dict[Any, Any]: context["uv_version"] = "0.6.6" + context["pnpm_version"] = "10.6.3" context["pre_commit_version"] = "4.1.0" context["pyright_version"] = "1.1.396" context["pytest_version"] = "8.3.4" @@ -19,22 +20,26 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]: context["copier_version"] = "9.5.0" context["copier_templates_extension_version"] = "0.3.0" context["sphinx_version"] = "8.1.3" - context["pulumi_version"] = "3.155.0" - context["pulumi_aws_version"] = "6.67.0" - context["pulumi_aws_native_version"] = "1.25.0" - context["pulumi_command_version"] = "1.0.1" + context["pulumi_version"] = "3.156.0" + context["pulumi_aws_version"] = "6.72.0" + context["pulumi_aws_native_version"] = "1.26.0" + context["pulumi_command_version"] = "1.0.2" context["pulumi_github"] = "" context["boto3_version"] = "1.37.11" - context["ephemeral_pulumi_deploy_version"] = "0.0.2" + context["ephemeral_pulumi_deploy_version"] = "0.0.4" context["pydantic_version"] = "2.10.6" context["pyinstaller_version"] = "6.12.0" context["setuptools_version"] = "76.0.0" + context["strawberry_graphql_version"] = "0.262.5" + context["fastapi_version"] = "0.115.11" + context["uvicorn_version"] = "0.34.0" context["gha_checkout"] = "v4.2.2" context["gha_setup_python"] = "v5.4.0" - context["gha_cache"] = "v4.2.0" - context["gha_upload_artifact"] = "v4.4.3" - context["gha_configure_aws_credentials"] = "v4.0.2" + context["gha_cache"] = "v4.2.2" + context["gha_upload_artifact"] = "v4.6.1" + context["gha_configure_aws_credentials"] = "v4.1.0" + context["gha_setup_node"] = "v4.3.0" context["gha_mutex"] = "1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10" context["gha_linux_runner"] = "ubuntu-24.04" context["gha_windows_runner"] = "windows-2022" @@ -42,4 +47,8 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]: context["py311_version"] = "" context["py312_version"] = "3.12.7" context["py313_version"] = "3.13.2" + + # Kludge to be able to help symlinked jinja files in the child and grandchild templates + context["template_uses_vuejs"] = False + context["template_uses_javascript"] = False return context diff --git a/template/.devcontainer/devcontainer.json.jinja b/template/.devcontainer/devcontainer.json.jinja index 8b3d0200..69b3add2 100644 --- a/template/.devcontainer/devcontainer.json.jinja +++ b/template/.devcontainer/devcontainer.json.jinja @@ -5,7 +5,7 @@ "features": { "ghcr.io/devcontainers/features/aws-cli:1": { // view latest version https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst - "version": "2.19.3" + "version": "2.24.24" }, "ghcr.io/devcontainers/features/python:1": { // https://github.com/devcontainers/features/tree/main/src/python @@ -13,7 +13,13 @@ {% endraw %}{% if is_frozen_executable %}{% raw %} "enableShared": true,{% endraw %}{% endif %}{% raw %} "installTools": false, "optimize": true + }{% endraw %}{% if is_child_of_copier_base_template is not defined and template_uses_javascript is defined and template_uses_javascript is sameas(true) %}{% raw %}, + "ghcr.io/devcontainers/features/node:1.6.1": { + // https://github.com/devcontainers/features/tree/main/src/node + "version": "{% endraw %}{{ node_version }}{% raw %}", + "pnpmVersion": "{% endraw %}{{ pnpm_version }}{% raw %}" } +{% endraw %}{% endif %}{% raw %} }, "customizations": { "vscode": { @@ -32,6 +38,11 @@ "ms-vscode-remote.remote-containers@0.383.0", "charliermarsh.ruff@2024.54.0", +{% endraw %}{% if is_child_of_copier_base_template is not defined and template_uses_vuejs is defined and template_uses_vuejs is sameas(true) %}{% raw %} + // VueJS + "vue.volar@2.2.8", +{% endraw %}{% endif %}{% raw %} + // Misc file formats "bierner.markdown-mermaid@1.25.0", "samuelcolvin.jinjahtml@0.20.0", diff --git a/template/.devcontainer/install-ci-tooling.sh.jinja b/template/.devcontainer/install-ci-tooling.sh.jinja index 26259a7a..2b6a7286 100644 --- a/template/.devcontainer/install-ci-tooling.sh.jinja +++ b/template/.devcontainer/install-ci-tooling.sh.jinja @@ -2,6 +2,11 @@ # can pass in the full major.minor.patch version of python as an optional argument set -ex +{% endraw %}{% if template_uses_javascript is defined and template_uses_javascript is sameas(true) %}{% raw %} +npm -v +npm install -g pnpm@{% endraw %}{{ pnpm_version }}{% raw %} +pnpm -v{% endraw %}{% endif %}{% raw %} + curl -LsSf https://astral.sh/uv/{% endraw %}{{ uv_version }}{% raw %}/install.sh | sh uv --version # TODO: add uv autocompletion to the shell https://docs.astral.sh/uv/getting-started/installation/#shell-autocompletion diff --git a/template/.github/actions/install_deps_uv/action.yml b/template/.github/actions/install_deps_uv/action.yml index 017b8d05..dc7898e9 100644 --- a/template/.github/actions/install_deps_uv/action.yml +++ b/template/.github/actions/install_deps_uv/action.yml @@ -56,7 +56,7 @@ runs: - name: OIDC Auth for CodeArtifact if: ${{ inputs.code-artifact-auth-role-name != 'no-code-artifact' }} - uses: aws-actions/configure-aws-credentials@v4.0.2 + uses: aws-actions/configure-aws-credentials@v4.1.0 with: role-to-assume: arn:aws:iam::${{ inputs.code-artifact-auth-role-account-id }}:role/${{ inputs.code-artifact-auth-role-name }} aws-region: ${{ inputs.code-artifact-auth-region }} diff --git a/template/.pre-commit-config.yaml b/template/.pre-commit-config.yaml index d66717e9..54e0475e 100644 --- a/template/.pre-commit-config.yaml +++ b/template/.pre-commit-config.yaml @@ -2,190 +2,206 @@ minimum_pre_commit_version: 4.0.1 # run `pre-commit autoupdate --freeze` to update all hooks default_install_hook_types: [pre-commit, post-checkout] repos: + # Git-related + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 38980559e3a605691d6579f96222c30778e5a69e # frozen: 3.0.0 + hooks: + - id: git-dirty -# Git-related -- repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 38980559e3a605691d6579f96222c30778e5a69e # frozen: 3.0.0 - hooks: - - id: git-dirty - -# package management -- repo: local - hooks: - - id: uv-check - name: check pyproject.toml for valid uv config - entry: bash -c 'uv lock --check' - language: system - pass_filenames: false - verbose: true - files: '^pyproject.toml$|^uv.lock$' - - - id: sync-dependencies-on-commit - name: ensure python dependencies are up to date during commits - stages: [pre-commit] - # When the install does change things, it exits 0, so needed to check for the phrase 'operations' in stdout in order to cause things pre-commit command to fail - entry: python -c "import subprocess,sys; results=subprocess.run(['uv', 'sync', '--frozen'],timeout=360,capture_output=True); print ('stdout- ' + results.stdout.decode('utf-8', 'strict')); print ('stderr- ' + results.stderr.decode('utf-8', 'strict')); sys.exit(int(results.returncode or int('Installed' in results.stdout.decode('utf-8', 'strict'))));" - # don't pass filenames else the command line sees them twice - pass_filenames: false - language: system - files: 'uv.lock$' - verbose: true - - - id: sync-dependencies-post-checkout - name: ensure python dependencies are up to date during checkouts - stages: [post-checkout] - entry: bash -c 'uv sync --frozen' - pass_filenames: false - language: system - always_run: true - verbose: true - - -# Reformatting (should generally come before any file format or other checks, because reformatting can change things) -- repo: https://github.com/crate-ci/typos - rev: 2300ad1b6b5c37da54bcafb1a06211196503eac9 # frozen: v1 + # package management + - repo: local + hooks: + - id: uv-check + name: check pyproject.toml for valid uv config + entry: bash -c 'uv lock --check' + language: system + pass_filenames: false + verbose: true + files: "^pyproject.toml$|^uv.lock$" + + - id: sync-dependencies-on-commit + name: ensure python dependencies are up to date during commits + stages: + [pre-commit] + # When the install does change things, it exits 0, so needed to check for the phrase 'operations' in stdout in order to cause things pre-commit command to fail + entry: python -c "import subprocess,sys; results=subprocess.run(['uv', 'sync', '--frozen'],timeout=360,capture_output=True); print ('stdout- ' + results.stdout.decode('utf-8', 'strict')); print ('stderr- ' + results.stderr.decode('utf-8', 'strict')); sys.exit(int(results.returncode or int('Installed' in results.stdout.decode('utf-8', 'strict'))));" + # don't pass filenames else the command line sees them twice + pass_filenames: false + language: system + files: "uv.lock$" + verbose: true + + - id: sync-dependencies-post-checkout + name: ensure python dependencies are up to date during checkouts + stages: [post-checkout] + entry: bash -c 'uv sync --frozen' + pass_filenames: false + language: system + always_run: true + verbose: true + + # Reformatting (should generally come before any file format or other checks, because reformatting can change things) + - repo: https://github.com/crate-ci/typos + rev: 2300ad1b6b5c37da54bcafb1a06211196503eac9 # frozen: v1 hooks: - id: typos -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer # the XML formatter hook doesn't leave a blank line at the end, so excluding XML files from this hook to avoid conflicts - exclude: | # the extra trailing newline in the pull request template makes it easier to click there in the github console. The CLI that programmatically generates devcontainer-lock.json always ends the file incompatible with this hook. - (?x)^( - .github/pull_request_template.md| - template/.github/pull_request_template.md| - template/.copier-answers.yml.jinja-base| - template/template/.copier-answers.yml.jinja| - template/.copier-answers.yml.jinja| - .devcontainer/devcontainer-lock.json| - .copier-answers.yml| - .*\.xml| - )$ + exclude: + | # the extra trailing newline in the pull request template makes it easier to click there in the github console. The CLI that programmatically generates devcontainer-lock.json always ends the file incompatible with this hook. + (?x)^( + .github/pull_request_template.md| + template/.github/pull_request_template.md| + template/.copier-answers.yml.jinja-base| + template/template/.copier-answers.yml.jinja| + template/.copier-answers.yml.jinja| + .devcontainer/devcontainer-lock.json| + .copier-answers.yml| + .*\.xml| + )$ - id: pretty-format-json exclude: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ args: [--autofix, --no-sort-keys] -- repo: https://github.com/myint/docformatter + - repo: https://github.com/pre-commit/mirrors-prettier # TODO: switch to a different approach...this was archived in 2024 + rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8 + hooks: + - id: prettier + # TODO: get template YAML and MD files more in line with prettier expectations so we can start using prettier on those too + exclude: | + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + .*.yaml| + .*.yml| + .*.md| + )$ + + - repo: https://github.com/myint/docformatter # black seems to be working on formatting docstrings, but use this for now - rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 # tip of main that is compatible with pre-commit v4 + rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 # tip of main that is compatible with pre-commit v4 hooks: - id: docformatter exclude: (tests*)|(exceptions\.py)|(warnings\.py) args: - - --in-place - - --wrap-summaries=150 - - --wrap-descriptions=150 + - --in-place + - --wrap-summaries=150 + - --wrap-descriptions=150 -- repo: https://github.com/pamoller/xmlformatter - rev: 47ae0fb9cf2a515f8a2666050fac66fd719ae530 # frozen: v0.2.8 + - repo: https://github.com/pamoller/xmlformatter + rev: 47ae0fb9cf2a515f8a2666050fac66fd719ae530 # frozen: v0.2.8 hooks: - id: xml-formatter exclude: | - (?x)^( - .*/__snapshots__/.*| - )$ - + (?x)^( + .*/__snapshots__/.*| + )$ -# Invalid File Checks -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + # Invalid File Checks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - - id: check-added-large-files - args: ['--maxkb=123'] + - id: check-added-large-files + args: ["--maxkb=123"] exclude: (uv.lock)|(pnpm-lock.yaml) - - id: check-json + - id: check-json # exclude JSON5 or JSONC files with comments - exclude: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ - - id: check-yaml + exclude: | + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ + - id: check-yaml exclude: .copier-answers.yml # This is an autogenerated YAML file by Copier that throws 'found unhashable key' errors - - id: check-xml - - id: check-merge-conflict - - id: check-case-conflict + - id: check-xml + - id: check-merge-conflict + - id: check-case-conflict -- repo: https://github.com/maresb/check-json5 + - repo: https://github.com/maresb/check-json5 rev: 893a2b5a0a27c3540bd8fcafe2968ccc05237179 # 1.0 hooks: - - id: check-json5 + - id: check-json5 files: | - (?x)^( - .devcontainer/devcontainer.json| - .devcontainer/devcontainer-lock.json| - .*devcontainer.json| - .*pyrightconfig.json| - .*tsconfig.json| - )$ - -- repo: local + (?x)^( + .devcontainer/devcontainer.json| + .devcontainer/devcontainer-lock.json| + .*devcontainer.json| + .*pyrightconfig.json| + .*tsconfig.json| + )$ + + - repo: local hooks: - - id: forbidden-files + - id: forbidden-files name: forbidden files entry: found copier update rejection files; review them and remove them language: fail files: "\\.rej$" -# Safety/Security Issues -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 + # Safety/Security Issues + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0 hooks: - - id: detect-private-key + - id: detect-private-key -# Linting + # Linting -- repo: https://github.com/Lucas-C/pre-commit-hooks-markup + - repo: https://github.com/Lucas-C/pre-commit-hooks-markup rev: 501f3d60cee13c712492103343bc23efdc7b3d1f #v1.0.1 hooks: - - id: rst-linter + - id: rst-linter # this hook fails on Sphinx documentation https://github.com/Lucas-C/pre-commit-hooks-markup/issues/13 exclude: docs/.*\.rst$ -- repo: https://github.com/hadolint/hadolint - rev: c3dc18df7a501f02a560a2cc7ba3c69a85ca01d3 # frozen: v2.13.1-beta + - repo: https://github.com/hadolint/hadolint + rev: c3dc18df7a501f02a560a2cc7ba3c69a85ca01d3 # frozen: v2.13.1-beta hooks: - - id: hadolint-docker + - id: hadolint-docker name: Lint Dockerfiles description: Runs hadolint to lint Dockerfiles -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: 41d2daf392fbf43341a77f24a9c6481a4b66af98 # frozen: v0.9.10 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 99abe27a5a16f301d9e0a3828181399dfbf54ebd # frozen: v0.11.0 hooks: - - id: ruff + - id: ruff name: ruff-src - args: [ --fix, --config=./ruff.toml ] + args: [--fix, --config=./ruff.toml] files: src/.+\.py$ - - id: ruff + - id: ruff name: ruff-tests - args: [ --fix, --config=./ruff-test.toml ] + args: [--fix, --config=./ruff-test.toml] files: tests?/.+\.py$ - - id: ruff-format + - id: ruff-format -- repo: https://github.com/pylint-dev/pylint - rev: aaab3ccb541532d2bcdf0410ab93ff4fafc266f5 # frozen: v3.3.5 + - repo: https://github.com/pylint-dev/pylint + rev: aaab3ccb541532d2bcdf0410ab93ff4fafc266f5 # frozen: v3.3.5 hooks: - - id: pylint + - id: pylint name: pylint args: - - --rcfile=./pylintrc.toml + - --rcfile=./pylintrc.toml verbose: true -- repo: local + - repo: local hooks: - - id: pyright + - id: pyright name: pyright entry: bash -c "uv run pyright" files: '.+\.py$' diff --git a/template/.prettierrc b/template/.prettierrc new file mode 100644 index 00000000..d7dc1d46 --- /dev/null +++ b/template/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 120, + "singleQuote": false, + "trailingComma": "all", + "semi": true, + "tabWidth": 2, + "useTabs": false, + "arrowParens": "always", + "bracketSpacing": true, + "quoteProps": "as-needed", + "proseWrap": "preserve" +} diff --git a/tests/copier_data/data1.yaml b/tests/copier_data/data1.yaml index 58959d82..d5f9d737 100644 --- a/tests/copier_data/data1.yaml +++ b/tests/copier_data/data1.yaml @@ -5,16 +5,14 @@ description: Doing amazing things ssh_port_number: 12345 use_windows_in_ci: false + python_package_registry: PyPI aws_identity_center_id: d-9145c20053 aws_org_home_region: us-west-2 aws_production_account_id: 123456789012 use_staging_environment: false aws_region_for_stack: us-east-2 - - # Data added based on the specifics of this template - python_ci_versions: - 3.12.7 package_name: foo-bar diff --git a/tests/copier_data/data2.yaml b/tests/copier_data/data2.yaml index ae4507ad..33a6ff92 100644 --- a/tests/copier_data/data2.yaml +++ b/tests/copier_data/data2.yaml @@ -5,6 +5,7 @@ description: Doing crazy things! So many things! ssh_port_number: 54321 use_windows_in_ci: true + python_package_registry: AWS CodeArtifact aws_central_infrastructure_account_id: 012321432543 core_infra_base_access_profile_name: MyAccessRole @@ -16,11 +17,7 @@ aws_staging_account_id: 210987654321 aws_test_account_id: 211735654321 aws_development_account_id: 000321456870 aws_region_for_stack: us-west-1 - - - # Data added based on the specifics of this template - python_ci_versions: - "3.12.7" - "3.13.2"