diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..20c3bb0 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,105 @@ +# name: build +# on: push +# jobs: +# checks: +# uses: nixbuild/nixbuild-action/.github/workflows/ci-workflow.yml@v19 +# with: +# nix_conf: | +# allow-import-from-derivation = true +# secrets: +# nixbuild_token: ${{ secrets.nixbuild_token }} + + +name: "build" +on: + pull_request: + push: + branches: [ "main" ] + +jobs: + build-matrix: + 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: Generate Matrix + id: generate-matrix + run: | + nix flake show --allow-import-from-derivation --json \ + | jq -c '.["checks"]["x86_64-linux"] | keys' > .output + + cat .output + + echo dynamic_list="$(cat .output)" >> "$GITHUB_OUTPUT" + outputs: + check: ${{ steps.generate-matrix.outputs.dynamic_list }} + + manual: + 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: Build + run: | + nix \ + --print-build-logs \ + --option keep-going true \ + --show-trace \ + build .#manualHtml + + tests: + runs-on: ubuntu-latest + needs: [ "build-matrix" ] + strategy: + matrix: + check: ${{ fromJson(needs.build-matrix.outputs.check) }} + 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: Build + run: | + nix build --print-build-logs --show-trace .#checks.x86_64-linux.${{ matrix.check }} + + results: + if: ${{ always() }} + runs-on: ubuntu-latest + name: Final Results + needs: [ manual, tests ] + steps: + - run: | + result="${{ needs.tests.result }}" + if [[ $result == "success" || $result == "skipped" ]]; then + exit 0 + else + exit 1 + fi diff --git a/.github/workflows/garnix.yaml b/.github/workflows/garnix.yaml deleted file mode 100644 index 4304da4..0000000 --- a/.github/workflows/garnix.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# Leaving commented because it does not work. -# -# 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/pages.yml b/.github/workflows/pages.yml index f45fd75..16a4ffb 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -2,14 +2,8 @@ name: Deploy docs on: - # Runs on pushes targeting the default branch push: branches: ["main"] - # TODO: needed ? - # schedule: - # - cron: 0 0 * * 1 - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages diff --git a/flake.nix b/flake.nix index 0869c01..9a07658 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,6 @@ src = nixpkgs; inherit patches; }; - pkgs = import patchedNixpkgs { inherit system; }; @@ -79,12 +78,14 @@ checks = let + inherit (pkgs.lib) foldl foldlAttrs mergeAttrs optionalAttrs; + importFiles = files: map (m: pkgs.callPackage m {}) files; - mergeTests = pkgs.lib.lists.foldl pkgs.lib.trivial.mergeAttrs {}; + mergeTests = foldl mergeAttrs {}; - flattenAttrs = root: attrset: pkgs.lib.attrsets.foldlAttrs (acc: name: value: acc // { + flattenAttrs = root: attrset: foldlAttrs (acc: name: value: acc // { "${root}_${name}" = value; }) {} attrset; @@ -96,19 +97,21 @@ ); shblib = pkgs.callPackage ./lib {}; - in (rec { + in (optionalAttrs (system == "x86_64-linux") ({ modules = shblib.check { inherit pkgs; tests = mergeTests (importFiles [ ./test/modules/arr.nix ./test/modules/davfs.nix + # TODO: Make this not use IFD ./test/modules/lib.nix ./test/modules/nginx.nix ./test/modules/postgresql.nix ]); }; + # TODO: Make this not use IFD lib = nix-flake-tests.lib.check { inherit pkgs; tests = pkgs.callPackage ./test/modules/lib.nix {}; @@ -119,7 +122,7 @@ // (vm_test "deluge" ./test/services/deluge.nix) // (vm_test "forgejo" ./test/services/forgejo.nix) // (vm_test "grocy" ./test/services/grocy.nix) - // (vm_test "home-assistant" ./test/services/home-assistant.nix) + // (vm_test "homeassistant" ./test/services/home-assistant.nix) // (vm_test "jellyfin" ./test/services/jellyfin.nix) // (vm_test "monitoring" ./test/services/monitoring.nix) // (vm_test "nextcloud" ./test/services/nextcloud.nix) @@ -131,7 +134,9 @@ // (vm_test "postgresql" ./test/blocks/postgresql.nix) // (vm_test "restic" ./test/blocks/restic.nix) // (vm_test "ssl" ./test/blocks/ssl.nix) - ); + )); } - ); + ) // { + herculesCI.ciSystems = [ "x86_64-linux" ]; + }; }