From 388dfd8b5e28c84412a862c5fa130581c5402996 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 10 Jan 2023 17:01:28 +1300 Subject: [PATCH 1/9] fix: Remove unreferenced variable declaration --- disko | 3 --- 1 file changed, 3 deletions(-) diff --git a/disko b/disko index 7e4f0bf..dadaa33 100755 --- a/disko +++ b/disko @@ -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=() From 148ac4c2613b8e71a4b451bb3c04a6e998faffbd Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 10 Jan 2023 17:01:52 +1300 Subject: [PATCH 2/9] refactor: Use `-n` instead of `! -z` As recommended by ShellCheck. --- disko | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/disko b/disko index dadaa33..f361ebb 100755 --- a/disko +++ b/disko @@ -91,7 +91,7 @@ if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_ 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]}" @@ -104,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" @@ -115,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" From 077ff277dad353210992e916ff1facca09aeef59 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 10 Jan 2023 17:02:11 +1300 Subject: [PATCH 3/9] refactor: Use command grouping rather than subshell As recommended by ShellCheck. --- disko | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disko b/disko index f361ebb..10e2fc2 100755 --- a/disko +++ b/disko @@ -87,7 +87,7 @@ 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 From 4553130780070574b82a08bd466075b0fd2f69c5 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 10 Jan 2023 17:02:29 +1300 Subject: [PATCH 4/9] fix: Quote variable reference As recommended by ShellCheck. --- disk-deactivate/disk-deactivate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk-deactivate/disk-deactivate b/disk-deactivate/disk-deactivate index 7dcd753..c569690 100755 --- a/disk-deactivate/disk-deactivate +++ b/disk-deactivate/disk-deactivate @@ -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" From 5a4d706e521a09682510fa2023f50a400856adf8 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 10 Jan 2023 17:02:55 +1300 Subject: [PATCH 5/9] feat: Run ShellCheck on shell scripts Closes #85. --- .github/workflows/test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ba736f2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,18 @@ +name: test +on: + workflow_dispatch: + pull_request: + types: [opened, reopened, synchronize] + +jobs: + lint: + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v3.2.0 + - name: Install Nix + uses: cachix/install-nix-action@v18 + with: + extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + - name: ShellCheck + run: nix-shell --packages git shellcheck --pure --run 'shellcheck disk-deactivate/disk-deactivate disko' From a6a7ccbc9bdbdc45cd4e7316228d0213cf0d3dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 10 Jan 2023 08:05:45 +0100 Subject: [PATCH 6/9] add shellcheck to flake instead --- .github/workflows/test.yml | 18 ------------------ flake.nix | 14 ++++++++++---- 2 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ba736f2..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: test -on: - workflow_dispatch: - pull_request: - types: [opened, reopened, synchronize] - -jobs: - lint: - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v3.2.0 - - name: Install Nix - uses: cachix/install-nix-action@v18 - with: - extra_nix_config: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - - name: ShellCheck - run: nix-shell --packages git shellcheck --pure --run 'shellcheck disk-deactivate/disk-deactivate disko' diff --git a/flake.nix b/flake.nix index cd22b53..2137583 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }); }; } From 40516cfd68a234927fcbcd7a04623577eb75dfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 10 Jan 2023 08:11:05 +0100 Subject: [PATCH 7/9] update bors.toml --- bors.toml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/bors.toml b/bors.toml index 5a95260..ef528ca 100644 --- a/bors.toml +++ b/bors.toml @@ -1,28 +1,29 @@ + 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]" ] From bd27a2e9d4146d38b9e7d72772c40eb472c4aeaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 10 Jan 2023 08:14:04 +0100 Subject: [PATCH 8/9] bors.toml: drop leading line --- bors.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/bors.toml b/bors.toml index ef528ca..2c01556 100644 --- a/bors.toml +++ b/bors.toml @@ -1,4 +1,3 @@ - cut_body_after = "" # don't include text from the PR body in the merge commit message status = [ "Evaluate flake.nix", From 2584fb5b82c8d888d8d7301fc8e3b9787917c46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 10 Jan 2023 08:17:07 +0100 Subject: [PATCH 9/9] update mergify --- .mergify.yml | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/.mergify.yml b/.mergify.yml index 05fd84b..94dff70 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -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: