forked from airbytehq/airbyte-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
182 lines (148 loc) · 5.61 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
plugins {
id "base"
id 'com.bmuschko.docker-remote-api'
alias(libs.plugins.node.gradle)
}
// Use the node version that's defined in the .nvmrc file
def nodeVersion = new File("${projectDir}/.nvmrc").text.trim();
// Read pnpm version to use from package.json engines.pnpm entry
def pnpmVer = new groovy.json.JsonSlurper().parse(new File("${projectDir}/package.json")).engines.pnpm.trim();
// This array should contain a path to all configs that are common to most build tasks and
// might affect them (i.e. if any of those files change we want to rerun most tasks)
def commonConfigs = [
'.env',
'.env.production',
'package.json',
'pnpm-lock.yaml',
'tsconfig.json',
'.prettierrc.js'
]
node {
download = true
version = nodeVersion
pnpmVersion = pnpmVer
distBaseUrl = "https://nodejs.org/dist"
}
tasks.named("pnpmInstall") {
// Add patches folder to inputs of pnpmInstall task, since it has pnpm-lock.yml as an output
// thus wouldn't rerun in case a patch get changed
inputs.dir "patches"
}
// fileTree to watch node_modules, but exclude the .cache dir since that might have changes on every build
def nodeModules = fileTree('node_modules').matching {
exclude '.cache'
}
// fileTree to watch the public dir but exclude the auto generated buildInfo.json. It's content is anyway a
// content hash, depending on the other files.
def publicDir = fileTree('public').matching {
exclude 'buildInfo.json'
}
tasks.register("pnpmBuild", PnpmTask) {
dependsOn tasks.named("pnpmInstall")
environment = ["VERSION": rootProject.ext.version]
args = ['build']
inputs.property "cloudEnv", System.env.WEBAPP_BUILD_CLOUD_ENV ?: ""
inputs.files commonConfigs
inputs.files nodeModules
inputs.files publicDir
inputs.file '.eslintrc.js'
inputs.file '.stylelintrc'
inputs.file 'orval.config.ts'
inputs.file 'vite.config.mts'
inputs.file 'index.html'
inputs.dir 'scripts'
inputs.dir 'src'
outputs.dir 'build/app'
}
tasks.register("test", PnpmTask) {
dependsOn tasks.named("assemble")
args = ['run', 'test:ci']
inputs.files commonConfigs
inputs.file 'jest.config.ts'
inputs.file 'babel.config.js'
inputs.dir 'src'
// The test has no outputs, thus we always treat the outputs up to date
// as long as the inputs have not changed
outputs.upToDateWhen { true }
}
tasks.register("e2etest", PnpmTask) {
dependsOn tasks.named("pnpmInstall")
// If the cypressWebappKey property has been set from the outside (see tools/bin/e2e_test.sh)
// we'll record the cypress session, otherwise we're not recording
def recordCypress = project.hasProperty('cypressWebappKey') && project.getProperty('cypressWebappKey')
if (recordCypress) {
environment = [CYPRESS_KEY: project.getProperty('cypressWebappKey')]
args = ['run', 'cypress:ci:record']
} else {
args = ['run', 'cypress:ci']
}
// Mark the outputs as never up to date, to ensure we always run the tests.
// We want this because they are e2e tests and can depend on other factors e.g., external dependencies.
outputs.upToDateWhen { false }
}
tasks.register("cloudE2eTest", PnpmTask) {
dependsOn tasks.named("pnpmInstall")
def recordCypress = project.hasProperty('cypressCloudWebappKey') && project.getProperty('cypressCloudWebappKey')
if (recordCypress) {
environment = [CYPRESS_KEY: project.getProperty('cypressCloudWebappKey')]
args = ['run', 'cloud-test:stage:record']
} else {
args = ['run', 'cloud-test:stage']
}
// Mark the outputs as never up to date, to ensure we always run the tests.
// We want this because they are e2e tests and can depend on other factors e.g., external dependencies.
outputs.upToDateWhen { false }
}
//
//tasks.register("validateLinks", PnpmTask) {
// dependsOn tasks.named("pnpmInstall")
//
// args = ['run', 'validate-links']
//
// inputs.file 'scripts/validate-links.ts'
// inputs.file 'src/core/utils/links.ts'
//
// // Since the output of this task depends on availability of URLs
// // we never want to treat it as "up-to-date" on CI and always want to run it
// // but running locally we treat it as up-to-date just depending on its inputs
// outputs.upToDateWhen {
// System.getenv("CI") === null
// }
//}
tasks.register("buildStorybook", PnpmTask) {
dependsOn tasks.named("pnpmInstall")
args = ['run', 'build:storybook']
inputs.files commonConfigs
inputs.files nodeModules
inputs.files publicDir
inputs.dir '.storybook'
inputs.dir 'src'
outputs.dir 'build/storybook'
environment = [
'NODE_OPTIONS': '--max_old_space_size=8192'
]
}
tasks.register("copyBuildOutput", Copy) {
dependsOn tasks.named("copyDocker"), tasks.named("pnpmBuild")
from "${project.projectDir}/build/app"
into 'build/docker/bin/build'
}
tasks.register("copyNginx", Copy) {
dependsOn tasks.named("copyDocker")
from "${project.projectDir}/nginx"
into "build/docker/bin/nginx"
}
// Those tasks should be run as part of the "check" task
tasks.named("check") {
dependsOn /*tasks.named("validateLinks"),*/ tasks.named("test")
}
tasks.named("build") {
dependsOn tasks.named("buildStorybook")
}
tasks.named("buildDockerImage") {
dependsOn tasks.named("copyDocker"), tasks.named("copyNginx"), tasks.named("copyBuildOutput")
}
// Include some cloud-specific tasks only in the airbyte-platform-internal environment
if (file("${project.projectDir}/../../cloud-webapp/cloud-tasks.gradle").exists()) {
apply from: "${project.projectDir}/../../cloud-webapp/cloud-tasks.gradle"
}