Skip to content
Closed
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
1 change: 1 addition & 0 deletions content/en/docs/04/solution/ci/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/sdk/** linguist-generated
4 changes: 4 additions & 0 deletions content/en/docs/04/solution/ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.venv
/**/__pycache__
/sdk
/.env
12 changes: 12 additions & 0 deletions content/en/docs/04/solution/ci/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "class-quiz"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["dagger-io"]

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

[tool.uv.sources]
dagger-io = { path = "sdk", editable = true }
16 changes: 16 additions & 0 deletions content/en/docs/04/solution/ci/src/class_quiz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""A generated module for ClassQuiz functions

This module has been generated via dagger init and serves as a reference to
basic module structure as you get started with Dagger.

Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.

The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
"""

from .main import ClassQuiz as ClassQuiz
22 changes: 22 additions & 0 deletions content/en/docs/04/solution/ci/src/class_quiz/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import dagger
from dagger import dag, function, object_type


@object_type
class ClassQuiz:
@function
def container_echo(self, string_arg: str) -> dagger.Container:
"""Returns a container that echoes whatever string argument is provided"""
return dag.container().from_("alpine:latest").with_exec(["echo", string_arg])

@function
async def grep_dir(self, directory_arg: dagger.Directory, pattern: str) -> str:
"""Returns lines that match a pattern in the files of the provided Directory"""
return await (
dag.container()
.from_("alpine:latest")
.with_mounted_directory("/mnt", directory_arg)
.with_workdir("/mnt")
.with_exec(["grep", "-R", pattern, "."])
.stdout()
)
637 changes: 637 additions & 0 deletions content/en/docs/04/solution/ci/uv.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/en/docs/04/solution/dagger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ClassQuiz",
"engineVersion": "v0.18.0",
"engineVersion": "v0.18.14",
"sdk": {
"source": "python"
},
Expand Down