forgejo-actions: let's give this a shot
This commit is contained in:
parent
4eae813277
commit
c85f98117c
2 changed files with 87 additions and 1 deletions
61
.forgejo/workflows/ci.yaml
Normal file
61
.forgejo/workflows/ci.yaml
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
generate-targets:
|
||||||
|
runs-on: cacher
|
||||||
|
outputs:
|
||||||
|
targets: ${{ steps.build.outputs.targets }}
|
||||||
|
machines: ${{ steps.build.outputs.machines }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Drop in ops/secrets/default.nix
|
||||||
|
run:
|
||||||
|
echo "$OPS_SECRETS_DEFAULTNIX" > ops/secrets/default.nix
|
||||||
|
env:
|
||||||
|
OPS_SECRETS_DEFAULTNIX: "${{ secrets.OPS_SECRETS_DEFAULTNIX }}"
|
||||||
|
|
||||||
|
- id: build
|
||||||
|
name: Build matrix
|
||||||
|
run: |
|
||||||
|
cat "$(nix-build ci-root.nix -A forgejoMatrix)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: cacher
|
||||||
|
needs: [generate-targets]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJSON(needs.generate-targets.outputs.targets) }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Drop in ops/secrets/default.nix
|
||||||
|
run: |
|
||||||
|
echo "$OPS_SECRETS_DEFAULTNIX" > ops/secrets/default.nix
|
||||||
|
env:
|
||||||
|
OPS_SECRETS_DEFAULTNIX: "${{ secrets.OPS_SECRETS_DEFAULTNIX }}"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
nix-build ci-root.nix -A "${{ matrix.target }}"
|
||||||
|
|
||||||
|
build-machine:
|
||||||
|
runs-on: cacher
|
||||||
|
needs: [generate-targets]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
target: ${{ fromJSON(needs.generate-targets.outputs.machines) }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Drop in ops/secrets/default.nix
|
||||||
|
run: |
|
||||||
|
echo "$OPS_SECRETS_DEFAULTNIX" > ops/secrets/default.nix
|
||||||
|
env:
|
||||||
|
OPS_SECRETS_DEFAULTNIX: "${{ secrets.OPS_SECRETS_DEFAULTNIX }}"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
nix-build ci-root.nix -A "machine.${{ matrix.target }}"
|
27
ci-root.nix
27
ci-root.nix
|
@ -56,5 +56,30 @@ let
|
||||||
notADerivationOrPath = builtins.filter (elem: !lib.isString elem.path && !lib.isDerivation elem.path) entries;
|
notADerivationOrPath = builtins.filter (elem: !lib.isString elem.path && !lib.isDerivation elem.path) entries;
|
||||||
notADerivationOrPath' = map (elem: elem.name) notADerivationOrPath;
|
notADerivationOrPath' = map (elem: elem.name) notADerivationOrPath;
|
||||||
in assert lib.assertMsg ((lib.length notADerivationOrPath') == 0) "not a derivation or path: ${toString notADerivationOrPath'}"; entries;
|
in assert lib.assertMsg ((lib.length notADerivationOrPath') == 0) "not a derivation or path: ${toString notADerivationOrPath'}"; entries;
|
||||||
|
|
||||||
|
entries = entriesFilter (builtins.concatLists (lib.mapAttrsToList prefixAttrs ciBits));
|
||||||
|
linkFarm = pkgs.linkFarm "ci" entries;
|
||||||
|
|
||||||
|
targetNamer' = prefix: lib.mapAttrsToList (name: value: let
|
||||||
|
prefixedName = prefix ++ [name];
|
||||||
|
finalName = lib.concatStringsSep "." prefixedName;
|
||||||
|
in
|
||||||
|
if lib.isDerivation value then finalName
|
||||||
|
else if lib.isAttrs value then targetNamer' prefixedName value
|
||||||
|
else finalName
|
||||||
|
);
|
||||||
|
targetNamer = attrs: lib.flatten (targetNamer' [] attrs);
|
||||||
|
|
||||||
|
delimiter = "HONKHONKHONKxxxHONKHONKHONK";
|
||||||
|
forgejoMatrix = pkgs.writeText "forgejo-ci-matrix" ''
|
||||||
|
machines<<${delimiter}
|
||||||
|
${builtins.toJSON (builtins.attrNames depot.ops.nixos.systems)}
|
||||||
|
${delimiter}
|
||||||
|
targets<<${delimiter}
|
||||||
|
${builtins.toJSON (lib.filter (name: !lib.hasPrefix "machine." name) (targetNamer ciBits))}
|
||||||
|
${delimiter}
|
||||||
|
'';
|
||||||
in
|
in
|
||||||
pkgs.linkFarm "ci" (entriesFilter (builtins.concatLists (lib.mapAttrsToList prefixAttrs ciBits)))
|
ciBits // {
|
||||||
|
inherit forgejoMatrix linkFarm;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue