patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <alyssa.ross@unikie.com>
To: devel@spectrum-os.org
Cc: Henri Rosten <henri.rosten@unikie.com>
Subject: [PATCH 2/2] release.nix: run shellcheck on build scripts
Date: Thu, 10 Nov 2022 11:22:20 +0000	[thread overview]
Message-ID: <20221110112219.459660-2-alyssa.ross@unikie.com> (raw)
In-Reply-To: <20221110112219.459660-1-alyssa.ross@unikie.com>

This will make the binary cache build (which I expect to become more
CI-like over time) fail if shellcheck doesn't pass on any shell
scripts found in the tree.  This will help ensure we are sticking to
POSIX shell features and following shell scripting best practices.

At present, only scripts with names ending in ".sh" are processed, as
we don't have any others, and discovering extensionless scripts would
be quite a bit more complex.  We can worry about that when the time
comes.

Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
---
 nix/checks.nix | 24 ++++++++++++++++++++++++
 release.nix    |  2 ++
 2 files changed, 26 insertions(+)
 create mode 100644 nix/checks.nix

diff --git a/nix/checks.nix b/nix/checks.nix
new file mode 100644
index 0000000..9eb261f
--- /dev/null
+++ b/nix/checks.nix
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: MIT
+# SPDX-FileCopyrightText: 2022 Unikie
+
+{ config ? import ../nix/eval-config.nix {} }:
+
+{
+  recurseForDerivations = true;
+
+  shellcheck = config.pkgs.callPackage (
+    { lib, runCommand, shellcheck }:
+    runCommand "spectrum-shellcheck" {
+      src = lib.cleanSourceWith {
+        filter = path: type:
+          type == "directory" || builtins.match ''.*[^/]\.sh'' path != null;
+        src = lib.cleanSource ../.;
+      };
+
+      nativeBuildInputs = [ shellcheck ];
+    } ''
+      shellcheck $src/**/*.sh
+      touch $out
+    ''
+  ) {};
+}
diff --git a/release.nix b/release.nix
index 91a843b..3ecf8a7 100644
--- a/release.nix
+++ b/release.nix
@@ -12,5 +12,7 @@
 {
   doc = import ./Documentation { inherit config; };
 
+  checks = import nix/checks.nix { inherit config; };
+
   combined = import img/combined/run-vm.nix { inherit config; };
 }
-- 
2.35.1



  reply	other threads:[~2022-11-10 11:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 11:22 [PATCH 1/2] scripts: fix shellcheck warnings Alyssa Ross
2022-11-10 11:22 ` Alyssa Ross [this message]
2022-11-10 13:40   ` [PATCH 2/2] release.nix: run shellcheck on build scripts Henri Rosten
2022-11-11 14:28   ` Alyssa Ross
2022-11-10 13:38 ` [PATCH 1/2] scripts: fix shellcheck warnings Henri Rosten
2022-11-11 14:28 ` Alyssa Ross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110112219.459660-2-alyssa.ross@unikie.com \
    --to=alyssa.ross@unikie.com \
    --cc=devel@spectrum-os.org \
    --cc=henri.rosten@unikie.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).