Repository: sqlfluff/sqlfluff
Issue category: Feature Request

Issue:
Include filename in visible GHA output
### Search before asking

- [X] I searched the [issues](https://github.com/sqlfluff/sqlfluff/issues) and found no similar issues.


### Description

When using `github-annotation-native` format, the raw output contains the filename
```
::warning title=SQLFluff,file=migrations/manual/20240912220714_foo.sql,line=2,col=1,endLine=2,endColumn=3::LT02: Line should not be indented. [layout.indent]
```
and the actual annotations work properly, however the output visible in the GH console doesn't show the filename, which makes it a little tricky from the console output. It might be a little redundant, but maybe the messagee should be prefixed with the filename (or else put the filename on top of each section the way we do in other output formats, if that won't confuse GH)

<img width="991" alt="image" src="https://github.com/user-attachments/assets/fd327745-c835-4c7e-85e8-943106c0e308">

### Use case

_No response_

### Dialect

postgres

### Are you willing to work on and submit a PR to address the issue?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/sqlfluff/sqlfluff/blob/main/CODE_OF_CONDUCT.md)



Hints:

Patch:
diff --git a/src/sqlfluff/cli/commands.py b/src/sqlfluff/cli/commands.py
index 894c39b3c45..84dddbe3aa5 100644
--- a/src/sqlfluff/cli/commands.py
+++ b/src/sqlfluff/cli/commands.py
@@ -715,6 +715,11 @@ def lint(
         github_result_native = []
         for record in result.as_records():
             filepath = record["filepath"]
+
+            # Add a group, titled with the filename
+            if record["violations"]:
+                github_result_native.append(f"::group::{filepath}")
+
             for violation in record["violations"]:
                 # NOTE: The output format is designed for GitHub action:
                 # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-notice-message
@@ -741,6 +746,10 @@ def lint(
 
                 github_result_native.append(line)
 
+            # Close the group
+            if record["violations"]:
+                github_result_native.append("::endgroup::")
+
         file_output = "\n".join(github_result_native)
 
     if file_output:


Test patch:
diff --git a/test/cli/commands_test.py b/test/cli/commands_test.py
index 823ada02985..34f3739aee9 100644
--- a/test/cli/commands_test.py
+++ b/test/cli/commands_test.py
@@ -1652,7 +1652,7 @@ def test__cli__command_lint_serialize_multiple_files(serialize, write_file, tmp_
         # SQLFluff produces trailing newline
         if result[-1] == "":
             del result[-1]
-        assert len(result) == 12
+        assert len(result) == 16
     else:
         raise Exception
 
@@ -1778,6 +1778,7 @@ def test__cli__command_lint_serialize_github_annotation():
         (
             "test/fixtures/linter/identifier_capitalisation.sql",
             (
+                "::group::{filename}\n"
                 "::error title=SQLFluff,file={filename},"
                 "line=3,col=5,endLine=3,endColumn=8::"
                 "RF02: Unqualified reference 'foo' found in select with more than one "
@@ -1805,12 +1806,14 @@ def test__cli__command_lint_serialize_github_annotation():
                 "line=5,col=18,endLine=5,endColumn=22::"
                 "CP02: Unquoted identifiers must be consistently lower case. "
                 "[capitalisation.identifiers]\n"
+                "::endgroup::\n"
                 # SQLFluff produces trailing newline
             ),
         ),
         (
             "test/fixtures/linter/jinja_spacing.sql",
             (
+                "::group::{filename}\n"
                 "::error title=SQLFluff,file={filename},"
                 "line=3,col=15,endLine=3,endColumn=22::JJ01: "
                 "Jinja tags should have a single whitespace on either "
@@ -1818,6 +1821,7 @@ def test__cli__command_lint_serialize_github_annotation():
                 # .format() method.
                 "side: {{{{foo}}}} "
                 "[jinja.padding]\n"
+                "::endgroup::\n"
             ),
         ),
     ],
@@ -1843,7 +1847,6 @@ def test__cli__command_lint_serialize_github_annotation_native(
         ],
         ret_code=1,
     )
-
     assert result.output == expected_output.format(filename=fpath_normalised)