git: dbee52c9d600 - main - Connect my checkstyle9.pl script to a action.

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 06 Jan 2024 23:23:31 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=dbee52c9d6009539992b19c649cdfb4352921b61

commit dbee52c9d6009539992b19c649cdfb4352921b61
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-01-06 15:20:17 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-01-06 23:23:14 +0000

    Connect my checkstyle9.pl script to a action.
    
    Connect the checkstyle9.pl script to a github action. This will provide
    feedback to people submitting changes when the style is grossly wrong. And
    can provide other automated feedback for the commit message in the future.
    It already catches the github noreply author.
    
    It pulls the full repo to do this. Optimizations welcome. After messing
    with that for a few hours, I decided to punt and commit the slow, working
    version and let someone else optimize from here.
    
    Sponsored by:           Netflix
---
 .github/workflows/style.yml | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml
new file mode 100644
index 000000000000..a84d32b65c04
--- /dev/null
+++ b/.github/workflows/style.yml
@@ -0,0 +1,40 @@
+name: Style Checker
+
+# Runs my simple style(9) checker on any pushes or pull requests.  It could be
+# optimized by fetching the pull request head branch back to main revisions and
+# running on that. That would reduce the run time from 3-4 minutes down to 30-40
+# seconds. Getting the right series of clone + fetches to get that iteratively
+# is proving elusive, so optimizations welcome.
+
+on:
+  push:
+    branches: [ main, 'stable/13', 'stable/14' ]
+  pull_request: # maybe pull_request_target
+    branches: [ main ]
+    types: [ opened, reopened, edited ]
+
+permissions:
+  contents: read
+
+jobs:
+  build:
+    name: Style Checker
+    runs-on: ubuntu-latest
+    steps:
+      - name: checkout
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          ref: ${{ github.event.pull_request.head.sha }}
+      - name: Dump GitHub context
+        env:
+          GITHUB_CONTEXT: ${{ toJson(github) }}
+        run: echo "$GITHUB_CONTEXT"
+      - name: Install packages
+        run: |
+          sudo apt-get update --quiet || true
+          sudo apt-get -yq --no-install-suggests --no-install-recommends install perl
+      - name: Run checker
+        run: |
+          sha=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
+          tools/build/checkstyle9.pl ${sha}..${{ github.event.pull_request.head.sha }}