Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Pull Request Checks

on:
pull_request:
branches:
- main
- master
types:
- opened
- synchronize

env:
PYTHON_VERSION: "3.11"

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@v6.4.3
with:
version: latest

- name: Install dependencies
run: ./scripts/setup.sh

- name: Run linting
run: ./scripts/lint.sh

test:
name: Test
runs-on: ubuntu-latest
needs: lint

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@v6.4.3
with:
version: latest

- name: Install dependencies
run: ./scripts/setup.sh

- name: Run tests
run: ./scripts/test.sh
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
coverage.*

# Translations
*.mo
Expand Down Expand Up @@ -182,9 +183,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
28 changes: 28 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://taskfile.dev

version: "3"

tasks:
default:
deps:
- setup
- format
- lint
- test
silent: true

setup:
cmds:
- ./scripts/setup.sh

format:
cmds:
- ./scripts/format.sh

lint:
cmds:
- ./scripts/lint.sh

test:
cmds:
- ./scripts/test.sh
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[project]
name = "lambda-application"
description = "Lambda application code, decoupled from lambda-infrastructure"
version = "0.1.0"
requires-python = ">=3.11"
readme = "README.md"

dependencies = []

[dependency-groups]
dev = [
"pytest>=8.3",
"pytest-cov>=6.2",
"ruff>=0.12",
]

[tool.pytest.ini_options]
testpaths = ["src"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]

[tool.coverage.run]
source = ["src"]
omit = [
"*/test_*.py",
"*/_test.py",
"*/tests/*",
"*_test.py",
"test_*.py"
]

[tool.coverage.report]
exclude_lines = [
"if __name__ == .__main__.:",
"raise AssertionError",
"raise NotImplementedError",
"if self.debug:",
"if settings.DEBUG",
"pragma: no cover",
]
3 changes: 3 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

uv run ruff format src/
5 changes: 5 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

uv run ruff check .

uv run ruff format --check src/
3 changes: 3 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

uv sync --group dev
3 changes: 3 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

uv run pytest . -v --cov=src
6 changes: 6 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from lambda-application!")


if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions src/main_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from unittest.mock import patch
from main import main


def test_main_prints_hello_message():
"""Test that main() prints the expected hello message."""
with patch("builtins.print") as mock_print:
main()
mock_print.assert_called_once_with("Hello from lambda-application!")


def test_main_returns_none():
"""Test that main() returns None (implicit return)."""
result = main()
assert result is None


def test_main_calls_print():
"""Test that main() actually calls print function."""
with patch("builtins.print") as mock_print:
main()
assert mock_print.called
242 changes: 242 additions & 0 deletions uv.lock

Large diffs are not rendered by default.