Skip to content

Commit

Permalink
Group unsupported libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
dnestoro committed Nov 13, 2024
1 parent 6d740fe commit 87027fa
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/check-new-library-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,25 @@ 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 "[email protected]"
git config --local user.name "Github Actions"
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 "[email protected]"
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 }}"
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> getGithubComments()

@TaskAction
void action() {
Pattern pattern = Pattern.compile("--[\n ](.*?)[\n ]--")
Matcher matcher = pattern.matcher(getGithubComments().get())

Map<String, List<String>> libraryGroups = new HashMap<String, List<String>>()
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<String>())
}

libraryGroups.get(artifactKey).add(version)
libraryGroups.get(artifactKey).sort(Comparator.comparing(VersionNumber::parse))
}

print generateGroupedComment(libraryGroups)
}

private static String generateGroupedComment(Map<String, List<String>> 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()
}

}

0 comments on commit 87027fa

Please sign in to comment.