From c65bdcfc79e984b7a12965d1065543cf7df7b025 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 23 Jun 2025 21:13:19 -0400 Subject: [PATCH] test the github format --- .../lucene/gradle/plugins/astgrep/AstGrepPlugin.java | 11 +++++++++-- lucene/core/src/test/org/apache/lucene/TestDemo.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java index 315210d04284..d0310512f510 100644 --- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java +++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java @@ -17,6 +17,8 @@ package org.apache.lucene.gradle.plugins.astgrep; import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension; + +import java.util.ArrayList; import java.util.List; import org.gradle.api.GradleException; import org.gradle.api.Plugin; @@ -67,9 +69,14 @@ public void apply(Project project) { optionName); } + var args = new ArrayList(); // fail on any rule match regardless of severity level - task.setArgs( - List.of("scan", "-c", "gradle/validation/ast-grep/sgconfig.yml", "--error")); + args.addAll(List.of("scan", "-c", "gradle/validation/ast-grep/sgconfig.yml", "--error")); + // use the github format when being run as a workflow + if (System.getenv("CI") != null && System.getenv("GITHUB_WORKFLOW") != null) { + args.addAll(List.of("--format", "github")); + } + task.setArgs(args); }); // Common configuration. diff --git a/lucene/core/src/test/org/apache/lucene/TestDemo.java b/lucene/core/src/test/org/apache/lucene/TestDemo.java index 9f6f880e1dcf..8075f6ff5328 100644 --- a/lucene/core/src/test/org/apache/lucene/TestDemo.java +++ b/lucene/core/src/test/org/apache/lucene/TestDemo.java @@ -51,7 +51,7 @@ public void testDemo() throws IOException { "longtermlongtermlongtermlongtermlongtermlongtermlongtermlong" + "termlongtermlongtermlongtermlongtermlongtermlongtermlongterm" + "longtermlongtermlongterm"; - String text = "This is the text to be indexed. " + longTerm; + String text = "This is the text to be indexed. " + longTerm.substring(0); Path indexPath = Files.createTempDirectory("tempIndex"); try (Directory dir = FSDirectory.open(indexPath)) {