]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
GHA: add a checksrc job
authorDaniel Stenberg <daniel@haxx.se>
Wed, 21 Aug 2024 07:19:27 +0000 (09:19 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 22 Aug 2024 21:43:52 +0000 (23:43 +0200)
This job unconditionally runs checksrc on ALL .c and .h files present in
git.

checksrc.pl: fixed to look for ".checksrc" in the same directory from
where it loads the file to check so that it an be invoked like this

Closes #14625

.github/workflows/checksrc.yml [new file with mode: 0644]
scripts/checksrc.pl

diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml
new file mode 100644 (file)
index 0000000..0115bc5
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# SPDX-License-Identifier: curl
+
+name: checksrc
+
+on:
+  # Trigger the workflow on push or pull requests, but only for the
+  # master branch
+  push:
+    branches:
+      - master
+      - '*/ci'
+  pull_request:
+    branches:
+      - master
+
+permissions: {}
+
+jobs:
+  all:
+
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
+
+      - name: check
+        run: git ls-files "*.[ch]" | xargs -n1 ./scripts/checksrc.pl
index 75f68fbaaa85e353ce59069aad452534a60e7e4a..45897aad6f1beb565e765900274381f26ca86944 100755 (executable)
@@ -115,9 +115,20 @@ sub readskiplist {
 # and since that's already handled via !checksrc! commands there is probably
 # little use to add it.
 sub readlocalfile {
+    my ($file) = @_;
     my $i = 0;
+    my $rcfile;
 
-    open(my $rcfile, "<", "$dir/.checksrc") or return;
+    if(($dir eq ".") && $file =~ /\//) {
+        my $ldir;
+        if($file =~ /(.*)\//) {
+            $ldir = $1;
+            open($rcfile, "<", "$dir/$ldir/.checksrc") or return;
+        }
+    }
+    else {
+        open($rcfile, "<", "$dir/.checksrc") or return;
+    }
 
     while(<$rcfile>) {
         $windows_os ? $_ =~ s/\r?\n$// : chomp;
@@ -264,7 +275,7 @@ if(!$file) {
 }
 
 readskiplist();
-readlocalfile();
+readlocalfile($file);
 
 do {
     if("$wlist" !~ / $file /) {