forked from com-lihaoyi/mill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mill
76 lines (60 loc) · 2.11 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
package build
import mill._, javascriptlib._, pythonlib._, javalib._
object client extends ReactScriptsModule
object `sentiment-analysis` extends PythonModule {
def mainScript = Task.Source { moduleDir / "src" / "foo.py" }
def pythonDeps = Seq("textblob==0.19.0")
object test extends PythonTests with pythonlib.TestModule.Unittest
}
object server extends JavaModule {
def ivyDeps = Seq(
ivy"org.springframework.boot:spring-boot-starter-web:2.5.6",
ivy"org.springframework.boot:spring-boot-starter-actuator:2.5.6"
)
/** Bundle client & sentiment-analysis as resource */
def resources = Task.Sources {
os.copy(client.bundle().path, Task.dest / "static")
os.makeDir.all(Task.dest / "analysis")
os.copy(`sentiment-analysis`.bundle().path, Task.dest / "analysis" / "analysis.pex")
super.resources() ++ Seq(PathRef(Task.dest))
}
object test extends JavaTests with javalib.TestModule.Junit5 {
def ivyDeps = super.ivyDeps() ++ Seq(
ivy"org.springframework.boot:spring-boot-starter-test:2.5.6"
)
}
}
// This example demonstrates a simple multi-langauge project,
// running a `spring boot webserver` serving a `react client` and interacting with a `python binary`
// through the web-server api.
/** Usage
> mill client.test
PASS src/test/App.test.tsx
...Text Analysis Tool
...renders the app with initial UI...
...displays sentiment result...
...
Test Suites:...1 passed, 1 total
Tests:...2 passed, 2 total
...
> mill sentiment-analysis.test
...
test_negative_sentiment... ok
test_neutral_sentiment... ok
test_positive_sentiment... ok
...
Ran 3 tests...
...
OK
...
> mill server.test
...com.example.ServerTest#shouldReturnStaticPage() finished...
...com.example.ServerTest#shouldReturnPositiveAnalysis() finished...
...com.example.ServerTest#shouldReturnNegativeAnalysis() finished...
> mill server.runBackground
> curl http://localhost:8086
...<title>Sentiment Analysis Tool</title>...
> curl -X POST http://localhost:8086/api/analysis -H "Content-Type: text/plain" --data "This is awesome!" # Make request to the analysis api
Positive sentiment (polarity: 1.0)
> mill clean server.runBackground
*/