Skip to content

Commit 99b10c8

Browse files
authored
ci: enable gh annotations with ast-grep (#14840)
Error is still printed to console, but in a special structured format recognized by actions to highlight and annotate the problem in your PR. When clicking the build failure, annotations can be seen at the very top of action link (no need to look at logs). Github does highlight the failures in red in the logs as well. You can see the problems annotated inline in the sources, when reviewing the changes.
1 parent 9936b20 commit 99b10c8

File tree

1 file changed

+8
-1
lines changed
  • build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep

1 file changed

+8
-1
lines changed

build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/astgrep/AstGrepPlugin.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.lucene.gradle.plugins.astgrep;
1818

1919
import com.carrotsearch.gradle.buildinfra.buildoptions.BuildOptionsExtension;
20+
import java.util.ArrayList;
2021
import java.util.List;
2122
import org.gradle.api.GradleException;
2223
import org.gradle.api.Plugin;
@@ -67,9 +68,15 @@ public void apply(Project project) {
6768
optionName);
6869
}
6970

71+
var args = new ArrayList<String>();
7072
// fail on any rule match regardless of severity level
71-
task.setArgs(
73+
args.addAll(
7274
List.of("scan", "-c", "gradle/validation/ast-grep/sgconfig.yml", "--error"));
75+
// use the github format when being run as a workflow
76+
if (System.getenv("CI") != null && System.getenv("GITHUB_WORKFLOW") != null) {
77+
args.addAll(List.of("--format", "github"));
78+
}
79+
task.setArgs(args);
7380
});
7481

7582
// Common configuration.

0 commit comments

Comments
 (0)