feat: Add local workflow
All checks were successful
Run pre-commit on all files / pre-push (push) Successful in 25s

This commit is contained in:
Tom Hubrecht 2024-12-30 12:16:26 +01:00
parent 8815dfc28d
commit 829e83af9c
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
3 changed files with 64 additions and 16 deletions

View file

@ -0,0 +1,12 @@
jobs:
pre-push:
runs-on: nix
steps:
- uses: actions/checkout@v3
- name: Run pre-commit on all files
run: nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage
pre-push --show-diff-on-failure'
name: Run pre-commit on all files
'on':
- pull_request
- push

View file

@ -2,7 +2,7 @@ version = 1
[[annotations]] [[annotations]]
SPDX-FileCopyrightText = "NONE" SPDX-FileCopyrightText = "NONE"
SPDX-License-Identifier = "CC0-1.0" SPDX-License-Identifier = "CC0-1.0"
path = [".envrc", ".gitignore", "shell.nix"] path = [".envrc", ".forgejo/workflows/*.yaml", ".gitignore", "shell.nix"]
precedence = "closest" precedence = "closest"
[[annotations]] [[annotations]]

View file

@ -8,7 +8,9 @@
}: }:
let let
inherit (pkgs) lib mkShell; inherit (pkgs) mkShell;
inherit (pkgs.lib) evalModules getExe recursiveUpdate;
inherit (pkgs.lib.fileset) gitTracked toSource; inherit (pkgs.lib.fileset) gitTracked toSource;
@ -52,6 +54,7 @@ let
generatedPaths = [ generatedPaths = [
".envrc" ".envrc"
".forgejo/workflows/*.yaml"
".gitignore" ".gitignore"
"shell.nix" "shell.nix"
]; ];
@ -65,24 +68,11 @@ let
} }
]; ];
}; };
in
{
devShell = mkShell {
name = "nix-actions.dev";
packages = git-checks.enabledPackages;
shellHook = builtins.concatStringsSep "\n" [
git-checks.shellHook
reuse.shellHook
];
};
install = install =
{ src, ... }@config: { src, ... }@config:
let let
project = lib.evalModules { project = evalModules {
modules = [ modules = [
./modules ./modules
{ {
@ -107,6 +97,52 @@ in
}; };
}; };
workflows = install {
src = ./.;
buildCheck = false;
workflows.pre-commit = {
name = "Run pre-commit on all files";
on = [
"pull_request"
"push"
];
jobs.pre-push = {
runs-on = "nix";
steps = [
{ uses = "actions/checkout@v3"; }
{
name = "Run pre-commit on all files";
run = "nix-shell -A pre-commit --run 'pre-commit run --all-files --hook-stage pre-push --show-diff-on-failure'";
}
];
};
};
};
in
{
devShell = mkShell {
name = "nix-actions.dev";
packages = git-checks.enabledPackages;
shellHook = builtins.concatStringsSep "\n" [
git-checks.shellHook
reuse.shellHook
workflows.shellHook
];
passthru.pre-commit = mkShell {
name = "pre-commit";
inherit (git-checks) shellHook;
};
};
inherit install;
lib = rec { lib = rec {
expr = repr: "\${{ ${repr} }}"; expr = repr: "\${{ ${repr} }}";
secret = name: expr "secrets.${name}"; secret = name: expr "secrets.${name}";