From 87027faf9c65219a06fd0b11eb97dd225c394086 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Wed, 13 Nov 2024 14:38:14 +0100 Subject: [PATCH 1/2] Group unsupported libraries --- .../workflows/check-new-library-versions.yml | 15 +++++ .../org.graalvm.internal.tck-harness.gradle | 6 ++ .../tasks/GroupUnsupportedLibraries.groovy | 58 +++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy diff --git a/.github/workflows/check-new-library-versions.yml b/.github/workflows/check-new-library-versions.yml index d88780c8f..dafdff660 100644 --- a/.github/workflows/check-new-library-versions.yml +++ b/.github/workflows/check-new-library-versions.yml @@ -135,6 +135,11 @@ jobs: steps: - name: "☁️ Checkout repository" uses: actions/checkout@v4 + - name: "🔧 Setup java" + uses: actions/setup-java@v4 + with: + distribution: 'oracle' + java-version: '21' - name: "✏️ PR for supported versions" run: | git config --local user.email "actions@github.com" @@ -142,3 +147,13 @@ jobs: git fetch origin check-new-library-versions/$(date '+%Y-%m-%d') git checkout check-new-library-versions/$(date '+%Y-%m-%d') gh pr create --title "Update supported library versions" --body "This pull request updates supported versions of the existing libraries in the repo" + - name: "✏️ Edit issue for unsupported versions" + run: | + git config --local user.email "actions@github.com" + git config --local user.name "Github Actions" + ALL_COMMENTS=$(gh issue view "${{ needs.get-all-libraries.outputs.issue }}" --comments) + + FORMATTED_BODY=$(./gradlew -q extractLibrariesGroupsFromGithubComments --comments="$ALL_COMMENTS") + gh issue create --title "List unsupported libraries versions" --body "$FORMATTED_BODY" + + gh issue close "${{ needs.get-all-libraries.outputs.issue }}" diff --git a/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle b/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle index e26864c9b..2bcf43e34 100644 --- a/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle +++ b/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle @@ -17,6 +17,7 @@ import org.graalvm.internal.tck.GrypeTask import org.graalvm.internal.tck.TestedVersionUpdaterTask import org.graalvm.internal.tck.harness.tasks.CheckstyleInvocationTask import org.graalvm.internal.tck.harness.tasks.FetchExistingLibrariesWithNewerVersionsTask +import org.graalvm.internal.tck.harness.tasks.GroupUnsupportedLibraries import org.graalvm.internal.tck.harness.tasks.TestInvocationTask @@ -170,6 +171,11 @@ tasks.register("fetchExistingLibrariesWithNewerVersions", FetchExistingLibraries task.setAllLibraryCoordinates(matchingCoordinates) } +tasks.register("extractLibrariesGroupsFromGithubComments", GroupUnsupportedLibraries.class) { task -> + task.setGroup(METADATA_GROUP) + task.setDescription("Extracts groups of libraries from githu comments provided in a form of string.") +} + // java tasks tasks.register("checkAllowedDockerImages", GrypeTask.class) { task -> task.setDescription("Returns list of allowed docker images") diff --git a/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy b/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy new file mode 100644 index 000000000..ba72ada9f --- /dev/null +++ b/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy @@ -0,0 +1,58 @@ +package org.graalvm.internal.tck.harness.tasks + +import org.gradle.api.DefaultTask +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.options.Option +import org.gradle.util.internal.VersionNumber + +import java.util.regex.Matcher +import java.util.regex.Pattern + +abstract class GroupUnsupportedLibraries extends DefaultTask { + + @Input + @Option(option = "comments", description = "Provides a string that contains github comments for library grouping.") + abstract Property getGithubComments() + + @TaskAction + void action() { + Pattern pattern = Pattern.compile("--[\n ](.*?)[\n ]--") + Matcher matcher = pattern.matcher(getGithubComments().get()) + + Map> libraryGroups = new HashMap>() + while (matcher.find()) { + String coordinates = matcher.group(1) + String[] coordinatesPart = coordinates.split(":") + String artifactKey = coordinatesPart[0] + ":" + coordinatesPart[1] + String version = coordinatesPart[2] + + if (libraryGroups.get(artifactKey) == null) { + libraryGroups.put(artifactKey, new ArrayList()) + } + + libraryGroups.get(artifactKey).add(version) + libraryGroups.get(artifactKey).sort(Comparator.comparing(VersionNumber::parse)) + } + + print generateGroupedComment(libraryGroups) + } + + private static String generateGroupedComment(Map> groups) { + StringBuilder sb = new StringBuilder("List of all unsupported libraries:\n") + + for (String library : groups.keySet()) { + sb.append("- ").append(library).append(":\n") + + for (String version : groups.get(library)) { + sb.append("\t").append("- ").append(version).append("\n") + } + + sb.append("\n") + } + + return sb.toString() + } + +} From 5a422dfcb318edbf16c7813adb9347171a74d968 Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Wed, 13 Nov 2024 17:30:10 +0100 Subject: [PATCH 2/2] Use def instead of actual types --- .../org.graalvm.internal.tck-harness.gradle | 2 +- .../tasks/GroupUnsupportedLibraries.groovy | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle b/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle index 2bcf43e34..c529e8f2b 100644 --- a/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle +++ b/tests/tck-build-logic/src/main/groovy/org.graalvm.internal.tck-harness.gradle @@ -173,7 +173,7 @@ tasks.register("fetchExistingLibrariesWithNewerVersions", FetchExistingLibraries tasks.register("extractLibrariesGroupsFromGithubComments", GroupUnsupportedLibraries.class) { task -> task.setGroup(METADATA_GROUP) - task.setDescription("Extracts groups of libraries from githu comments provided in a form of string.") + task.setDescription("Extracts groups of libraries from github comments provided in a form of string.") } // java tasks diff --git a/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy b/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy index ba72ada9f..aaa4974f8 100644 --- a/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy +++ b/tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/GroupUnsupportedLibraries.groovy @@ -13,20 +13,20 @@ import java.util.regex.Pattern abstract class GroupUnsupportedLibraries extends DefaultTask { @Input - @Option(option = "comments", description = "Provides a string that contains github comments for library grouping.") + @Option(option = "comments", description = "Provides github comments for library grouping as string.") abstract Property getGithubComments() @TaskAction void action() { - Pattern pattern = Pattern.compile("--[\n ](.*?)[\n ]--") - Matcher matcher = pattern.matcher(getGithubComments().get()) + def pattern = Pattern.compile("--[\n ](.*?)[\n ]--") + def matcher = pattern.matcher(getGithubComments().get()) - Map> libraryGroups = new HashMap>() + def libraryGroups = new HashMap>() while (matcher.find()) { - String coordinates = matcher.group(1) - String[] coordinatesPart = coordinates.split(":") - String artifactKey = coordinatesPart[0] + ":" + coordinatesPart[1] - String version = coordinatesPart[2] + def coordinates = matcher.group(1) + def coordinatesPart = coordinates.split(":") + def artifactKey = coordinatesPart[0] + ":" + coordinatesPart[1] + def version = coordinatesPart[2] if (libraryGroups.get(artifactKey) == null) { libraryGroups.put(artifactKey, new ArrayList()) @@ -40,7 +40,7 @@ abstract class GroupUnsupportedLibraries extends DefaultTask { } private static String generateGroupedComment(Map> groups) { - StringBuilder sb = new StringBuilder("List of all unsupported libraries:\n") + def sb = new StringBuilder("List of all unsupported libraries:\n") for (String library : groups.keySet()) { sb.append("- ").append(library).append(":\n")