Merge pull request #98 from Nebucatnetzer/check

Use nix flake checks for tests
This commit is contained in:
Andreas Zweili 2022-11-27 21:52:40 +01:00 committed by GitHub
commit 8454a56371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
239 changed files with 45 additions and 16 deletions

View File

@ -4,5 +4,5 @@ exclude =
__init__.py,
*cache*,
venv/,
manage.py,
network_inventory/settings/*
src/manage.py,
src/network_inventory/settings/*

View File

@ -14,10 +14,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
- name: Linting
- name: Test
run: |
nix develop --command flake8 . --count --show-source --statistics
- name: Testing
run: |
nix develop --command make test
nix flake check -L

2
.gitignore vendored
View File

@ -175,7 +175,7 @@ migrations/
htmlcov/
.second_run
/static
/src/static
.idea/
db_data
.direnv

View File

@ -7,6 +7,7 @@ run: setup
( \
find . -name __pycache__ -o -name "*.pyc" -delete; \
sudo iptables -I INPUT -p tcp --dport 8000 -j ACCEPT; \
cd src/; \
python manage.py runserver 0.0.0.0:8000; \
)
@ -14,6 +15,7 @@ run: setup
setup:
( \
docker-compose -f docker-compose-development.yml up -d; \
cd src/; \
if [ -f .second_run ]; then \
sleep 2; \
python manage.py collectstatic --noinput; \
@ -47,7 +49,6 @@ setup:
venv:
nix build .#venv -o venv
.PHONY: clean
clean:
docker-compose -f docker-compose-development.yml down -v
@ -67,12 +68,6 @@ init:
python manage.py loaddata network_inventory.yaml; \
)
.PHONY: test
test:
( \
pytest --ds=network_inventory.settings.ram_test -nauto --nomigrations --cov=. --cov-report=html; \
)
.PHONY: debug
debug:
( \

View File

@ -41,8 +41,43 @@
export DJANGO_SETTINGS_MODULE=network_inventory.settings.local
'';
};
checks = {
lint = pkgs.stdenv.mkDerivation {
dontPatch = true;
dontConfigure = true;
dontBuild = true;
dontInstall = true;
doCheck = true;
name = "lint";
src = ./.;
checkInputs = [ pkgs.inventoryEnv ];
checkPhase = ''
mkdir -p $out
flake8 . --count --show-source --statistics
'';
};
tests = pkgs.stdenv.mkDerivation {
dontPatch = true;
dontConfigure = true;
dontBuild = true;
dontInstall = true;
doCheck = true;
name = "test";
src = ./.;
checkInputs = [ pkgs.inventoryEnv ];
checkPhase = ''
mkdir -p $out
pytest --ds=network_inventory.settings.ram_test \
-nauto \
--nomigrations \
--cov=./src \
./src
'';
};
};
packages.venv = pkgs.inventoryEnv;
packages.inventory = pkgs.inventoryPackage;
packages.default = pkgs.inventoryPackage;
}));
}

View File

@ -7,6 +7,9 @@ version = "0.1.0"
description = ""
authors = ["Andreas Zweili <andreas@zweili.ch>"]
license = "GPLv3"
packages = [
{ include = "src" },
]
[tool.poetry.dependencies]
python = "^3.9"

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More