Skip to content

Commit 3c58202

Browse files
committed
Review AI code
1 parent 03c0189 commit 3c58202

File tree

9 files changed

+110
-186
lines changed

9 files changed

+110
-186
lines changed

AGENTS.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,22 @@
2222
- In java, always import classes and use them without qualified names.
2323

2424
## Testing individual components
25-
```console
26-
# Clean previous build outputs for the selected coordinates
27-
./gradlew clean -Pcoordinates=[group:artifact:version|k/n|all]
28-
# Pre-fetch Docker images allowed by metadata (used in tests) for the selected coordinates
29-
./gradlew pullAllowedDockerImages -Pcoordinates=[group:artifact:version|k/n|all]
30-
# Validate reachability metadata files for the selected coordinates
31-
./gradlew checkMetadataFiles -Pcoordinates=[group:artifact:version|k/n|all]
32-
# Run Checkstyle for the selected coordinates
33-
./gradlew checkstyle -Pcoordinates=[group:artifact:version|k/n|all]
34-
# Compile test sources for the selected coordinates
35-
./gradlew compileTestJava -Pcoordinates=[group:artifact:version|k/n|all]
36-
# Run JVM-based tests for the selected coordinates
37-
./gradlew javaTest -Pcoordinates=[group:artifact:version|k/n|all]
38-
# Build native images used by native tests (compile-only) for the selected coordinates
39-
./gradlew nativeTestCompile -Pcoordinates=[group:artifact:version|k/n|all]
40-
# Run all tests for the selected coordinates
41-
./gradlew test -Pcoordinates=[group:artifact:version|k/n|all]
42-
```
4325

44-
### Check style and formatting
26+
- Clean previous build outputs for the selected coordinates: ./gradlew clean -Pcoordinates=[group:artifact:version|k/n|all]
27+
- Pre-fetch Docker images allowed by metadata (used in tests) for the selected coordinates: ./gradlew pullAllowedDockerImages -Pcoordinates=[group:artifact:version|k/n|all]
28+
- Validate reachability metadata files for the selected coordinates: ./gradlew checkMetadataFiles -Pcoordinates=[group:artifact:version|k/n|all]
29+
- Run Checkstyle for the selected coordinates: ./gradlew checkstyle -Pcoordinates=[group:artifact:version|k/n|all]
30+
- Compile test sources for the selected coordinates: ./gradlew compileTestJava -Pcoordinates=[group:artifact:version|k/n|all]
31+
- Run JVM-based tests for the selected coordinates: ./gradlew javaTest -Pcoordinates=[group:artifact:version|k/n|all]
32+
- Build native images used by native tests (compile-only) for the selected coordinates: ./gradlew nativeTestCompile -Pcoordinates=[group:artifact:version|k/n|all]
33+
- Run all tests for the selected coordinates: ./gradlew test -Pcoordinates=[group:artifact:version|k/n|all]
34+
35+
36+
## Check style and formatting
4537
- Style check: ./gradlew checkstyle
4638
- Format check: ./gradlew spotlessCheck
4739

48-
### Testing the metadata
40+
## Testing the metadata
4941
- Single library (replace with group:artifact:version):
5042
- ./gradlew pullAllowedDockerImages -Pcoordinates=group:artifact:version
5143
- ./gradlew checkMetadataFiles -Pcoordinates=group:artifact:version
@@ -55,18 +47,18 @@
5547
- ./gradlew checkMetadataFiles -Pcoordinates=1/64
5648
- ./gradlew test -Pcoordinates=1/64
5749

58-
### Docker Image Vulnerability Scanning
50+
## Docker Image Vulnerability Scanning
5951
- Changed images between commits:
6052
- ./gradlew checkAllowedDockerImages --baseCommit=$(git rev-parse origin/master) --newCommit=$(git rev-parse HEAD)
6153
- All allowed images:
6254
- ./gradlew checkAllowedDockerImages
6355

64-
### Compatibility Automation (latest library versions)
56+
##s Compatibility Automation (latest library versions)
6557
- List libs with newer upstream versions:
6658
- ./gradlew fetchExistingLibrariesWithNewerVersions --quiet
6759
- Record a newly tested version:
6860
- ./gradlew addTestedVersion -Pcoordinates="group:artifact:newVersion" --lastSupportedVersion="oldVersion"
6961
- Example: ./gradlew addTestedVersion -Pcoordinates="org.postgresql:postgresql:42.7.4" --lastSupportedVersion="42.7.3"
7062

71-
# Releases and Packaging
63+
## Releases and Packaging
7264
- Package artifacts: ./gradlew package

build.gradle

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,28 @@ ext.runLoggedCommand = { List<String> args, String label, File logFile, File wor
8787
return exit
8888
}
8989

90+
static List<Map> testAllCommands(String gradleCmd, String target) {
91+
def taskNames = [
92+
"checkstyle",
93+
"spotlessCheck",
94+
"checkMetadataFiles",
95+
"fetchExistingLibrariesWithNewerVersions",
96+
"test"
97+
]
98+
return taskNames.collect { name ->
99+
[name: name, args: [gradleCmd, name, "-Pcoordinates=${target}"]]
100+
}
101+
}
102+
90103
tasks.register('testAllParallel') { t ->
91104
t.group = "verification"
92-
t.setDescription("For each target, run clean and pullAllowedDockerImages first (sequentially), then run style checks and individual testing stages (checkstyle, spotlessCheck, checkMetadataFiles, compileTestJava, javaTest, nativeTestCompile, test) concurrently with isolated logs. Options: -Pcoordinates to specify a single coordinate or 1/64 for the pull step; -Pparallelism to control the number of concurrent tasks.")
105+
t.setDescription("For each target, run clean and pullAllowedDockerImages first (sequentially), then run style checks and individual testing stages (checkstyle, spotlessCheck, checkMetadataFiles, fetchExistingLibrariesWithNewerVersions, test) concurrently with isolated logs. Options: -Pcoordinates to specify a single coordinate or 1/64 for the pull step; -Pparallelism to control the number of concurrent tasks.")
93106

94107
doLast {
95108
def selectedArtifact = "org.postgresql:postgresql:42.7.3"
96-
def selectedCoord = "1/64"
109+
def selectedBatch = "1/64"
97110

98-
def logsDir = layout.buildDirectory.dir("command-logs").get().asFile
99-
logsDir.mkdirs()
100111
def gradleCmd = System.getProperty("os.name").toLowerCase().contains("windows") ? "gradlew.bat" : "./gradlew"
101-
// Determine parallelism: default is 4 if -Pparallelism=n is not provided
102112
def parallelismProp = (project.findProperty('parallelism') ?: '').toString().trim()
103113
int parallelism = 4
104114
if (!parallelismProp.isEmpty()) {
@@ -113,45 +123,42 @@ tasks.register('testAllParallel') { t ->
113123
}
114124
println("Using parallelism=${parallelism} for testAllParallel.")
115125

126+
def logsDir = layout.buildDirectory.dir("command-logs").get().asFile
127+
logsDir.mkdirs()
128+
116129
// Helper to run pull + command set for a given target (artifact or coordinates)
117-
def runPhaseForTarget = { String target ->
118-
// Clean project before pulling Docker images for this target
130+
def runPhaseForCoordinate = { String coordinate ->
131+
// Clean project before pulling Docker images for this coordinate
119132
def cleanLogsDir = new File(project.rootDir, "command-logs-clean")
120133
cleanLogsDir.mkdirs()
121-
def cleanLogFile = new File(cleanLogsDir, "clean-${target.replaceAll(File.separator, "-")}.log")
122-
int cleanExit = project.ext.runLoggedCommand([gradleCmd, "clean", "-Pcoordinates=${target}"], "clean (${target})", cleanLogFile, project.rootDir)
134+
135+
def fileSuffix = coordinate.replaceAll(File.separator, "-")
136+
def cleanLogFile = new File(cleanLogsDir, "clean-${fileSuffix}.log")
137+
int cleanExit = project.ext.runLoggedCommand([gradleCmd, "clean", "-Pcoordinates=${coordinate}"], "clean (${coordinate})", cleanLogFile, project.rootDir)
123138
if (cleanExit != 0) {
124139
throw new GradleException("clean failed with exit code ${cleanExit} (see ${cleanLogFile})")
125140
}
126141
// Ensure logsDir exists after clean
127142
logsDir.mkdirs()
128143

129-
// Pull Docker images sequentially for this target
130-
def pullArgs = [gradleCmd, "pullAllowedDockerImages", "-Pcoordinates=${target}"]
131-
def pullLogFile = new File(logsDir, "pullAllowedDockerImages-${target}.log")
132-
int pullExit = project.ext.runLoggedCommand(pullArgs, "pullAllowedDockerImages (${target})", pullLogFile, project.rootDir)
144+
// Pull Docker images sequentially for this coordinate
145+
def pullArgs = [gradleCmd, "pullAllowedDockerImages", "-Pcoordinates=${coordinate}"]
146+
def pullLogFile = new File(logsDir, "pullAllowedDockerImages-${fileSuffix}.log")
147+
int pullExit = project.ext.runLoggedCommand(pullArgs, "pullAllowedDockerImages (${coordinate})", pullLogFile, project.rootDir)
133148
if (pullExit != 0) {
134149
throw new GradleException("pullAllowedDockerImages failed with exit code ${pullExit} (see ${pullLogFile})")
135150
}
136151

137-
// Commands to run in parallel (style checks and individual testing stages) for this target
138-
def commands = [
139-
[name: "checkstyle", args: [gradleCmd, "checkstyle", "-Pcoordinates=${target}"]],
140-
[name: "spotlessCheck", args: [gradleCmd, "spotlessCheck", "-Pcoordinates=${target}"]],
141-
[name: "checkMetadataFiles", args: [gradleCmd, "checkMetadataFiles", "-Pcoordinates=${target}"]],
142-
[name: "fetchExistingLibrariesWithNewerVersions", args: [gradleCmd, "fetchExistingLibrariesWithNewerVersions", "-Pcoordinates=${target}"]],
143-
[name: "test", args: [gradleCmd, "test", "-Pcoordinates=${target}"]]
144-
]
145-
152+
def commands = testAllCommands(gradleCmd, coordinate)
146153
int effectiveParallelism = Math.min(parallelism, commands.size())
147154
def pool = Executors.newFixedThreadPool(effectiveParallelism)
148155
def failures = Collections.synchronizedList(new ArrayList<Map>())
149156
def futures = []
150157

151158
commands.each { cmd ->
152159
futures << pool.submit {
153-
def label = "${cmd.name} (${target})"
154-
def logFile = new File(logsDir, "${cmd.name}-${target}.log")
160+
def label = "${cmd.name} (${coordinate})"
161+
def logFile = new File(logsDir, "${cmd.name}-${fileSuffix}.log")
155162
int exit = project.ext.runLoggedCommand(cmd.args, label, logFile, project.rootDir)
156163
if (exit != 0) {
157164
failures.add([label: label, logFile: logFile, exit: exit])
@@ -164,11 +171,11 @@ tasks.register('testAllParallel') { t ->
164171
pool.awaitTermination(1, TimeUnit.HOURS)
165172

166173
if (!failures.isEmpty()) {
167-
println("Some commands failed (coordinates=${target}). Logs in: ${logsDir}")
174+
println("Some commands failed (coordinates=${coordinate}). Logs in: ${logsDir}")
168175
failures.each { f ->
169176
println(" - ${f.label} failed with exit code ${f.exit} (see ${f.logFile})")
170177
}
171-
println("==== BEGIN FAILED TASK LOGS (${target})")
178+
println("==== BEGIN FAILED TASK LOGS (${coordinate})")
172179
failures.each { f ->
173180
println("---- LOG: ${f.logFile}")
174181
try {
@@ -181,15 +188,15 @@ tasks.register('testAllParallel') { t ->
181188
println("Error reading ${f.logFile}: ${e.message}")
182189
}
183190
}
184-
println("==== END FAILED TASK LOGS (${target})")
191+
println("==== END FAILED TASK LOGS (${coordinate})")
185192
throw new GradleException("Failures encountered. See logs above. Logs directory: ${logsDir}")
186193
} else {
187-
println("All commands succeeded for coordinates=${target}. Logs in: ${logsDir}")
194+
println("All commands succeeded for coordinates=${coordinate}. Logs in: ${logsDir}")
188195
}
189196
}
190197

191-
// Run phases sequentially: first the selectedArtifact, then the selectedCoord
192-
runPhaseForTarget(selectedArtifact)
193-
runPhaseForTarget(selectedCoord)
198+
// Run parallel phases sequentially: first the selectedArtifact, then the selectedBatch
199+
runPhaseForCoordinate(selectedArtifact)
200+
runPhaseForCoordinate(selectedBatch)
194201
}
195202
}

docs/CI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
This repository uses GitHub Actions and Gradle-based checks to ensure metadata quality, stability, and automated releases.
44
Below is an overview of the CI pipelines and the configuration they rely on.
55

6-
- Source of truth for style checks: [gradle/checkstyle.xml](../gradle/checkstyle.xml)
76
- GitHub Actions workflows: [.github/workflows](../.github/workflows)/*.yml
7+
- Source of truth for style checks: [gradle/checkstyle.xml](../gradle/checkstyle.xml)
88

99
CI prefetches docker images and temporarily disables Docker networking for test isolation via [`.github/workflows/disable-docker.sh`](../.github/workflows/scripts/disable-docker.sh).
1010
You usually do not need this locally.

docs/DEVELOPING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ For a single coordinate, CI runs three steps in this order:
5353
3. Then run tests:
5454
```console
5555
./gradlew test -Pcoordinates=org.postgresql:postgresql:42.7.3
56-
```
56+
```
5757

5858
### Testing libraries in bulk
5959

@@ -105,18 +105,18 @@ Each stage of the testing can be run with `-Pcoordinates=[group:artifact:version
105105
These tasks support the scheduled workflow that checks newer upstream library versions and updates our metadata accordingly.
106106

107107
1. List supported libraries that have newer upstream versions
108-
```console
109-
./gradlew fetchExistingLibrariesWithNewerVersions --quiet
108+
```console
109+
./gradlew fetchExistingLibrariesWithNewerVersions --quiet
110110
```
111111

112112
2. Mark a new tested version for a library
113113
```console
114114
./gradlew addTestedVersion -Pcoordinates="group:artifact:newVersion" --lastSupportedVersion="oldVersion"
115115
```
116-
For example:
117-
```console
118-
./gradlew addTestedVersion -Pcoordinates="org.postgresql:postgresql:42.7.4" --lastSupportedVersion="42.7.3"
119-
```
116+
For example:
117+
```console
118+
./gradlew addTestedVersion -Pcoordinates="org.postgresql:postgresql:42.7.4" --lastSupportedVersion="42.7.3"
119+
```
120120

121121
### Releases and Packaging
122122

tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import org.graalvm.internal.tck.harness.tasks.NativeTestCompileInvocationTask
2727
import org.graalvm.internal.tck.harness.tasks.FetchExistingLibrariesWithNewerVersionsTask
2828
import org.gradle.util.internal.VersionNumber
2929
import org.graalvm.internal.tck.harness.tasks.ComputeAndPullAllowedDockerImagesTask
30-
import org.graalvm.internal.tck.utils.CoordinateUtils;
30+
import org.graalvm.internal.tck.utils.CoordinateUtils
3131

3232

3333
import static org.graalvm.internal.tck.Utils.generateTaskName
@@ -304,12 +304,9 @@ tasks.register("checkAllowedDockerImages", GrypeTask.class) { task ->
304304
task.setGroup(METADATA_GROUP)
305305
}
306306

307-
def imagesFileProvider = project.layout.buildDirectory.file("tck/required-docker-images.txt")
308-
309307
tasks.register("pullAllowedDockerImages", ComputeAndPullAllowedDockerImagesTask.class) { task ->
310308
task.setDescription("Computes and pulls allowed docker images required by matching coordinates")
311309
task.setGroup(METADATA_GROUP)
312-
task.getImagesFile().set(imagesFileProvider)
313310
}
314311

315312

tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/CleanInvocationTask.groovy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
* Copyright and related rights waived via CC0
3+
*
4+
* You should have received a copy of the CC0 legalcode along with this
5+
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
6+
*/
7+
18
package org.graalvm.internal.tck.harness.tasks
29

310
import org.gradle.api.tasks.Input

0 commit comments

Comments
 (0)