@@ -24,92 +24,114 @@ plugins {
2424
2525description = " Apache Polaris (incubating) Helm Chart"
2626
27+ val runtimeServerDistribution by
28+ configurations.creating {
29+ isCanBeConsumed = false
30+ isCanBeResolved = true
31+ }
32+
33+ dependencies { runtimeServerDistribution(project(" :polaris-server" , " distributionElements" )) }
34+
2735val helmTestReportsDir = layout.buildDirectory.dir(" reports" )
2836
2937val helmTemplateValidation by
3038 tasks.registering(Exec ::class ) {
3139 group = " verification"
3240 description = " Run 'helm template' validation with all values files"
3341
34- workingDir = projectDir
42+ val outputFile = helmTestReportsDir.get().file( " helm-template/validation.log " ).asFile
3543
36- val outputFile = helmTestReportsDir.get().file(" helm-template/validation.log" )
44+ doFirst {
45+ outputFile.parentFile.mkdirs()
46+ val outStream = outputFile.outputStream()
47+ standardOutput = outStream
48+ errorOutput = outStream
49+ }
3750
3851 commandLine =
3952 listOf (
4053 " sh" ,
4154 " -c" ,
4255 """
43- mkdir -p ${outputFile.asFile.parent}
44- for f in values.yaml ci/*.yaml; do
45- echo "Validating helm template with ${' $' } f"
46- helm template --debug --namespace polaris-ns --values ${' $' } f .
47- done > ${outputFile.asFile} 2>&1
48- """
56+ for f in values.yaml ci/*.yaml; do
57+ echo "Validating helm template with ${' $' } f"
58+ helm template --debug --namespace polaris-ns --values ${' $' } f .
59+ done
60+ """
4961 .trimIndent(),
5062 )
5163
5264 inputs.files(
5365 fileTree(projectDir) { include(" Chart.yaml" , " values.yaml" , " ci/*.yaml" , " templates/**/*" ) }
5466 )
5567
56- outputs.file(outputFile)
68+ outputs.cacheIf { true }
5769 }
5870
5971val helmUnitTest by
6072 tasks.registering(Exec ::class ) {
6173 group = " verification"
6274 description = " Run Helm unit tests"
6375
64- workingDir = projectDir
76+ val outputFile = helmTestReportsDir.get().file( " helm-unit/test.log " ).asFile
6577
66- val outputFile = helmTestReportsDir.get().file(" helm-unit/test.log" )
78+ doFirst {
79+ outputFile.parentFile.mkdirs()
80+ val outStream = outputFile.outputStream()
81+ standardOutput = outStream
82+ errorOutput = outStream
83+ }
6784
68- // Install the plugin if not already installed, then run tests
6985 commandLine =
7086 listOf (
7187 " sh" ,
7288 " -c" ,
7389 """
74- mkdir -p ${outputFile.asFile.parent}
75- helm plugin install https://github.com/helm-unittest/helm-unittest.git 2>/dev/null || true
76- helm unittest . > ${outputFile.asFile} 2>&1
77- """
90+ echo "====== Install helm-unittest plugin ======"
91+ helm plugin install https://github.com/helm-unittest/helm-unittest.git || true
92+
93+ echo "====== Run helm unit tests ======"
94+ helm unittest .
95+ """
7896 .trimIndent(),
7997 )
8098
8199 inputs.files(
82100 fileTree(projectDir) { include(" Chart.yaml" , " values.yaml" , " templates/**/*" , " tests/**/*" ) }
83101 )
84102
85- outputs.file(outputFile)
103+ outputs.cacheIf { true }
86104 }
87105
88106val chartTestingLint by
89107 tasks.registering(Exec ::class ) {
90108 group = " verification"
91109 description = " Run chart-testing (lint)"
92110
93- workingDir = rootProject.projectDir
111+ val outputFile = helmTestReportsDir.get().file( " ct/lint.log " ).asFile
94112
95- val outputFile = helmTestReportsDir.get().file(" ct/lint.log" )
113+ doFirst {
114+ outputFile.parentFile.mkdirs()
115+ val outStream = outputFile.outputStream()
116+ standardOutput = outStream
117+ errorOutput = outStream
118+ }
96119
97120 commandLine =
98121 listOf (
99122 " sh" ,
100123 " -c" ,
101124 """
102- mkdir -p ${outputFile.asFile.parent}
103- ct lint --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1
104- """
125+ ct lint --debug --charts .
126+ """
105127 .trimIndent(),
106128 )
107129
108130 inputs.files(
109131 fileTree(projectDir) { include(" Chart.yaml" , " values.yaml" , " ci/*.yaml" , " templates/**/*" ) }
110132 )
111133
112- outputs.file(outputFile)
134+ outputs.cacheIf { true }
113135 }
114136
115137// Task to build Docker images in minikube's Docker environment
@@ -120,43 +142,49 @@ val buildMinikubeImages by
120142
121143 workingDir = rootProject.projectDir
122144
123- // Output: file containing SHA digest of built image
124- val outputFile = helmTestReportsDir.get().file(" minikube-images.sha256" )
145+ val outputFile = helmTestReportsDir.get().file(" minikube-images/build.log" ).asFile
146+ val digestFile = helmTestReportsDir.get().file(" minikube-images/build.sha256" ).asFile
147+
148+ doFirst {
149+ outputFile.parentFile.mkdirs()
150+ digestFile.parentFile.mkdirs()
151+ val outStream = outputFile.outputStream()
152+ standardOutput = outStream
153+ errorOutput = outStream
154+ }
125155
126156 commandLine =
127157 listOf (
128158 " sh" ,
129159 " -c" ,
130160 """
131- # Check if minikube is running
161+ echo "====== Check if minikube is running ======"
132162 if ! minikube status >/dev/null 2>&1; then
133163 echo "Minikube is not running. Starting minikube..."
134164 minikube start
135165 fi
136166
137- # Set up docker environment and build images
167+ echo "====== Set up docker environment and build images ======"
138168 eval $(minikube -p minikube docker-env)
139169
140- # Build server image
170+ echo "====== Build server image ======"
141171 docker build -t apache/polaris:latest \
142172 -f runtime/server/src/main/docker/Dockerfile.jvm \
143173 runtime/server
144174
145- # Capture image digest
146- mkdir -p ${outputFile.asFile.parent}
147175 {
148176 docker inspect --format='{{.Id}}' apache/polaris:latest
149- } > ${outputFile.asFile }
177+ } > ${digestFile.relativeTo(workingDir) }
150178 """
151179 .trimIndent(),
152180 )
153181
154182 dependsOn(" :polaris-server:quarkusBuild" )
155183
156- inputs.dir(rootProject.file( " runtime/server/build/quarkus-app " ) )
157- inputs.file(rootProject.file( " runtime/ server/ src/main/docker/Dockerfile.jvm" ))
184+ inputs.files(runtimeServerDistribution )
185+ inputs.file(project( " :polaris- server" ).projectDir.resolve( " src/main/docker/Dockerfile.jvm" ))
158186
159- outputs.file(outputFile)
187+ outputs.cacheIf { true }
160188 }
161189
162190// Task to run chart-testing install on minikube
@@ -165,62 +193,74 @@ val chartTestingInstall by
165193 group = " verification"
166194 description = " Run chart-testing (install) on minikube"
167195
168- workingDir = rootProject.projectDir
196+ val outputFile = helmTestReportsDir.get().file( " ct/install.log " ).asFile
169197
170- val outputFile = helmTestReportsDir.get().file(" ct/install.log" )
198+ doFirst {
199+ outputFile.parentFile.mkdirs()
200+ val outStream = outputFile.outputStream()
201+ standardOutput = outStream
202+ errorOutput = outStream
203+ }
171204
172205 commandLine =
173206 listOf (
174207 " sh" ,
175208 " -c" ,
176209 """
177- mkdir -p ${outputFile.asFile.parent}
210+ echo "====== Check if minikube is running ======"
211+ if ! minikube status >/dev/null 2>&1; then
212+ echo "Minikube is not running. Starting minikube..."
213+ minikube start
214+ fi
178215
179- # Create namespace if it doesn't exist
180- kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f -
216+ echo "====== Create namespace if it doesn't exist ======"
217+ kubectl create namespace polaris-ns --dry-run=client -o yaml | kubectl apply -f -
181218
182- # Install fixtures
183- kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures
219+ echo "===== Install fixtures ======"
220+ kubectl apply --namespace polaris-ns -f helm/polaris/ci/fixtures
184221
185- # Run chart-testing install
186- ct install \
187- --namespace polaris-ns \
188- --debug --charts ./helm/polaris > ${outputFile.asFile} 2>&1
189- """
222+ echo "===== Run chart-testing install ======"
223+ ct install --namespace polaris-ns --debug --charts .
224+ """
190225 .trimIndent(),
191226 )
192227
228+ dependsOn(buildMinikubeImages)
229+
193230 inputs.files(
194231 fileTree(projectDir) { include(" Chart.yaml" , " values.yaml" , " ci/**/*" , " templates/**/*" ) }
195232 )
196233
197- outputs.file(outputFile)
198-
199- // Depend on the images being built in minikube
200- dependsOn(buildMinikubeImages)
234+ outputs.cacheIf { true }
201235 }
202236
203- // Task to generate helm documentation
204237val helmDocs by
205238 tasks.registering(Exec ::class ) {
206239 group = " documentation"
207240 description = " Generate Helm chart documentation using helm-docs"
208241
209- workingDir = rootProject.projectDir
242+ val outputFile = helmTestReportsDir.get().file(" helm-docs/build.log" ).asFile
243+
244+ doFirst {
245+ outputFile.parentFile.mkdirs()
246+ val outStream = outputFile.outputStream()
247+ standardOutput = outStream
248+ errorOutput = outStream
249+ }
210250
211251 commandLine =
212252 listOf (
213253 " sh" ,
214254 " -c" ,
215255 """
216- helm-docs --chart-search-root=helm
256+ helm-docs --chart-search-root=.
217257 """
218258 .trimIndent(),
219259 )
220260
221261 inputs.files(fileTree(projectDir) { include(" Chart.yaml" , " values.yaml" , " README.md.gotmpl" ) })
222262
223- outputs.file(projectDir.resolve( " README.md " ))
263+ outputs.cacheIf { true }
224264 }
225265
226266val test by
@@ -235,11 +275,9 @@ val intTest by
235275 group = " verification"
236276 description = " Run Helm chart integration tests on minikube"
237277 dependsOn(chartTestingInstall)
278+ mustRunAfter(test)
238279 }
239280
240- tasks.named(" check" ) { dependsOn(test) }
281+ tasks.named(" check" ) { dependsOn(test, intTest ) }
241282
242- tasks.named(" build" ) {
243- dependsOn(intTest)
244- dependsOn(helmDocs)
245- }
283+ tasks.named(" assemble" ) { dependsOn(helmDocs) }
0 commit comments