forked from spinnaker/deck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
128 lines (108 loc) · 3.46 KB
/
build.gradle
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
121
122
123
124
125
126
127
128
plugins {
id "io.spinnaker.bintray-publish" version "$spinnakerGradleVersion"
id "nebula.node" version "1.3.1"
}
import java.nio.file.Paths
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.redline_rpm.header.Flags
group = "com.netflix.spinnaker.deck"
apply plugin: "nebula.ospackage"
// BintrayPublishPlugin looks for a task named "publish" to attach its tasks to,
// so we need to make sure one exists. Normally this would be created by the
// publishing plugin, but we aren't applying that here.
project.tasks.register("publish")
node {
// Pulls node and npm versions from package.json.
def packageSlurper = new JsonSlurper()
def packageJson = packageSlurper.parse file('package.json')
version = packageJson.engines.node.replaceAll(/[^\d\.]/, '')
npmVersion = packageJson.engines.npm.replaceAll(/[^\d\.]/, '')
yarnVersion = packageJson.engines.yarn.replaceAll(/[^\d\.]/, '')
// Enabled the automatic download. False is the default (for now).
download = true
}
task webpack(type: NodeTask) {
workingDir file('.')
script = file('node_modules/webpack/bin/webpack.js')
args = ['--mode=production']
environment = [
"NODE_ENV": "production",
"GATE_HOST": "spinnaker-api-prestaging.prod.netflix.net",
"NODE_OPTIONS": "--max_old_space_size=8192",
]
}
task copyFavicon(type: Copy) {
from "app/prod-favicon.ico"
into "build/webpack"
rename "prod-favicon.ico", "favicon.ico"
}
task karma(type: NodeTask) {
script = file('node_modules/karma/bin/karma')
args = ["start", "--single-run", "--reporters", "dots"]
if (project.hasProperty('skipTests')) {
karma.enabled = false
}
}
task functionalTestsChrome(type: NodeTask) {
script = file('test/functional/run.js')
args = ['--replay-fixtures', '--serve-deck', '--imposter-port=8084', '--browser=chrome', '--headless']
}
task functionalTestsFirefox(type: NodeTask) {
script = file('test/functional/run.js')
args = ['--replay-fixtures', '--serve-deck', '--imposter-port=8084', '--browser=firefox', '--headless']
}
task generateVersionFile {
doLast {
'git update-index --assume-unchanged version.json'.execute()
def buildInfo = [
version: project.hasProperty('deckVersion') ? "${deckVersion}" : "n/a",
created: new Date().getTime()
]
def buildJson = JsonOutput.prettyPrint(JsonOutput.toJson(buildInfo))
new File(Paths.get("build", "webpack").toString()).mkdirs()
new File(Paths.get("build", "webpack", "version.json").toString()).write(buildJson)
new File("version.json").write(buildJson)
}
}
webpack.outputs.dir file('build/webpack')
yarn.dependsOn 'generateVersionFile'
webpack.dependsOn 'yarn'
karma.dependsOn 'webpack'
project.tasks.register('test') {
dependsOn 'karma'
}
copyFavicon.dependsOn 'test'
buildDeb.dependsOn 'webpack', 'copyFavicon'
buildRpm.dependsOn 'webpack'
functionalTestsChrome.dependsOn 'yarn'
functionalTestsFirefox.dependsOn 'yarn'
build.dependsOn 'buildDeb'
String toVers(String v) {
int idx = v.indexOf('-')
if (idx != -1) {
return v.substring(0, idx)
}
return v
}
String toRelease(String v) {
int idx = v.lastIndexOf('-')
if (idx != -1) {
return v.substring(idx + 1)
}
return ''
}
ospackage {
packageName = "spinnaker-deck"
version = toVers(project.version.toString())
release toRelease(project.version.toString())
into "/opt/deck/html"
from "build/webpack"
os = LINUX
}
buildRpm {
requires('httpd')
}
buildDeb {
requires('apache2', '2.4.7', Flags.GREATER | Flags.EQUAL)
}