Skip to content

Commit

Permalink
fix builds in CI (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibizaman authored Oct 24, 2024
1 parent b8a570a commit 2dd3f4c
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 35 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions .github/workflows/garnix.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
src = nixpkgs;
inherit patches;
};

pkgs = import patchedNixpkgs {
inherit system;
};
Expand Down Expand Up @@ -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;

Expand All @@ -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 {};
Expand All @@ -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)
Expand All @@ -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" ];
};
}

0 comments on commit 2dd3f4c

Please sign in to comment.