mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 09:54:20 +02:00
run psalm and phpstan checks for all php versions
This commit is contained in:
parent
d6b95b950d
commit
a59a517f66
3 changed files with 24 additions and 20 deletions
|
|
@ -8,11 +8,13 @@
|
|||
flakelight,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) elem readFile pathExists match fromJSON attrNames head;
|
||||
inherit (lib) getExe mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types;
|
||||
inherit (builtins) elem readFile pathExists match fromJSON attrNames head replaceStrings;
|
||||
inherit (lib) getExe mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types listToAttrs;
|
||||
inherit (lib.fileset) fileFilter toSource unions;
|
||||
inherit (flakelight.types) fileset function;
|
||||
|
||||
genAttrs' = xs: f: listToAttrs (map f xs); # TODO remove after we're at newer nixpkgs
|
||||
|
||||
phpVersions = {
|
||||
"5.6" = pkgs: pkgs.php56;
|
||||
"7.0" = pkgs: pkgs.php70;
|
||||
|
|
@ -55,6 +57,7 @@
|
|||
enabled ++ (config.phpExtensions (all // extra));
|
||||
};
|
||||
buildPhp = pkgs: buildPhpVersion pkgs (head composerMeta.phpVersions);
|
||||
removeDots = replaceStrings ["."] [""];
|
||||
in
|
||||
warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
|
||||
{
|
||||
|
|
@ -92,7 +95,7 @@ in
|
|||
|| file.hasExt "stub"
|
||||
|| file.hasExt "phpstub"
|
||||
|| match "snapshot__.*\.snap" file.name != null
|
||||
|| elem file.name [".php-cs-fixer.dist.php" "psalm.xml" "package.json" "package.lock" "phpstan.neon"])
|
||||
|| elem file.name [".php-cs-fixer.dist.php" "psalm.xml" "composer.json" "composer.lock" "phpstan.neon"])
|
||||
src;
|
||||
};
|
||||
phpExtensions = mkOption {
|
||||
|
|
@ -141,17 +144,18 @@ in
|
|||
vendor = pkgs: pkgs.vendor;
|
||||
};
|
||||
|
||||
checks = {pkgs, ...}:
|
||||
(optionalAttrs hasPsalm {
|
||||
psalm = pkgs.callPackage ./checks/psalm.nix {
|
||||
src = filteredSrc;
|
||||
};
|
||||
})
|
||||
// (optionalAttrs hasPhpStan {
|
||||
phpstan = pkgs.callPackage ./checks/phpstan.nix {
|
||||
src = filteredSrc;
|
||||
};
|
||||
});
|
||||
checks = {pkgs, ...}: let
|
||||
forPhpVersions = name: checkFile:
|
||||
genAttrs' composerMeta.phpVersions (version: {
|
||||
name = "${name}${removeDots version}";
|
||||
value = pkgs.callPackage ./checks/psalm.nix {
|
||||
src = filteredSrc;
|
||||
php = buildPhpVersion pkgs version;
|
||||
};
|
||||
});
|
||||
in
|
||||
(optionalAttrs hasPsalm (forPhpVersions "psalm" ./checks/psalm.nix))
|
||||
// (optionalAttrs hasPhpStan (forPhpVersions "phpstan" ./checks/phpstan.nix));
|
||||
})
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue