switch to gh actions for tests
This commit is contained in:
parent
492701ec62
commit
f44c92f0d3
|
@ -0,0 +1,56 @@
|
|||
name: Tests CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup virtual env and install requirements
|
||||
run: |
|
||||
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS pipeline'
|
||||
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS test_pipeline'
|
||||
sudo -u postgres psql -c 'CREATE DATABASE pipeline'
|
||||
sudo -u postgres psql -c "SET client_encoding = 'UTF8'" pipeline
|
||||
pwd
|
||||
rm -rf /actions-runner/_work/trmm-actions/trmm-actions/api/env
|
||||
cd api
|
||||
python3.10 -m venv env
|
||||
source env/bin/activate
|
||||
cd tacticalrmm
|
||||
python --version
|
||||
SETTINGS_FILE="tacticalrmm/settings.py"
|
||||
SETUPTOOLS_VER=$(grep "^SETUPTOOLS_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
|
||||
WHEEL_VER=$(grep "^WHEEL_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
|
||||
pip install --upgrade pip
|
||||
pip install setuptools==${SETUPTOOLS_VER} wheel==${WHEEL_VER}
|
||||
pip install -r requirements.txt -r requirements-test.txt
|
||||
|
||||
- name: Run django tests
|
||||
env:
|
||||
GHACTIONS: "yes"
|
||||
run: |
|
||||
cd api/tacticalrmm
|
||||
source ../env/bin/activate
|
||||
coverage run manage.py test -v 2
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Codestyle black
|
||||
run: |
|
||||
cd api
|
||||
source env/bin/activate
|
||||
black --exclude migrations/ --check tacticalrmm
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
|
@ -52,6 +52,29 @@ REST_KNOX = {
|
|||
"MIN_REFRESH_INTERVAL": 600,
|
||||
}
|
||||
|
||||
if "GHACTIONS" in os.environ:
|
||||
print("-----------------------PIPELINE----------------------------")
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": "pipeline",
|
||||
"USER": "pipeline",
|
||||
"PASSWORD": "pipeline123456",
|
||||
"HOST": "127.0.0.1",
|
||||
"PORT": "",
|
||||
}
|
||||
}
|
||||
SECRET_KEY = "abcdefghijklmnoptravis123456789"
|
||||
DEBUG = False
|
||||
ALLOWED_HOSTS = ["api.example.com"]
|
||||
ADMIN_URL = "abc123456/"
|
||||
CORS_ORIGIN_WHITELIST = ["https://rmm.example.com"]
|
||||
MESH_USERNAME = "pipeline"
|
||||
MESH_SITE = "https://example.com"
|
||||
MESH_TOKEN_KEY = "bd65e957a1e70c622d32523f61508400d6cd0937001a7ac12042227eba0b9ed625233851a316d4f489f02994145f74537a331415d00047dbbf13d940f556806dffe7a8ce1de216dc49edbad0c1a7399c"
|
||||
REDIS_HOST = "localhost"
|
||||
ADMIN_ENABLED = False
|
||||
|
||||
try:
|
||||
from .local_settings import *
|
||||
except ImportError:
|
||||
|
@ -74,11 +97,11 @@ SPECTACULAR_SETTINGS = {
|
|||
"AUTHENTICATION_WHITELIST": ["tacticalrmm.auth.APIAuthentication"],
|
||||
}
|
||||
|
||||
if not "AZPIPELINE" in os.environ:
|
||||
if not DEBUG: # type: ignore
|
||||
REST_FRAMEWORK.update(
|
||||
{"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",)}
|
||||
)
|
||||
|
||||
if not DEBUG: # type: ignore
|
||||
REST_FRAMEWORK.update(
|
||||
{"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",)}
|
||||
)
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
|
@ -93,6 +116,7 @@ MIDDLEWARE = [
|
|||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||
]
|
||||
|
||||
|
||||
if ADMIN_ENABLED: # type: ignore
|
||||
MIDDLEWARE += ("django.contrib.messages.middleware.MessageMiddleware",)
|
||||
|
||||
|
@ -129,26 +153,23 @@ INSTALLED_APPS = [
|
|||
"drf_spectacular",
|
||||
]
|
||||
|
||||
if not "AZPIPELINE" in os.environ:
|
||||
if DEBUG: # type: ignore
|
||||
INSTALLED_APPS += (
|
||||
"django_extensions",
|
||||
"silk",
|
||||
)
|
||||
|
||||
MIDDLEWARE.insert(0, "silk.middleware.SilkyMiddleware")
|
||||
if DEBUG: # type: ignore
|
||||
INSTALLED_APPS += (
|
||||
"django_extensions",
|
||||
"silk",
|
||||
)
|
||||
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [(REDIS_HOST, 6379)], # type: ignore
|
||||
},
|
||||
MIDDLEWARE.insert(0, "silk.middleware.SilkyMiddleware")
|
||||
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
"CONFIG": {
|
||||
"hosts": [(REDIS_HOST, 6379)], # type: ignore
|
||||
},
|
||||
}
|
||||
|
||||
if "AZPIPELINE" in os.environ:
|
||||
ADMIN_ENABLED = False
|
||||
},
|
||||
}
|
||||
|
||||
if ADMIN_ENABLED: # type: ignore
|
||||
INSTALLED_APPS += (
|
||||
|
@ -231,39 +252,3 @@ LOGGING = {
|
|||
"django.request": {"handlers": ["file"], "level": "ERROR", "propagate": True}
|
||||
},
|
||||
}
|
||||
|
||||
if "AZPIPELINE" in os.environ:
|
||||
print("PIPELINE")
|
||||
print("test2")
|
||||
DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.postgresql",
|
||||
"NAME": "pipeline",
|
||||
"USER": "pipeline",
|
||||
"PASSWORD": "pipeline123456",
|
||||
"HOST": "127.0.0.1",
|
||||
"PORT": "",
|
||||
}
|
||||
}
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
"DATETIME_FORMAT": "%b-%d-%Y - %H:%M",
|
||||
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
|
||||
"DEFAULT_AUTHENTICATION_CLASSES": (
|
||||
"knox.auth.TokenAuthentication",
|
||||
"tacticalrmm.auth.APIAuthentication",
|
||||
),
|
||||
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
|
||||
}
|
||||
|
||||
ALLOWED_HOSTS = ["api.example.com"]
|
||||
DEBUG = True
|
||||
SECRET_KEY = "abcdefghijklmnoptravis123456789"
|
||||
|
||||
ADMIN_URL = "abc123456/"
|
||||
|
||||
SCRIPTS_DIR = os.path.join(Path(BASE_DIR).parents[1], "scripts")
|
||||
MESH_USERNAME = "pipeline"
|
||||
MESH_SITE = "https://example.com"
|
||||
MESH_TOKEN_KEY = "bd65e957a1e70c622d32523f61508400d6cd0937001a7ac12042227eba0b9ed625233851a316d4f489f02994145f74537a331415d00047dbbf13d940f556806dffe7a8ce1de216dc49edbad0c1a7399c"
|
||||
REDIS_HOST = "localhost"
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
trigger:
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
- job: setup_env
|
||||
displayName: "Setup"
|
||||
strategy:
|
||||
matrix:
|
||||
Debian10:
|
||||
AGENT_NAME: "az-pipeline-fran"
|
||||
|
||||
pool:
|
||||
name: linux-vms
|
||||
demands:
|
||||
- agent.name -equals $(AGENT_NAME)
|
||||
|
||||
steps:
|
||||
- script: |
|
||||
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS pipeline'
|
||||
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS test_pipeline'
|
||||
sudo -u postgres psql -c 'CREATE DATABASE pipeline'
|
||||
sudo -u postgres psql -c "SET client_encoding = 'UTF8'" pipeline
|
||||
SETTINGS_FILE="/myagent/_work/3/s/api/tacticalrmm/tacticalrmm/settings.py"
|
||||
rm -rf /myagent/_work/3/s/api/env
|
||||
cd /myagent/_work/3/s/api
|
||||
python3.10 -m venv env
|
||||
source env/bin/activate
|
||||
cd /myagent/_work/3/s/api/tacticalrmm
|
||||
pip install --upgrade pip
|
||||
SETUPTOOLS_VER=$(grep "^SETUPTOOLS_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
|
||||
WHEEL_VER=$(grep "^WHEEL_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
|
||||
pip install setuptools==${SETUPTOOLS_VER} wheel==${WHEEL_VER}
|
||||
pip install -r requirements.txt -r requirements-test.txt
|
||||
displayName: "Install Python Dependencies"
|
||||
|
||||
- script: |
|
||||
cd /myagent/_work/3/s/api
|
||||
source env/bin/activate
|
||||
cd /myagent/_work/3/s/api/tacticalrmm
|
||||
coverage run manage.py test -v 2
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
displayName: "Run django tests"
|
||||
|
||||
- script: |
|
||||
cd /myagent/_work/3/s/api
|
||||
source env/bin/activate
|
||||
black --exclude migrations/ --check tacticalrmm
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
displayName: "Codestyle black"
|
||||
|
||||
- script: |
|
||||
cd /myagent/_work/3/s/api
|
||||
source env/bin/activate
|
||||
cd /myagent/_work/3/s/api/tacticalrmm
|
||||
export CIRCLE_BRANCH=$BUILD_SOURCEBRANCH
|
||||
coveralls
|
||||
displayName: "coveralls"
|
||||
env:
|
||||
CIRCLECI: 1
|
||||
CIRCLE_BUILD_NUM: $(Build.BuildNumber)
|
Loading…
Reference in New Issue