diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..fff8269 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/devcontainers/python:1-3.13-bookworm + +RUN apt-get update -y \ + && export DEBIAN_FRONTEND=noninteractive diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..ef936d4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,61 @@ +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers-extra/features/curl-apt-get:1": {} + }, + "customizations": { + "settings": { + "files.eol": "\n", + "editor.formatOnSave": true, + "editor.tabSize": 4, + "editor.insertSpaces": true, + "python.testing.pytestArgs": [ + "." + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.formatting.provider": "black", + "python.formatting.blackArgs": ["--config", "./pyproject.toml"], + "python.linting.enabled": true, + "python.linting.flake8Enabled": true, + "python.linting.flake8Args": ["--config=./pyproject.toml"], + "python.linting.mypyEnabled": true, + "python.analysis.extraPaths": [ + "./src" + ], + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "terminal.integrated.defaultProfile.linux": "bash", + "workbench.iconTheme": "vscode-icons", + "workbench.colorTheme": "Visual Studio Dark", + "remote.extensionKind": { + "ms-azuretools.vscode-docker": "workspace" + } + }, + "vscode": { + "extensions": [ + "davidanson.vscode-markdownlint", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "Gruntfuggly.todo-tree", + "hashicorp.terraform", + "ms-azuretools.vscode-docker", + "ms-python.debugpy", + "ms-python.python", + "ms-python.black-formatter", + "ms-python.flake8", + "ms-python.mypy", + "streetsidesoftware.code-spell-checker", + "vscode-icons-team.vscode-icons" + ] + } + }, + "postCreateCommand": ".devcontainer/scripts/postCreate.sh", + "remoteUser": "root", + "workspaceFolder": "/workspaces/test", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/test,type=bind,consistency=cached" +} diff --git a/.devcontainer/scripts/postCreate.sh b/.devcontainer/scripts/postCreate.sh new file mode 100755 index 0000000..0814003 --- /dev/null +++ b/.devcontainer/scripts/postCreate.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +set -e # Exit immediately if a command exits with a non-zero status + +# Display system information +echo "System Information:" +uname -a + +# Install Poetry +echo "Installing Poetry..." +if ! command -v poetry &> /dev/null; then + curl -sSL https://install.python-poetry.org | python3 - + export PATH="$HOME/.local/bin:$PATH" +else + echo "Poetry is already installed." +fi + +# Verify Poetry installation +if ! command -v poetry &> /dev/null; then + echo "Error: Poetry installation failed." + exit 1 +fi + +# Configure Poetry to create virtual environments inside the project +poetry config virtualenvs.in-project true + +# Install dependencies via Poetry +echo "Installing dependencies with Poetry..." +poetry install --with dev + +# Ensure PYTHONPATH is set in the current session and persists across sessions +PYTHONPATH_ENTRY="/workspaces/test/src" +if ! grep -Fxq "export PYTHONPATH=$PYTHONPATH_ENTRY:\$PYTHONPATH" ~/.bashrc; then + echo "Configuring PYTHONPATH..." + echo "export PYTHONPATH=$PYTHONPATH_ENTRY:\$PYTHONPATH" >> ~/.bashrc +fi + +# Add the Poetry virtual environment's `bin` directory to PATH +VENV_BIN_PATH="/workspaces/test/.venv/bin" +if ! grep -Fxq "export PATH=$VENV_BIN_PATH:\$PATH" ~/.bashrc; then + echo "Adding Poetry virtual environment to PATH..." + echo "export PATH=$VENV_BIN_PATH:\$PATH" >> ~/.bashrc +fi + +# Load the updated bashrc configuration for the current session +source ~/.bashrc + +# Validate that validate-devschema is accessible +echo "Validating script installation..." +if ! validate-devschema --help &> /dev/null; then + echo "Error: validate-devschema script is not globally accessible." + exit 1 +else + echo "validate-devschema is installed and ready to use." +fi + +# Display completion message +echo "Development container setup complete!" diff --git a/.github/workflows/commitmsg-conform.yml b/.github/workflows/commitmsg-conform.yml new file mode 100644 index 0000000..a08ee76 --- /dev/null +++ b/.github/workflows/commitmsg-conform.yml @@ -0,0 +1,11 @@ +name: commit-message-conformance +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + commitmsg-conform: + uses: jdevto/actions/.github/workflows/commitmsg-conform.yml@main diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml new file mode 100644 index 0000000..2db537d --- /dev/null +++ b/.github/workflows/markdown-lint.yml @@ -0,0 +1,11 @@ +name: markdown-lint +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + markdown-lint: + uses: jdevto/actions/.github/workflows/markdown-lint.yml@main diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..272ef7d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,17 @@ +{ + "recommendations": [ + "davidanson.vscode-markdownlint", + "eamodio.gitlens", + "esbenp.prettier-vscode", + "Gruntfuggly.todo-tree", + "hashicorp.terraform", + "ms-azuretools.vscode-docker", + "ms-python.autopep8", + "ms-python.debugpy", + "ms-python.python", + "ms-python.black-formatter", + "ms-python.flake8", + "streetsidesoftware.code-spell-checker", + "vscode-icons-team.vscode-icons" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f577d0a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,27 @@ +{ + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + "editor.tabSize": 4, + "editor.insertSpaces": true, + "files.eol": "\n", + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "python.formatting.provider": "black", + "python.formatting.blackArgs": ["--config", "./pyproject.toml"], + "python.linting.enabled": true, + "python.linting.flake8Enabled": true, + "python.linting.mypyEnabled": true, + "python.linting.flake8Args": ["--config=./pyproject.toml"], + "python.analysis.extraPaths": [ + "./src" + ], + "python.pythonPath": "/workspaces/test/.venv/bin/python", + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnSave": true + }, + "prettier.requireConfig": true, + "workbench.iconTheme": "vscode-icons", + "workbench.colorTheme": "Visual Studio Dark" +} diff --git a/README.md b/README.md index 043729e..f92c2eb 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# python-poetry-hello \ No newline at end of file +# python-poetry-hello diff --git a/commitmsg-conform.yml b/commitmsg-conform.yml new file mode 100644 index 0000000..e7b4d63 --- /dev/null +++ b/commitmsg-conform.yml @@ -0,0 +1,11 @@ +name: commit-message-conformance +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + commitmsg-conform: + uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main diff --git a/hello-world/README.md b/hello-world/README.md new file mode 100644 index 0000000..e69de29 diff --git a/hello-world/hello_world/__init__.py b/hello-world/hello_world/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hello-world/hello_world/main.py b/hello-world/hello_world/main.py new file mode 100644 index 0000000..4231d31 --- /dev/null +++ b/hello-world/hello_world/main.py @@ -0,0 +1,7 @@ +# hello_world/main.py +def main(): + print("Hello, World!") + + +if __name__ == "__main__": + main() diff --git a/hello-world/hello_world/tests/test_hello_world.py b/hello-world/hello_world/tests/test_hello_world.py new file mode 100644 index 0000000..eca2a47 --- /dev/null +++ b/hello-world/hello_world/tests/test_hello_world.py @@ -0,0 +1,6 @@ +def test_main(capsys): + from hello_world.main import main + + main() + captured = capsys.readouterr() + assert captured.out == "Hello, World!\n" diff --git a/hello-world/poetry.lock b/hello-world/poetry.lock new file mode 100644 index 0000000..8a352f2 --- /dev/null +++ b/hello-world/poetry.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand. +package = [] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.13" +content-hash = "43c15d4b40e26b9dc4090308565270876da3b72ef2b9fa0bddbe4b344cfe177c" diff --git a/hello-world/pyproject.toml b/hello-world/pyproject.toml new file mode 100644 index 0000000..43529c0 --- /dev/null +++ b/hello-world/pyproject.toml @@ -0,0 +1,19 @@ +[project] +name = "hello-world" +version = "0.1.0" +description = "" +authors = [ + {name = "Your Name",email = "you@example.com"} +] +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ +] + + +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry.scripts] +hello-world = "hello_world.main:main" diff --git a/hello-world/tests/__init__.py b/hello-world/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/markdown-lint.yml b/markdown-lint.yml new file mode 100644 index 0000000..d9a2d67 --- /dev/null +++ b/markdown-lint.yml @@ -0,0 +1,11 @@ +name: markdown-lint +on: + pull_request: {} +permissions: + statuses: write + checks: write + contents: read + pull-requests: read +jobs: + markdown-lint: + uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main