mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-09 03:56:10 +01:00
Convert ci tests to nix flake app test-runner
This commit is contained in:
parent
7c41549bd4
commit
76eba564f7
4 changed files with 32 additions and 23 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -21,4 +21,4 @@ jobs:
|
||||||
keep-derivations = true
|
keep-derivations = true
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command flakes
|
||||||
- run:
|
- run:
|
||||||
nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz ci.nix --run 'true'
|
"nix run .#test-runner"
|
||||||
|
|
|
||||||
21
ci.nix
21
ci.nix
|
|
@ -1,21 +0,0 @@
|
||||||
with import <nixpkgs> {};
|
|
||||||
mkShell {
|
|
||||||
nativeBuildInputs = [
|
|
||||||
shellcheck direnv mypy python3.pkgs.black python3.pkgs.flake8
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
set -e
|
|
||||||
echo -e "\x1b[32m## run shellcheck\x1b[0m"
|
|
||||||
shellcheck direnvrc
|
|
||||||
echo -e "\x1b[32m## run black\x1b[0m"
|
|
||||||
LC_ALL=en_US.utf-8 black --check .
|
|
||||||
echo -e "\x1b[32m## run flake8\x1b[0m"
|
|
||||||
flake8 --ignore E501 tests
|
|
||||||
echo -e "\x1b[32m## run mypy\x1b[0m"
|
|
||||||
mypy tests
|
|
||||||
|
|
||||||
echo -e "\x1b[32m## run unittest\x1b[0m"
|
|
||||||
${pkgs.python3.interpreter} -m unittest discover tests
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
10
flake.nix
10
flake.nix
|
|
@ -7,8 +7,16 @@
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in {
|
in {
|
||||||
defaultPackage = pkgs.callPackage ./default.nix { };
|
packages = {
|
||||||
|
default = pkgs.callPackage ./default.nix { };
|
||||||
|
test-runner = pkgs.callPackage ./run-tests.nix {};
|
||||||
|
};
|
||||||
|
defaultPackage = self.packages.${system}.default;
|
||||||
devShell = pkgs.callPackage ./shell.nix { };
|
devShell = pkgs.callPackage ./shell.nix { };
|
||||||
|
apps.test-runner = {
|
||||||
|
type = "app";
|
||||||
|
program = "${self.packages.${system}.test-runner}";
|
||||||
|
};
|
||||||
}) // {
|
}) // {
|
||||||
overlay = final: prev: {
|
overlay = final: prev: {
|
||||||
nix-direnv = final.callPackage ./default.nix { };
|
nix-direnv = final.callPackage ./default.nix { };
|
||||||
|
|
|
||||||
22
run-tests.nix
Normal file
22
run-tests.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
writeScript,
|
||||||
|
shellcheck,
|
||||||
|
direnv,
|
||||||
|
mypy,
|
||||||
|
python3,
|
||||||
|
}:
|
||||||
|
writeScript "run-tests" ''
|
||||||
|
set -e
|
||||||
|
PATH="''${PATH}''${PATH:+":"}${direnv}/bin"
|
||||||
|
echo -e "\x1b[32m## run shellcheck\x1b[0m"
|
||||||
|
${shellcheck}/bin/shellcheck direnvrc
|
||||||
|
echo -e "\x1b[32m## run black\x1b[0m"
|
||||||
|
LC_ALL=en_US.utf-8 ${python3.pkgs.black}/bin/black --check .
|
||||||
|
echo -e "\x1b[32m## run flake8\x1b[0m"
|
||||||
|
${python3.pkgs.flake8}/bin/flake8 --ignore E501 tests
|
||||||
|
echo -e "\x1b[32m## run mypy\x1b[0m"
|
||||||
|
${mypy}/bin/mypy tests
|
||||||
|
|
||||||
|
echo -e "\x1b[32m## run unittest\x1b[0m"
|
||||||
|
${python3.interpreter} -m unittest discover tests
|
||||||
|
''
|
||||||
Loading…
Add table
Add a link
Reference in a new issue