-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# Rust | ||
target/ | ||
|
||
# Python | ||
dist/ | ||
__pycache__/ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: "1.0.0" | ||
project: { | ||
name: "hello" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.