mirror of
https://codeberg.org/icewind/flakelight-php.git
synced 2026-06-03 18:04:10 +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
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
composerMeta,
|
composerMeta,
|
||||||
src,
|
src,
|
||||||
phpstan,
|
php,
|
||||||
vendor,
|
vendor,
|
||||||
stdenvNoCC,
|
stdenvNoCC,
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
in
|
in
|
||||||
stdenvNoCC.mkDerivation {
|
stdenvNoCC.mkDerivation {
|
||||||
inherit src version;
|
inherit src version;
|
||||||
pname = "${name}-phpstan";
|
pname = "${name}-phpstan-${php.version}";
|
||||||
|
|
||||||
nativeBuildInputs = [phpstan];
|
nativeBuildInputs = [php.packages.phpstan];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
ln -s ${vendor}/vendor vendor
|
ln -s ${vendor}/vendor vendor
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
composerMeta,
|
composerMeta,
|
||||||
src,
|
src,
|
||||||
psalm,
|
php,
|
||||||
vendor,
|
vendor,
|
||||||
stdenvNoCC,
|
stdenvNoCC,
|
||||||
}: let
|
}: let
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
in
|
in
|
||||||
stdenvNoCC.mkDerivation {
|
stdenvNoCC.mkDerivation {
|
||||||
inherit src version;
|
inherit src version;
|
||||||
pname = "${name}-psalm";
|
pname = "${name}-psalm-${php.version}";
|
||||||
|
|
||||||
nativeBuildInputs = [psalm];
|
nativeBuildInputs = [php.packages.psalm];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
ln -s ${vendor}/vendor vendor
|
ln -s ${vendor}/vendor vendor
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,13 @@
|
||||||
flakelight,
|
flakelight,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) elem readFile pathExists match fromJSON attrNames head;
|
inherit (builtins) elem readFile pathExists match fromJSON attrNames head replaceStrings;
|
||||||
inherit (lib) getExe mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types;
|
inherit (lib) getExe mkDefault mkIf mkMerge mkOption warnIf optionalAttrs types listToAttrs;
|
||||||
inherit (lib.fileset) fileFilter toSource unions;
|
inherit (lib.fileset) fileFilter toSource unions;
|
||||||
inherit (flakelight.types) fileset function;
|
inherit (flakelight.types) fileset function;
|
||||||
|
|
||||||
|
genAttrs' = xs: f: listToAttrs (map f xs); # TODO remove after we're at newer nixpkgs
|
||||||
|
|
||||||
phpVersions = {
|
phpVersions = {
|
||||||
"5.6" = pkgs: pkgs.php56;
|
"5.6" = pkgs: pkgs.php56;
|
||||||
"7.0" = pkgs: pkgs.php70;
|
"7.0" = pkgs: pkgs.php70;
|
||||||
|
|
@ -55,6 +57,7 @@
|
||||||
enabled ++ (config.phpExtensions (all // extra));
|
enabled ++ (config.phpExtensions (all // extra));
|
||||||
};
|
};
|
||||||
buildPhp = pkgs: buildPhpVersion pkgs (head composerMeta.phpVersions);
|
buildPhp = pkgs: buildPhpVersion pkgs (head composerMeta.phpVersions);
|
||||||
|
removeDots = replaceStrings ["."] [""];
|
||||||
in
|
in
|
||||||
warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
|
warnIf (! builtins ? readFileType) "Unsupported Nix version in use."
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +95,7 @@ in
|
||||||
|| file.hasExt "stub"
|
|| file.hasExt "stub"
|
||||||
|| file.hasExt "phpstub"
|
|| file.hasExt "phpstub"
|
||||||
|| match "snapshot__.*\.snap" file.name != null
|
|| 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;
|
src;
|
||||||
};
|
};
|
||||||
phpExtensions = mkOption {
|
phpExtensions = mkOption {
|
||||||
|
|
@ -141,17 +144,18 @@ in
|
||||||
vendor = pkgs: pkgs.vendor;
|
vendor = pkgs: pkgs.vendor;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {pkgs, ...}:
|
checks = {pkgs, ...}: let
|
||||||
(optionalAttrs hasPsalm {
|
forPhpVersions = name: checkFile:
|
||||||
psalm = pkgs.callPackage ./checks/psalm.nix {
|
genAttrs' composerMeta.phpVersions (version: {
|
||||||
src = filteredSrc;
|
name = "${name}${removeDots version}";
|
||||||
};
|
value = pkgs.callPackage ./checks/psalm.nix {
|
||||||
})
|
|
||||||
// (optionalAttrs hasPhpStan {
|
|
||||||
phpstan = pkgs.callPackage ./checks/phpstan.nix {
|
|
||||||
src = filteredSrc;
|
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