-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpixi.toml
More file actions
120 lines (109 loc) · 5.4 KB
/
pixi.toml
File metadata and controls
120 lines (109 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
[workspace]
authors = ["ZHU Yuhao (朱宇浩) <dr.yuhao.zhu@outlook.com>"]
channels = [
"https://conda.modular.com/max",
"https://repo.prefix.dev/modular-community",
"conda-forge",
]
description = "A command-line argument parser library for Mojo"
license = "Apache-2.0"
name = "argmojo"
platforms = ["osx-arm64", "linux-64"]
readme = "README.md"
version = "0.5.0"
[dependencies]
mojo = "==0.26.2.0"
[tasks]
# format the code
format = "mojo format ./src ./tests ./examples"
# compile the package
package = "mojo package src/argmojo -o argmojo.mojopkg"
# doc
doc = """mojo doc --diagnose-missing-doc-strings src/argmojo > /dev/null"""
# run tests
test = """ set -e
pixi run format \
&& pixi run package \
&& mojo run -I src -D ASSERT=all tests/test_parse.mojo \
&& mojo run -I src -D ASSERT=all tests/test_options.mojo \
&& mojo run -I src -D ASSERT=all tests/test_groups.mojo \
&& mojo run -I src -D ASSERT=all tests/test_help.mojo \
&& mojo run -I src -D ASSERT=all tests/test_subcommands.mojo \
&& mojo run -I src -D ASSERT=all tests/test_completion.mojo \
&& mojo run -I src -D ASSERT=all tests/test_interactive.mojo < /dev/null \
&& mojo run -I src -D ASSERT=all tests/test_declarative.mojo \
&& mojo run -I src -D ASSERT=all tests/test_hybrid.mojo \
&& mojo run -I src -D ASSERT=all tests/test_subcommands_declarative.mojo \
&& mojo run -I src -D ASSERT=all tests/test_wrappers.mojo \
&& mojo run -I src -D ASSERT=all tests/test_dispatch.mojo \
&& mojo run -I src -D ASSERT=all tests/test_schema_validation.mojo \
&& bash tests/check_schema_errors.sh"""
# NOTE: test_response_file.mojo is excluded — response file expansion
# is temporarily disabled to work around a Mojo compiler deadlock
# with -D ASSERT=all. Re-enable when the compiler bug is fixed.
# run tests (parallel, fail if any test fails)
t = """set -e
pixi run format \
&& pixi run package \
&& bash -c '\
pids=(); \
mojo run -I src -D ASSERT=all tests/test_parse.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_options.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_groups.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_help.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_subcommands.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_completion.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_interactive.mojo < /dev/null & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_declarative.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_hybrid.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_subcommands_declarative.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_wrappers.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_dispatch.mojo & pids+=($!); \
mojo run -I src -D ASSERT=all tests/test_schema_validation.mojo & pids+=($!);
rc=0; for p in "${pids[@]}"; do wait "$p" || rc=1; done; \
bash tests/check_schema_errors.sh || rc=1; exit $rc'
"""
# build example binaries (with timing); pass a name to build one only
# Usage: pixi run build (all examples)
# pixi run build mgit (mgit only)
build = "bash examples/build.sh"
# run (debug mode) example binaries
# Uses --help so examples with required positional args exit cleanly.
# The purpose is to exercise command construction (registration-time
# validation), not argument parsing.
debug = """pixi run package \
&& mojo run -I src -D ASSERT=all examples/mgrep.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/mgit.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/demo.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/yu.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/declarative/search.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/declarative/deploy.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/declarative/convert.mojo -- --help \
&& mojo run -I src -D ASSERT=all examples/declarative/jomo.mojo -- --help \
"""
# run (debug mode) example binaries (parallel, fail if any run fails)
# Uses --help so examples with required positional args exit cleanly.
# The purpose is to exercise command construction (registration-time
# validation), not argument parsing.
d = """pixi run package && bash -c '\
pids=(); \
mojo run -I src -D ASSERT=all examples/mgrep.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/mgit.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/demo.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/yu.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/declarative/search.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/declarative/deploy.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/declarative/convert.mojo -- --help & pids+=($!); \
mojo run -I src -D ASSERT=all examples/declarative/jomo.mojo -- --help & pids+=($!); \
rc=0; for p in "${pids[@]}"; do wait "$p" || rc=1; done; exit $rc'
"""
# clean build artifacts
clean = "rm -f argmojo.mojopkg mgrep mgit demo yu jomo search deploy convert"
# Run all
all = """
pixi run format \
&& pixi run package \
&& pixi run doc \
&& pixi run test \
&& pixi run d \
&& pixi run clean"""