Skip to content

feat: add woodpecker-cli lint hook #589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ use nix
- [topiary](https://github.com/tweag/topiary)
- [treefmt](https://github.com/numtide/treefmt)
- [trim-trailing-whitespace](https://github.com/pre-commit/pre-commit-hooks/blob/main/pre_commit_hooks/trailing_whitespace_fixer.py)
- [woodpecker-cli-lint](https://woodpecker-ci.org/docs/cli#lint)

### Custom hooks

Expand Down
54 changes: 53 additions & 1 deletion modules/hooks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let
inherit (config) hooks tools settings;
cfg = config;
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkRemovedOptionModule mkRenamedOptionModule types;
inherit (lib) flatten mapAttrs mapAttrsToList mkDefault mkOption mkEnableOption mkRemovedOptionModule mkRenamedOptionModule types;

cargoManifestPathArg =
lib.optionalString
Expand Down Expand Up @@ -1942,6 +1942,40 @@ in
};
};
};
woodpecker-cli-lint = mkOption {
description = "`woodpecker-cli lint` hook";
type = types.submodule {
imports = [ hookModule ];
options.settings = {
workflowPath = mkOption {
type = types.str;
description = ''
Path to the workflow config file/directory. If not set, the program
looks for `.woodpecker.ya?ml` file or `.woodpecker` directory.
'';
default = "";
example = ".woodpecker.yml";
};
strict = mkEnableOption "" // {
description = "Whether to treat warnings as errors.";
};
pluginsPrivileged = mkOption {
type = types.commas;
description="List of plugins, allowed to run in privileged mode";
default="";
};
pluginsTrustedClone = mkOption {
type = types.commas;
description=''
List of plugins, that are trusted to handle Git credentials in cloning steps.
If not set, the program defaults to
"docker.io/woodpeckerci/plugin-git:2.6.3,docker.io/woodpeckerci/plugin-git,quay.io/woodpeckerci/plugin-git".
'';
default="";
};
};
};
};
yamlfmt = mkOption {
description = "yamlfmt hook";
type = types.submodule {
Expand Down Expand Up @@ -4050,6 +4084,24 @@ lib.escapeShellArgs (lib.concatMap (ext: [ "--ghc-opt" "-X${ext}" ]) hooks.fourm
"${hooks.vale.package}/bin/vale${cmdArgs} ${hooks.vale.settings.flags}";
types = [ "text" ];
};
woodpecker-cli-lint = {
name = "woodpecker-cli-lint";
description = "Command line client for the Woodpecker Continuous Integration server (lint only).";
package = tools.woodpecker-cli;
entry = let
cmdArgs = mkCmdArgs (with hooks.woodpecker-cli-lint.settings; [
[ (workflowPath != "") workflowPath ]
# this check depends on the internet connection, without it
# the lint is lightning-fast
[ true "--disable-update-check" ]
[ strict "--strict" ]
[ (pluginsPrivileged != "") "--plugins-privileged=${pluginsPrivileged}" ]
[ (pluginsTrustedClone != "") "--plugins-trusted-clone=${pluginsTrustedClone}" ]
]);
in
"${lib.getExe hooks.woodpecker-cli-lint.package} lint ${cmdArgs}";
types = [ "file" "yaml" ];
};
yamlfmt =
{
name = "yamlfmt";
Expand Down
2 changes: 2 additions & 0 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
, typos
, typstfmt
, typstyle ? null ## Add in nixpkgs added on commit 800ca60
, woodpecker-cli
, zprint
, yamlfmt
, yamllint
Expand Down Expand Up @@ -173,6 +174,7 @@ in
typstfmt
typstyle
vale
woodpecker-cli
yamlfmt
yamllint
zprint
Expand Down