Skip to content

Commit

Permalink
chore: add orion extension
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Oct 4, 2024
1 parent 184df2a commit 894c5cf
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ features:
- value: "{{ .Scaffold.oci }}"
globs:
- "*/tools/oci/BUILD.bazel"
- value: "{{ and .Scaffold.oci .Computed.go }}"
globs:
- "*/.aspect/cli/py3_image.star"
- "*/tools/oci/py3_image.bzl"
- value: "{{ and .Scaffold.oci .Computed.go }}"
globs:
- "*/.aspect/cli/go_image.star"
Expand Down
33 changes: 33 additions & 0 deletions {{ .ProjectSnake }}/.aspect/cli/py3_image.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"Generate py_pytest_main targets"
aspect.register_rule_kind("py3_image", {
"From": "//tools/oci:py3_image.bzl",
"ResolveAttrs": ["deps"],
})

def declare_targets(ctx):
"""Check for presence of pragma, generate rules if found"""
for file in ctx.sources:
has_pragma = len(file.query_results["pragma"]) > 0
if has_pragma:
ctx.targets.add(
kind = "py3_image",
name = "image",
attrs = {
},
)
break
aspect.register_configure_extension(
id = "py3_image",
prepare = lambda cfg: aspect.PrepareResult(
sources = [
aspect.SourceGlobs("__main__.py"),
],
queries = {
"pragma": aspect.RegexQuery(
filter = "__main__.py",
expression = """#\\s*oci:\\s*build""",
),
},
),
declare = declare_targets,
)

0 comments on commit 894c5cf

Please sign in to comment.