diff --git a/.github/workflows/demo.yml b/.github/workflows/demo.yml deleted file mode 100644 index a8b0913..0000000 --- a/.github/workflows/demo.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: "Demo" -on: - pull_request: - push: - branches: [ "main" ] -jobs: - # We're just checking if the demo start without hiccup. - test: - runs-on: ubuntu-latest - strategy: - matrix: - demo: - - homeassistant#basic - - homeassistant#ldap - - nextcloud#basic - - nextcloud#ldap - - nextcloud#sso - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: "system-features = nixos-test benchmark big-parallel kvm" - - name: Setup Caching - uses: cachix/cachix-action@v14 - with: - name: selfhostblocks - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Test demos - # See https://blog.stefan-koch.name/2020/12/10/qemu-guest-graceful-shutdown-from-python for - # inspiration. - run: | - set -x - - rm -f nixos.qcow2 - nix run nixpkgs#nixos-rebuild -- build-vm --flake ./demo/${{ matrix.demo }} - QEMU_NET_OPTS="hostfwd=tcp::8080-:80" ./result/bin/run-nixos-vm -nographic -qmp unix:/tmp/qmp-sock,server,nowait & - - nix run nixpkgs#socat -- - unix-connect:/tmp/qmp-sock <- - ${{ - contains(needs.*.result, 'failure') - || contains(needs.*.result, 'cancelled') - || contains(needs.*.result, 'skipped') - }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 3542141..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: "Documentation" -on: - pull_request: -jobs: - gen: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: "system-features = nixos-test benchmark big-parallel kvm" - - name: Setup Caching - uses: cachix/cachix-action@v14 - with: - name: selfhostblocks - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Test building docs - run: | - nix \ - --print-build-logs \ - --option keep-going true \ - --show-trace \ - build .#manualHtml diff --git a/.github/workflows/garnix.yaml b/.github/workflows/garnix.yaml new file mode 100644 index 0000000..7052000 --- /dev/null +++ b/.github/workflows/garnix.yaml @@ -0,0 +1,20 @@ +name: "Final Results" + +on: + check_suite: + types: [completed] + +jobs: + results: + name: Final Results + runs-on: ubuntu-latest + steps: + - run: echo + - run: exit 1 + # see https://stackoverflow.com/a/67532120/4907315 + if: >- + ${{ + contains(needs.*.result, 'failure') + || contains(needs.*.result, 'cancelled') + || contains(needs.*.result, 'skipped') + }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index fb3a11c..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: "Test" -on: - pull_request: - push: - branches: [ "main" ] -jobs: - tests: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: "system-features = nixos-test benchmark big-parallel kvm" - - name: Setup Caching - uses: cachix/cachix-action@v14 - with: - name: selfhostblocks - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Run tests - run: | - nix run github:Mic92/nix-fast-build -- \ - --skip-cached --no-nom \ - --max-jobs 1 \ - --flake ".#checks.$(nix eval --raw --impure --expr builtins.currentSystem)" diff --git a/README.md b/README.md index 281aa8a..8f136c9 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![Tests](https://github.com/ibizaman/selfhostblocks/actions/workflows/test.yml/badge.svg)](https://github.com/ibizaman/selfhostblocks/actions/workflows/test.yml) [![Demo](https://github.com/ibizaman/selfhostblocks/actions/workflows/demo.yml/badge.svg)](https://github.com/ibizaman/selfhostblocks/actions/workflows/demo.yml) [![Documentation](https://github.com/ibizaman/selfhostblocks/actions/workflows/docs.yml/badge.svg)](https://github.com/ibizaman/selfhostblocks/actions/workflows/docs.yml) +[![Tests](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fgarnix.io%2Fapi%2Fbadges%2Fibizaman%2Fselfhostblocks)](https://garnix.io) (using Garnix) SHB's (Self Host Blocks) is yet another server management tool whose goal is to provide a lower entry-bar for self-hosting. SHB provides opinionated [building blocks](#available-blocks) fitting diff --git a/modules/services/nextcloud-server.nix b/modules/services/nextcloud-server.nix index 197f251..eaba074 100644 --- a/modules/services/nextcloud-server.nix +++ b/modules/services/nextcloud-server.nix @@ -608,7 +608,7 @@ in environment.systemPackages = [ # Needed for a few apps. Would be nice to avoid having to put that in the environment and instead override https://github.com/NixOS/nixpkgs/blob/261abe8a44a7e8392598d038d2e01f7b33cf26d0/nixos/modules/services/web-apps/nextcloud.nix#L1035 - pkgs.ffmpeg + pkgs.ffmpeg-headless # Needed for the recognize app. pkgs.nodejs diff --git a/test/vm/arr.nix b/test/vm/arr.nix index d1c4678..264e6fd 100644 --- a/test/vm/arr.nix +++ b/test/vm/arr.nix @@ -1,5 +1,6 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; # TODO: Test login commonTestScript = appname: { nodes, ... }: let @@ -44,7 +45,7 @@ let raise Exception(f"Code is {response['code']}") ''; - basic = appname: pkgs.nixosTest { + basic = appname: pkgs.testers.runNixOSTest { name = "arr-${appname}-basic"; nodes.server = { config, pkgs, ... }: { @@ -58,6 +59,8 @@ let ../../modules/blocks/postgresql.nix ../../modules/blocks/nginx.nix ../../modules/services/arr.nix + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ]; shb.arr.${appname} = { diff --git a/test/vm/audiobookshelf.nix b/test/vm/audiobookshelf.nix index 7d035fc..795be7c 100644 --- a/test/vm/audiobookshelf.nix +++ b/test/vm/audiobookshelf.nix @@ -1,5 +1,7 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; + # TODO: Test login commonTestScript = { nodes, ... }: let @@ -38,11 +40,13 @@ let ''; in { - basic = pkgs.nixosTest { + basic = pkgs.testers.runNixOSTest { name = "audiobookshelf-basic"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -66,11 +70,13 @@ in testScript = commonTestScript; }; - cert = pkgs.nixosTest { + cert = pkgs.testers.runNixOSTest { name = "audiobookshelf-cert"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -115,11 +121,13 @@ in testScript = commonTestScript; }; - sso = pkgs.nixosTest { + sso = pkgs.testers.runNixOSTest { name = "audiobookshelf-sso"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; diff --git a/test/vm/authelia.nix b/test/vm/authelia.nix index 45d3cc6..d6fdda9 100644 --- a/test/vm/authelia.nix +++ b/test/vm/authelia.nix @@ -1,13 +1,17 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; + ldapAdminPassword = "ldapAdminPassword"; in { - basic = pkgs.nixosTest { + basic = pkgs.testers.runNixOSTest { name = "authelia-basic"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; diff --git a/test/vm/grocy.nix b/test/vm/grocy.nix index 5e33eb9..869e6d0 100644 --- a/test/vm/grocy.nix +++ b/test/vm/grocy.nix @@ -1,5 +1,7 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; + # TODO: Test login commonTestScript = { nodes, ... }: let @@ -38,11 +40,13 @@ let ''; in { - basic = pkgs.nixosTest { + basic = pkgs.testers.runNixOSTest { name = "grocy-basic"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -65,11 +69,13 @@ in testScript = commonTestScript; }; - cert = pkgs.nixosTest { + cert = pkgs.testers.runNixOSTest { name = "grocy-cert"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; diff --git a/test/vm/jellyfin.nix b/test/vm/jellyfin.nix index bfc6454..253424e 100644 --- a/test/vm/jellyfin.nix +++ b/test/vm/jellyfin.nix @@ -1,5 +1,7 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; + # TODO: Test login commonTestScript = { nodes, ... }: let @@ -38,11 +40,13 @@ let ''; in { - basic = pkgs.nixosTest { + basic = pkgs.testers.runNixOSTest { name = "jellyfin-basic"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -66,11 +70,13 @@ in testScript = commonTestScript; }; - ldap = pkgs.nixosTest { + ldap = pkgs.testers.runNixOSTest { name = "jellyfin-ldap"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -114,11 +120,13 @@ in testScript = commonTestScript; }; - cert = pkgs.nixosTest { + cert = pkgs.testers.runNixOSTest { name = "jellyfin_cert"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -164,11 +172,13 @@ in testScript = commonTestScript; }; - sso = pkgs.nixosTest { + sso = pkgs.testers.runNixOSTest { name = "jellyfin_sso"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; diff --git a/test/vm/ldap.nix b/test/vm/ldap.nix index 967757a..a6724ca 100644 --- a/test/vm/ldap.nix +++ b/test/vm/ldap.nix @@ -1,10 +1,15 @@ { pkgs, lib, ... }: +let + pkgs' = pkgs; +in { - auth = pkgs.nixosTest { + auth = pkgs.testers.runNixOSTest { name = "ldap-auth"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.ssl.enable = lib.mkEnableOption "ssl"; diff --git a/test/vm/lib.nix b/test/vm/lib.nix index 5a79c0a..8ee7db1 100644 --- a/test/vm/lib.nix +++ b/test/vm/lib.nix @@ -1,5 +1,7 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; + shblib = pkgs.callPackage ../../lib {}; in { @@ -40,11 +42,13 @@ in generator = lib.generators.toJSON {}; }; in - pkgs.nixosTest { + pkgs.testers.runNixOSTest { name = "lib-template"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { libtest.config = lib.mkOption { diff --git a/test/vm/monitoring.nix b/test/vm/monitoring.nix index e9ee204..15122d8 100644 --- a/test/vm/monitoring.nix +++ b/test/vm/monitoring.nix @@ -1,11 +1,16 @@ { pkgs, lib, ... }: +let + pkgs' = pkgs; +in { # This test, although simple, makes sure all provisioning went fine. - auth = pkgs.nixosTest { + auth = pkgs.testers.runNixOSTest { name = "monitoring-basic"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.ssl.enable = lib.mkEnableOption "ssl"; diff --git a/test/vm/nextcloud.nix b/test/vm/nextcloud.nix index 58ef84e..4d5056c 100644 --- a/test/vm/nextcloud.nix +++ b/test/vm/nextcloud.nix @@ -1,5 +1,6 @@ { pkgs, lib, ... }: let + pkgs' = pkgs; adminUser = "root"; adminPass = "rootpw"; @@ -124,11 +125,13 @@ let ''; in { - basic = pkgs.nixosTest { + basic = pkgs.testers.runNixOSTest { name = "nextcloud-basic"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; @@ -164,11 +167,13 @@ in testScript = commonTestScript; }; - cert = pkgs.nixosTest { + cert = pkgs.testers.runNixOSTest { name = "nextcloud-cert"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") { options = { shb.backup = lib.mkOption { type = lib.types.anything; }; diff --git a/test/vm/postgresql.nix b/test/vm/postgresql.nix index 28db06c..9bd0163 100644 --- a/test/vm/postgresql.nix +++ b/test/vm/postgresql.nix @@ -1,10 +1,15 @@ { pkgs, lib, ... }: +let + pkgs' = pkgs; +in { - peerWithoutUser = pkgs.nixosTest { + peerWithoutUser = pkgs.testers.runNixOSTest { name = "postgresql-peerWithoutUser"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ../../modules/blocks/postgresql.nix ]; @@ -35,11 +40,13 @@ ''; }; - peerAuth = pkgs.nixosTest { + peerAuth = pkgs.testers.runNixOSTest { name = "postgresql-peerAuth"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ../../modules/blocks/postgresql.nix ]; @@ -83,11 +90,13 @@ ''; }; - tcpIPWithoutPasswordAuth = pkgs.nixosTest { + tcpIPWithoutPasswordAuth = pkgs.testers.runNixOSTest { name = "postgresql-tcpIpWithoutPasswordAuth"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ../../modules/blocks/postgresql.nix ]; @@ -119,11 +128,13 @@ ''; }; - tcpIPPasswordAuth = pkgs.nixosTest { + tcpIPPasswordAuth = pkgs.testers.runNixOSTest { name = "postgresql-tcpIPPasswordAuth"; nodes.machine = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ../../modules/blocks/postgresql.nix ]; diff --git a/test/vm/ssl.nix b/test/vm/ssl.nix index e66104a..63d2303 100644 --- a/test/vm/ssl.nix +++ b/test/vm/ssl.nix @@ -1,10 +1,15 @@ { pkgs, lib, ... }: +let + pkgs' = pkgs; +in { - test = pkgs.nixosTest { + test = pkgs.testers.runNixOSTest { name = "ssl-test"; nodes.server = { config, pkgs, ... }: { imports = [ + (pkgs'.path + "/nixos/modules/profiles/headless.nix") + (pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix") ../../modules/blocks/ssl.nix ];