Merge pull request #106 from l0b0/feat/shellcheck

feat: ShellCheck
This commit is contained in:
Jörg Thalheim 2023-01-10 08:18:17 +01:00 committed by GitHub
commit bd435b2bc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 46 deletions

View file

@ -2,29 +2,31 @@ pull_request_rules:
- name: automatic merge on CI success
conditions:
- check-success=Evaluate flake.nix
- check-success=package disko [x86_64-linux]
- check-success=check boot-raid1 [x86_64-linux]
- check-success=check bcachefs [x86_64-linux]
- check-success=check luks-lvm [x86_64-linux]
- check-success=check mdadm [x86_64-linux]
- check-success=check lvm-luks-example-tsp-mount [x86_64-linux]
- check-success=package default [x86_64-linux]
- check-success=check lvm-luks-example-tsp-create [x86_64-linux]
- check-success=check cli [x86_64-linux]
- check-success=check boot-raid1 [x86_64-linux]
- check-success=check btrfs-subvolumes [x86_64-linux]
- check-success=check multi-device-no-deps [x86_64-linux]
- check-success=check negative-size [x86_64-linux]
- check-success=check swap [x86_64-linux]
- check-success=check module [x86_64-linux]
- check-success=check zfs [x86_64-linux]
- check-success=check zfs-over-legacy [x86_64-linux]
- check-success=check with-lib [x86_64-linux]
- check-success=check cli [x86_64-linux]
- check-success=check complex [x86_64-linux]
- check-success=check gpt-bios-compat [x86_64-linux]
- check-success=check luks-lvm [x86_64-linux]
- check-success=check lvm-luks-example-tsp-create [x86_64-linux]
- check-success=check lvm-luks-example-tsp-mount [x86_64-linux]
- check-success=check lvm-raid [x86_64-linux]
- check-success=check standalone [x86_64-linux]
- check-success=check tmpfs [x86_64-linux]
- check-success=check mdadm [x86_64-linux]
- check-success=check module [x86_64-linux]
- check-success=check multi-device-no-deps [x86_64-linux]
- check-success=check negative-size [x86_64-linux]
- check-success=check shellcheck [x86_64-linux]
- check-success=check simple-efi [x86_64-linux]
- check-success=check standalone [x86_64-linux]
- check-success=check swap [x86_64-linux]
- check-success=check tmpfs [x86_64-linux]
- check-success=check with-lib [x86_64-linux]
- check-success=check zfs [x86_64-linux]
- check-success=check zfs-over-legacy [x86_64-linux]
- check-success=package default [x86_64-linux]
- check-success=package disko [x86_64-linux]
- author=nix-eval-jobs-bot
actions:
merge:

View file

@ -1,28 +1,28 @@
cut_body_after = "" # don't include text from the PR body in the merge commit message
status = [
# garnix
"Evaluate flake.nix",
"package disko [x86_64-linux]",
"check boot-raid1 [x86_64-linux]",
"check bcachefs [x86_64-linux]",
"check luks-lvm [x86_64-linux]",
"check mdadm [x86_64-linux]",
"check lvm-luks-example-tsp-mount [x86_64-linux]",
"package default [x86_64-linux]",
"check lvm-luks-example-tsp-create [x86_64-linux]",
"check cli [x86_64-linux]",
"check boot-raid1 [x86_64-linux]",
"check btrfs-subvolumes [x86_64-linux]",
"check multi-device-no-deps [x86_64-linux]",
"check negative-size [x86_64-linux]",
"check swap [x86_64-linux]",
"check module [x86_64-linux]",
"check zfs [x86_64-linux]",
"check zfs-over-legacy [x86_64-linux]",
"check with-lib [x86_64-linux]",
"check cli [x86_64-linux]",
"check complex [x86_64-linux]",
"check gpt-bios-compat [x86_64-linux]",
"check luks-lvm [x86_64-linux]",
"check lvm-luks-example-tsp-create [x86_64-linux]",
"check lvm-luks-example-tsp-mount [x86_64-linux]",
"check lvm-raid [x86_64-linux]",
"check mdadm [x86_64-linux]",
"check module [x86_64-linux]",
"check multi-device-no-deps [x86_64-linux]",
"check negative-size [x86_64-linux]",
"check shellcheck [x86_64-linux]",
"check simple-efi [x86_64-linux]",
"check standalone [x86_64-linux]",
"check swap [x86_64-linux]",
"check tmpfs [x86_64-linux]",
"check simple-efi [x86_64-linux]"
"check with-lib [x86_64-linux]",
"check zfs [x86_64-linux]",
"check zfs-over-legacy [x86_64-linux]",
"package default [x86_64-linux]",
"package disko [x86_64-linux]"
]

View file

@ -3,4 +3,4 @@ set -efux
# dependencies: jq util-linux lvm2 mdadm zfs
disk=$1
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname $0)/disk-deactivate.jq"
lsblk --output-all --json | jq -r --arg disk_to_clear "$disk" -f "$(dirname "$0")/disk-deactivate.jq"

11
disko
View file

@ -6,9 +6,6 @@ readonly libexec_dir="${0%/*}"
# a file with the disko config
declare disko_config
# a flake uri, if present disko config is relative to the flake root
declare from_flake
# mount was chosen as the default mode because it's less destructive
mode=mount
nix_args=()
@ -90,11 +87,11 @@ while [[ $# -gt 0 ]]; do
shift
done
if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_mount" ]]); then
if ! { [[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_mount" ]]; }; then
abort "mode must be either create, mount or zap_create_mount"
fi
if [[ ! -z "${flake+x}" ]]; then
if [[ -n "${flake+x}" ]]; then
if [[ $flake =~ ^(.*)\#([^\#\"]*)$ ]]; then
flake="${BASH_REMATCH[1]}"
flakeAttr="${BASH_REMATCH[2]}"
@ -107,7 +104,7 @@ if [[ ! -z "${flake+x}" ]]; then
nix_args+=("--arg" "flake" "$flake")
nix_args+=("--argstr" "flakeAttr" "$flakeAttr")
nix_args+=(--extra-experimental-features flakes)
elif [[ ! -z "${disko_config+x}" ]] && [[ -e "$disko_config" ]]; then
elif [[ -n "${disko_config+x}" ]] && [[ -e "$disko_config" ]]; then
nix_args+=("--arg" "diskoFile" "$disko_config")
else
abort "disko config must be an existing file or flake must be set"
@ -118,7 +115,7 @@ script=$(nix-build "${libexec_dir}"/cli.nix \
--argstr mode "$mode" \
"${nix_args[@]}"
)
if [[ ! -z "${dry_run+x}" ]]; then
if [[ -n "${dry_run+x}" ]]; then
echo "$script"
else
exec "$script"

View file

@ -25,14 +25,20 @@
default = self.packages.${system}.disko;
});
# TODO: disable bios-related tests on aarch64...
# Run checks: nix flake check -L
checks = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in
# Run tests: nix flake check -L
import ./tests {
nixosTests = import ./tests {
inherit pkgs;
makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix");
eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix");
});
};
shellcheck = pkgs.runCommand "shellcheck" { nativeBuildInputs = [ pkgs.shellcheck ]; } ''
cd ${./.}
shellcheck disk-deactivate/disk-deactivate disko
touch $out
'';
in
nixosTests // { inherit shellcheck; });
};
}