From df16af78fc83392383e4b1036eb86a67e985b290 Mon Sep 17 00:00:00 2001 From: Anders Harrisson <anders.harrisson@ess.eu> Date: Mon, 30 Sep 2024 09:28:35 +0200 Subject: [PATCH] Run unit tests in GitLab CI pipeline --- .gitlab-ci.yml | 24 +++++++++++++++++++++++- tests/configuration.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/configuration.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c45407..894a676 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ stages: # - check - build - # - test + - test # - analyse - release @@ -22,6 +22,28 @@ build-package: paths: - dist/ +test: + stage: test + image: python:3 + services: + - name: redis + variables: + HEALTHCHECK_TCP_PORT: "6379" + - name: postgres + variables: + POSTGRES_DB: netbox + POSTGRES_USER: netbox + POSTGRES_PASSWORD: netbox + HEALTHCHECK_TCP_PORT: "5432" + before_script: + - pip install . + - git clone --depth 1 --branch v3.7.8 --single-branch https://github.com/netbox-community/netbox.git + - pip install --upgrade --requirement netbox/requirements.txt + - ln -s $(pwd)/tests/configuration.py netbox/netbox/netbox/configuration.py + script: + - cd netbox + - python netbox/manage.py test netbox_awx_plugin + release-package: stage: release image: python:3 diff --git a/tests/configuration.py b/tests/configuration.py new file mode 100644 index 0000000..c7f1f1b --- /dev/null +++ b/tests/configuration.py @@ -0,0 +1,36 @@ +ALLOWED_HOSTS = ["*"] + +DATABASE = { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'netbox', + 'USER': 'netbox', + 'PASSWORD': 'netbox', + 'HOST': 'postgres', + 'PORT': '', + 'CONN_MAX_AGE': 300, +} + +REDIS = { + 'tasks': { + 'HOST': 'redis', + 'PORT': 6379, + 'USERNAME': '', + 'PASSWORD': '', + 'DATABASE': 0, + 'SSL': False, + }, + 'caching': { + 'HOST': 'redis', + 'PORT': 6379, + 'USERNAME': '', + 'PASSWORD': '', + 'DATABASE': 1, + 'SSL': False, + } +} + +SECRET_KEY = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' + +PLUGINS = [ + "netbox_awx_plugin", +] -- GitLab