1
0
Fork 0

move CI to garnix (#210)

This commit is contained in:
Pierre Penninckx 2024-03-19 22:50:41 -07:00 committed by GitHub
parent f8636e28dc
commit c75daa23c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 109 additions and 136 deletions

View file

@ -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 <<EOF
{"execute": "qmp_capabilities"}
{"execute": "system_powerdown"}
EOF
# Needed to get a status check for matrix jobs
# From https://github.com/orgs/community/discussions/26822
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Results
needs: [ test ]
steps:
- run: exit 1
# see https://stackoverflow.com/a/67532120/4907315
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
|| contains(needs.*.result, 'skipped')
}}

View file

@ -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

20
.github/workflows/garnix.yaml vendored Normal file
View file

@ -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')
}}

View file

@ -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)"

View file

@ -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) [![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) [![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) [![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 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 entry-bar for self-hosting. SHB provides opinionated [building blocks](#available-blocks) fitting

View file

@ -608,7 +608,7 @@ in
environment.systemPackages = [ 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 # 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. # Needed for the recognize app.
pkgs.nodejs pkgs.nodejs

View file

@ -1,5 +1,6 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
# TODO: Test login # TODO: Test login
commonTestScript = appname: { nodes, ... }: commonTestScript = appname: { nodes, ... }:
let let
@ -44,7 +45,7 @@ let
raise Exception(f"Code is {response['code']}") raise Exception(f"Code is {response['code']}")
''; '';
basic = appname: pkgs.nixosTest { basic = appname: pkgs.testers.runNixOSTest {
name = "arr-${appname}-basic"; name = "arr-${appname}-basic";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
@ -58,6 +59,8 @@ let
../../modules/blocks/postgresql.nix ../../modules/blocks/postgresql.nix
../../modules/blocks/nginx.nix ../../modules/blocks/nginx.nix
../../modules/services/arr.nix ../../modules/services/arr.nix
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
]; ];
shb.arr.${appname} = { shb.arr.${appname} = {

View file

@ -1,5 +1,7 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
# TODO: Test login # TODO: Test login
commonTestScript = { nodes, ... }: commonTestScript = { nodes, ... }:
let let
@ -38,11 +40,13 @@ let
''; '';
in in
{ {
basic = pkgs.nixosTest { basic = pkgs.testers.runNixOSTest {
name = "audiobookshelf-basic"; name = "audiobookshelf-basic";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -66,11 +70,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
cert = pkgs.nixosTest { cert = pkgs.testers.runNixOSTest {
name = "audiobookshelf-cert"; name = "audiobookshelf-cert";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -115,11 +121,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
sso = pkgs.nixosTest { sso = pkgs.testers.runNixOSTest {
name = "audiobookshelf-sso"; name = "audiobookshelf-sso";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };

View file

@ -1,13 +1,17 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
ldapAdminPassword = "ldapAdminPassword"; ldapAdminPassword = "ldapAdminPassword";
in in
{ {
basic = pkgs.nixosTest { basic = pkgs.testers.runNixOSTest {
name = "authelia-basic"; name = "authelia-basic";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };

View file

@ -1,5 +1,7 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
# TODO: Test login # TODO: Test login
commonTestScript = { nodes, ... }: commonTestScript = { nodes, ... }:
let let
@ -38,11 +40,13 @@ let
''; '';
in in
{ {
basic = pkgs.nixosTest { basic = pkgs.testers.runNixOSTest {
name = "grocy-basic"; name = "grocy-basic";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -65,11 +69,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
cert = pkgs.nixosTest { cert = pkgs.testers.runNixOSTest {
name = "grocy-cert"; name = "grocy-cert";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };

View file

@ -1,5 +1,7 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
# TODO: Test login # TODO: Test login
commonTestScript = { nodes, ... }: commonTestScript = { nodes, ... }:
let let
@ -38,11 +40,13 @@ let
''; '';
in in
{ {
basic = pkgs.nixosTest { basic = pkgs.testers.runNixOSTest {
name = "jellyfin-basic"; name = "jellyfin-basic";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -66,11 +70,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
ldap = pkgs.nixosTest { ldap = pkgs.testers.runNixOSTest {
name = "jellyfin-ldap"; name = "jellyfin-ldap";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -114,11 +120,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
cert = pkgs.nixosTest { cert = pkgs.testers.runNixOSTest {
name = "jellyfin_cert"; name = "jellyfin_cert";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -164,11 +172,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
sso = pkgs.nixosTest { sso = pkgs.testers.runNixOSTest {
name = "jellyfin_sso"; name = "jellyfin_sso";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };

View file

@ -1,10 +1,15 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
pkgs' = pkgs;
in
{ {
auth = pkgs.nixosTest { auth = pkgs.testers.runNixOSTest {
name = "ldap-auth"; name = "ldap-auth";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.ssl.enable = lib.mkEnableOption "ssl"; shb.ssl.enable = lib.mkEnableOption "ssl";

View file

@ -1,5 +1,7 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
shblib = pkgs.callPackage ../../lib {}; shblib = pkgs.callPackage ../../lib {};
in in
{ {
@ -40,11 +42,13 @@ in
generator = lib.generators.toJSON {}; generator = lib.generators.toJSON {};
}; };
in in
pkgs.nixosTest { pkgs.testers.runNixOSTest {
name = "lib-template"; name = "lib-template";
nodes.machine = { config, pkgs, ... }: nodes.machine = { config, pkgs, ... }:
{ {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
libtest.config = lib.mkOption { libtest.config = lib.mkOption {

View file

@ -1,11 +1,16 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
pkgs' = pkgs;
in
{ {
# This test, although simple, makes sure all provisioning went fine. # This test, although simple, makes sure all provisioning went fine.
auth = pkgs.nixosTest { auth = pkgs.testers.runNixOSTest {
name = "monitoring-basic"; name = "monitoring-basic";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.ssl.enable = lib.mkEnableOption "ssl"; shb.ssl.enable = lib.mkEnableOption "ssl";

View file

@ -1,5 +1,6 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
pkgs' = pkgs;
adminUser = "root"; adminUser = "root";
adminPass = "rootpw"; adminPass = "rootpw";
@ -124,11 +125,13 @@ let
''; '';
in in
{ {
basic = pkgs.nixosTest { basic = pkgs.testers.runNixOSTest {
name = "nextcloud-basic"; name = "nextcloud-basic";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };
@ -164,11 +167,13 @@ in
testScript = commonTestScript; testScript = commonTestScript;
}; };
cert = pkgs.nixosTest { cert = pkgs.testers.runNixOSTest {
name = "nextcloud-cert"; name = "nextcloud-cert";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
{ {
options = { options = {
shb.backup = lib.mkOption { type = lib.types.anything; }; shb.backup = lib.mkOption { type = lib.types.anything; };

View file

@ -1,10 +1,15 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
pkgs' = pkgs;
in
{ {
peerWithoutUser = pkgs.nixosTest { peerWithoutUser = pkgs.testers.runNixOSTest {
name = "postgresql-peerWithoutUser"; name = "postgresql-peerWithoutUser";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
../../modules/blocks/postgresql.nix ../../modules/blocks/postgresql.nix
]; ];
@ -35,11 +40,13 @@
''; '';
}; };
peerAuth = pkgs.nixosTest { peerAuth = pkgs.testers.runNixOSTest {
name = "postgresql-peerAuth"; name = "postgresql-peerAuth";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
../../modules/blocks/postgresql.nix ../../modules/blocks/postgresql.nix
]; ];
@ -83,11 +90,13 @@
''; '';
}; };
tcpIPWithoutPasswordAuth = pkgs.nixosTest { tcpIPWithoutPasswordAuth = pkgs.testers.runNixOSTest {
name = "postgresql-tcpIpWithoutPasswordAuth"; name = "postgresql-tcpIpWithoutPasswordAuth";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
../../modules/blocks/postgresql.nix ../../modules/blocks/postgresql.nix
]; ];
@ -119,11 +128,13 @@
''; '';
}; };
tcpIPPasswordAuth = pkgs.nixosTest { tcpIPPasswordAuth = pkgs.testers.runNixOSTest {
name = "postgresql-tcpIPPasswordAuth"; name = "postgresql-tcpIPPasswordAuth";
nodes.machine = { config, pkgs, ... }: { nodes.machine = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
../../modules/blocks/postgresql.nix ../../modules/blocks/postgresql.nix
]; ];

View file

@ -1,10 +1,15 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let
pkgs' = pkgs;
in
{ {
test = pkgs.nixosTest { test = pkgs.testers.runNixOSTest {
name = "ssl-test"; name = "ssl-test";
nodes.server = { config, pkgs, ... }: { nodes.server = { config, pkgs, ... }: {
imports = [ imports = [
(pkgs'.path + "/nixos/modules/profiles/headless.nix")
(pkgs'.path + "/nixos/modules/profiles/qemu-guest.nix")
../../modules/blocks/ssl.nix ../../modules/blocks/ssl.nix
]; ];