Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds jmgilman project #4

Merged
merged 1 commit into from
Sep 20, 2024
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Rust
target/

# Python
dist/
__pycache__/
*.pyc
1 change: 1 addition & 0 deletions users/jmgilman/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
68 changes: 68 additions & 0 deletions users/jmgilman/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
VERSION 0.8

uv:
FROM ghcr.io/astral-sh/uv:0.4.12

SAVE ARTIFACT /uv uv

deps:
FROM python:3.12-slim-bookworm

ENV UV_COMPILE_BYTECODE=0

WORKDIR /work

COPY +uv/uv /usr/local/bin/uv
COPY pyproject.toml uv.lock README.md .

RUN uv sync --frozen --no-install-project

src:
FROM +deps

COPY --dir src README.md .

check:
FROM +src

RUN uv sync --frozen --no-install-project --extra dev

RUN uv run black --check .
RUN uv run ruff check .

build:
FROM +src

RUN uv build --wheel

SAVE ARTIFACT dist dist

test:
FROM +src

COPY --dir tests .

RUN uv sync --frozen --extra dev
RUN uv run pytest .

publish:
FROM python:3.12-slim

ARG container=hello
ARG tag=latest

WORKDIR /app

COPY +build/dist dist

RUN pip install dist/*.whl

ENTRYPOINT ["hello"]
SAVE IMAGE ${container}:${tag}

release:
FROM scratch

COPY +build/dist dist

SAVE ARTIFACT dist/* hello.whl
Empty file added users/jmgilman/README.md
Empty file.
4 changes: 4 additions & 0 deletions users/jmgilman/blueprint.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: "1.0.0"
project: {
name: "hello"
}
26 changes: 26 additions & 0 deletions users/jmgilman/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[project]
name = "hello"
version = "0.1.0"
description = "A simple hello world CLI"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"click>=8.1.7",
]

[project.scripts]
hello = "hello.hello:cli"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/hello"]

[project.optional-dependencies]
dev = [
"black>=24.8.0",
"pytest>=8.3.3",
"ruff>=0.6.5",
]
Empty file.
15 changes: 15 additions & 0 deletions users/jmgilman/src/hello/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import click


def hello(name: str = "World") -> str:
return f"Hello, {name}!"


@click.command()
@click.argument("name", required=False, default="World")
def cli(name):
click.echo(hello(name))


if __name__ == "__main__":
cli()
7 changes: 7 additions & 0 deletions users/jmgilman/tests/hello_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from hello.hello import hello


def test_hello():
assert hello("Alice") == "Hello, Alice!"
assert hello() == "Hello, World!"

160 changes: 160 additions & 0 deletions users/jmgilman/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.