Skip to content

Commit 029c497

Browse files
authored
Merge pull request #589 from acid-bong/feat/woodpecker-cli
feat: add woodpecker-cli lint hook
2 parents 4e9fce4 + d9d4a28 commit 029c497

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ use nix
498498
- [topiary](https://github.com/tweag/topiary)
499499
- [treefmt](https://github.com/numtide/treefmt)
500500
- [trim-trailing-whitespace](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/trailing_whitespace_fixer.py)
501+
- [woodpecker-cli-lint](https://woodpecker-ci.org/docs/cli#lint)
501502
- [zizmor](https://github.com/zizmorcore/zizmor)
502503

503504
### Custom hooks

modules/hooks.nix

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let
33
inherit (config) hooks tools settings;
44
cfg = config;
5-
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types;
5+
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkEnableOption mkRemovedOptionModule mkRenamedOptionModule types;
66

77
toml = pkgs.formats.toml { };
88

@@ -2003,6 +2003,40 @@ in
20032003
};
20042004
};
20052005
};
2006+
woodpecker-cli-lint = mkOption {
2007+
description = "`woodpecker-cli lint` hook";
2008+
type = types.submodule {
2009+
imports = [ hookModule ];
2010+
options.settings = {
2011+
workflowPath = mkOption {
2012+
type = types.str;
2013+
description = ''
2014+
Path to the workflow config file/directory. If not set, the program
2015+
looks for `.woodpecker.ya?ml` file or `.woodpecker` directory.
2016+
'';
2017+
default = "";
2018+
example = ".woodpecker.yml";
2019+
};
2020+
strict = mkEnableOption "" // {
2021+
description = "Whether to treat warnings as errors.";
2022+
};
2023+
pluginsPrivileged = mkOption {
2024+
type = types.commas;
2025+
description = "List of plugins, allowed to run in privileged mode";
2026+
default = "";
2027+
};
2028+
pluginsTrustedClone = mkOption {
2029+
type = types.commas;
2030+
description = ''
2031+
List of plugins, that are trusted to handle Git credentials in cloning steps.
2032+
If not set, the program defaults to
2033+
"docker.io/woodpeckerci/plugin-git:2.6.3,docker.io/woodpeckerci/plugin-git,quay.io/woodpeckerci/plugin-git".
2034+
'';
2035+
default = "";
2036+
};
2037+
};
2038+
};
2039+
};
20062040
yamlfmt = mkOption {
20072041
description = "yamlfmt hook";
20082042
type = types.submodule {
@@ -4152,6 +4186,25 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
41524186
"${hooks.vale.package}/bin/vale${cmdArgs} ${hooks.vale.settings.flags}";
41534187
types = [ "text" ];
41544188
};
4189+
woodpecker-cli-lint = {
4190+
name = "woodpecker-cli-lint";
4191+
description = "Command line client for the Woodpecker Continuous Integration server (lint only).";
4192+
package = tools.woodpecker-cli;
4193+
entry =
4194+
let
4195+
cmdArgs = mkCmdArgs (with hooks.woodpecker-cli-lint.settings; [
4196+
[ (workflowPath != "") workflowPath ]
4197+
# this check depends on the internet connection, without it
4198+
# the lint is lightning-fast
4199+
[ true "--disable-update-check" ]
4200+
[ strict "--strict" ]
4201+
[ (pluginsPrivileged != "") "--plugins-privileged=${pluginsPrivileged}" ]
4202+
[ (pluginsTrustedClone != "") "--plugins-trusted-clone=${pluginsTrustedClone}" ]
4203+
]);
4204+
in
4205+
"${lib.getExe hooks.woodpecker-cli-lint.package} lint ${cmdArgs}";
4206+
types = [ "file" "yaml" ];
4207+
};
41554208
yamlfmt =
41564209
{
41574210
name = "yamlfmt";

nix/tools.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
, typos
8787
, typstfmt
8888
, typstyle ? null ## Add in nixpkgs added on commit 800ca60
89+
, woodpecker-cli
8990
, zprint
9091
, yamlfmt
9192
, yamllint
@@ -179,6 +180,7 @@ in
179180
typstyle
180181
uv
181182
vale
183+
woodpecker-cli
182184
yamlfmt
183185
yamllint
184186
zizmor

0 commit comments

Comments
 (0)