Skip to content

Commit 9070130

Browse files
committed
review
1 parent 724fd32 commit 9070130

File tree

6 files changed

+135
-70
lines changed

6 files changed

+135
-70
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
./gradlew \
216216
intTest \
217217
-x :polaris-runtime-service:intTest \
218-
-x :polaris-helm:intTest \
218+
-x :polaris-helm:check \
219219
--continue
220220
env:
221221
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@ These tools are required for basic building and testing:
133133
* [SDKMAN!](https://sdkman.io/) - Run `sdk list java` to see available distributions, then `sdk install java <identifier>` to install.
134134
* [jEnv](https://www.jenv.be/) - You can also use jEnv to manage Java versions.
135135

136-
* **Docker**: Required for integration tests and building container images.
136+
* **Container Runtime**: A container runtime like [Docker] or [Podman] is required for integration tests, regression tests
137+
and building container images.
138+
139+
[Docker]: https://www.docker.com/
140+
[Podman]: https://podman.io/
137141

138142
### Helm Chart Testing Requirements
139143

helm/polaris/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ weight: 675
2828
Do not modify the README.md file directly, please modify README.md.gotmpl instead.
2929
To re-generate the README.md file, install helm-docs then run from the repo root:
3030
helm-docs --chart-search-root=helm
31-
Alternatively, run ./gradlew helmDocs from the repo root.
31+
Alternatively, run `./gradlew helmDocs` or `make helm-doc-generate` from the repo root.
3232
-->
3333

3434
![Version: 1.2.0-incubating-SNAPSHOT](https://img.shields.io/badge/Version-1.2.0--incubating--SNAPSHOT-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0-incubating-SNAPSHOT](https://img.shields.io/badge/AppVersion-1.2.0--incubating--SNAPSHOT-informational?style=flat-square)
@@ -142,7 +142,13 @@ The following tools are required to run the tests:
142142
* [Helm Unit Test](https://github.com/helm-unittest/helm-unittest)
143143
* [Chart Testing](https://github.com/helm/chart-testing)
144144

145-
Quick installation of all required tools on macOS:
145+
Quick installation instructions for these tools:
146+
```bash
147+
helm plugin install https://github.com/helm-unittest/helm-unittest.git
148+
brew install chart-testing
149+
```
150+
151+
Alternatively, on macOS, you can also run the following make targets:
146152

147153
```bash
148154
make install-dependencies-brew
@@ -183,7 +189,7 @@ Integration tests are run with the Chart Testing tool:
183189
ct install --namespace polaris --charts ./helm/polaris
184190
```
185191

186-
### Running tets with Gradle
192+
### Running tests with Gradle
187193

188194
Both unit and integration tests can be run with Gradle. From the Polaris repo root:
189195

helm/polaris/README.md.gotmpl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ weight: 675
2828
Do not modify the README.md file directly, please modify README.md.gotmpl instead.
2929
To re-generate the README.md file, install helm-docs then run from the repo root:
3030
helm-docs --chart-search-root=helm
31-
Alternatively, run ./gradlew helmDocs from the repo root.
31+
Alternatively, run `./gradlew helmDocs` or `make helm-doc-generate` from the repo root.
3232
-->
3333

3434
{{ template "chart.deprecationWarning" . }}
@@ -144,7 +144,13 @@ The following tools are required to run the tests:
144144
* [Helm Unit Test](https://github.com/helm-unittest/helm-unittest)
145145
* [Chart Testing](https://github.com/helm/chart-testing)
146146

147-
Quick installation of all required tools on macOS:
147+
Quick installation instructions for these tools:
148+
```bash
149+
helm plugin install https://github.com/helm-unittest/helm-unittest.git
150+
brew install chart-testing
151+
```
152+
153+
Alternatively, on macOS, you can also run the following make targets:
148154

149155
```bash
150156
make install-dependencies-brew
@@ -185,7 +191,7 @@ Integration tests are run with the Chart Testing tool:
185191
ct install --namespace polaris --charts ./helm/polaris
186192
```
187193

188-
### Running tets with Gradle
194+
### Running tests with Gradle
189195

190196
Both unit and integration tests can be run with Gradle. From the Polaris repo root:
191197

helm/polaris/build.gradle.kts

Lines changed: 97 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -24,92 +24,114 @@ plugins {
2424

2525
description = "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+
2735
val helmTestReportsDir = layout.buildDirectory.dir("reports")
2836

2937
val 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

5971
val 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

88106
val 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
204237
val 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

226266
val 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

Comments
 (0)