forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mill
114 lines (96 loc) · 3.52 KB
/
build.mill
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
package build
import mill._, pythonlib._
object foo extends PythonModule {
def mainScript = Task.Source { "src/foo.py" }
def pythonDeps = Seq("Jinja2==3.1.4")
object test extends PythonTests with TestModule.Unittest
}
// This is a basic Mill build for a single `PythonModule`, with one
// dependency and a test suite using the `Unittest` Library.
//
// You can download the example project using the **download** link above,
// or browse the full sources via the **browse** link.
// Ensure you have a JVM installed; the `./mill` script manages all other dependencies.
// All examples, from simple hello-world projects on this page to advanced
// xref:pythonlib/web-examples.adoc[web build examples]
// are fully executable and tested in Mill’s CI workflows.
//
// The source code for this module lives in the `src/` folder.
// Output for this module (typeChecked files, resolved dependency lists, …) lives in `out/`.
//
// ----
// build.mill
// foo/
// src/
// foo/foo.py
// resources/
// ...
// test/
// src/
// foo/test.py
// out/foo/
// run.json
// run.dest/
// ...
// test/
// run.json
// run.dest/
// ...
// ----
//
// This example project uses one dependency - https://pypi.org/project/Jinja2/[Jinja2]
// for HTML rendering and uses it to wrap a given input string in HTML templates with proper escaping.
//
// Typical usage of a `PythonModule` is shown below:
/** Usage
> ./mill resolve foo._ # List what tasks are available to run
foo.bundle
...
foo.console
...
foo.run
...
foo.test
...
foo.typeCheck
> ./mill inspect foo.typeCheck # Show documentation and inputs of a task
...
foo.typeCheck(PythonModule...)
Run a typechecker on this module.
Inputs:
foo.pythonExe
foo.transitivePythonPath
foo.sources
...
> ./mill foo.typeCheck # TypeCheck the Python Files and notify errors
Success: no issues found in 1 source file
> ./mill foo.run --text "Hello Mill" # run the main method with arguments
<h1>Hello Mill</h1>
> ./mill foo.test
...
test_escaping (test.TestScript...) ... ok
test_simple (test.TestScript...) ... ok
...Ran 2 tests...
OK
...
> ./mill show foo.bundle # Creates Bundle for the python file
".../out/foo/bundle.dest/bundle.pex"
> out/foo/bundle.dest/bundle.pex --text "Hello Mill" # running the PEX binary outside of Mill
<h1>Hello Mill</h1>
> sed -i.bak 's/print(main())/print(maaain())/g' foo/src/foo.py
> ./mill foo.typeCheck # if we make a typo in a method name, mypy flags it
error: ...Name "maaain" is not defined...
*/
// The output of every Mill task is stored in the `out/` folder under a name corresponding to
// the task that created it. e.g. The `typeCheck` task puts its metadata output in `out/typeCheck.json`,
// and its output files in `out/typeCheck.dest`.
// You can also use `show` to make Mill print out the metadata output for a particular task.
//
// You can run mill `resolve __` to see a full list of the different tasks that are available,
// `mill resolve _` to see the tasks within foo, `mill inspect typeCheck` to inspect a task’s doc-comment
// documentation or what it depends on, or `mill show foo.typeCheck` to show the output of any task.
//
// The most common **tasks** that Mill can run are cached tasks, such as `typeCheck`, `test`, `bundle` and
// `run`. Cached tasks do not re-evaluate unless one of their inputs changes, whereas commands re-run every time.
// See the documentation for https://mill-build.org/mill/main-branch/fundamentals/tasks.html[Tasks]
// for details on the different task types.