Skip to content

Commit

Permalink
Merge pull request #77 from svpernova09/tests-gha
Browse files Browse the repository at this point in the history
Add test run script and GHA for CICD
  • Loading branch information
bradmontgomery committed Aug 9, 2023
2 parents 9dea5f9 + f0fcb26 commit fcf26fc
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 31 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/setup-and-run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup django-redis-metrics and run tests

on: push

jobs:
setup-and-run-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"

- name: Run make install_requirements
run: make install_requirements

- name: run make test
run: make test
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ build:

.PHONY: upload
upload:
python -m twine upload --repository pypi dist/*
python -m twine upload --repository pypi dist/*

.PHONY: test
test:
python runtest.py

.PHONY: install_requirements
install_requirements:
pip install --upgrade pip
pip install --upgrade pip-tools
pip install -r requirements.txt
14 changes: 7 additions & 7 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --config=pyproject.toml --no-emit-index-url --output-file=docs/requirements.txt docs/requirements.in
# pip-compile --no-emit-index-url --output-file=docs/requirements.txt docs/requirements.in
#
alabaster==0.7.13
# via sphinx
Expand Down Expand Up @@ -32,7 +32,7 @@ packaging==23.1
# via
# build
# sphinx
pip-tools==7.2.0
pip-tools==7.3.0
# via -r docs/requirements.in
pygments==2.16.1
# via sphinx
Expand All @@ -50,17 +50,17 @@ sphinx==7.1.2
# sphinxcontrib-htmlhelp
# sphinxcontrib-qthelp
# sphinxcontrib-serializinghtml
sphinxcontrib-applehelp==1.0.5
sphinxcontrib-applehelp==1.0.6
# via sphinx
sphinxcontrib-devhelp==1.0.3
sphinxcontrib-devhelp==1.0.4
# via sphinx
sphinxcontrib-htmlhelp==2.0.2
sphinxcontrib-htmlhelp==2.0.3
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.4
sphinxcontrib-qthelp==1.0.5
# via sphinx
sphinxcontrib-serializinghtml==1.1.6
sphinxcontrib-serializinghtml==1.1.7
# via sphinx
urllib3==2.0.4
# via requests
Expand Down
6 changes: 4 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ isort
coverage
redis
django
django-redis
django-user-sessions
sphinx
toml; python_version < '3.11'
twine
toml
twine
39 changes: 18 additions & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ alabaster==0.7.13
# via sphinx
asgiref==3.7.2
# via django
async-timeout==4.0.2
# via redis
babel==2.12.1
# via sphinx
black==23.7.0
Expand All @@ -22,8 +20,6 @@ build==0.10.0
# pip-tools
certifi==2023.7.22
# via requests
cffi==1.15.1
# via cryptography
charset-normalizer==3.2.0
# via requests
click==8.1.6
Expand All @@ -32,9 +28,14 @@ click==8.1.6
# pip-tools
coverage==7.2.7
# via -r requirements.in
cryptography==41.0.3
# via secretstorage
django==4.2.4
# via
# -r requirements.in
# django-redis
# django-user-sessions
django-redis==5.3.0
# via -r requirements.in
django-user-sessions==2.0.0
# via -r requirements.in
docutils==0.20.1
# via
Expand All @@ -54,10 +55,6 @@ isort==5.12.0
# via -r requirements.in
jaraco-classes==3.3.0
# via keyring
jeepney==0.8.0
# via
# keyring
# secretstorage
jinja2==3.1.2
# via sphinx
keyring==24.2.0
Expand All @@ -81,16 +78,14 @@ packaging==23.1
# sphinx
pathspec==0.11.2
# via black
pip-tools==7.2.0
pip-tools==7.3.0
# via -r requirements.in
pkginfo==1.9.6
# via twine
platformdirs==3.10.0
# via black
pycodestyle==2.11.0
# via flake8
pycparser==2.21
# via cffi
pyflakes==3.1.0
# via flake8
pygments==2.16.1
Expand All @@ -103,7 +98,9 @@ pyproject-hooks==1.0.0
readme-renderer==40.0
# via twine
redis==4.6.0
# via -r requirements.in
# via
# -r requirements.in
# django-redis
requests==2.31.0
# via
# requests-toolbelt
Expand All @@ -115,8 +112,6 @@ rfc3986==2.0.0
# via twine
rich==13.5.2
# via twine
secretstorage==3.3.3
# via keyring
six==1.16.0
# via bleach
snowballstemmer==2.2.0
Expand All @@ -129,20 +124,22 @@ sphinx==7.1.2
# sphinxcontrib-htmlhelp
# sphinxcontrib-qthelp
# sphinxcontrib-serializinghtml
sphinxcontrib-applehelp==1.0.5
sphinxcontrib-applehelp==1.0.6
# via sphinx
sphinxcontrib-devhelp==1.0.3
sphinxcontrib-devhelp==1.0.4
# via sphinx
sphinxcontrib-htmlhelp==2.0.2
sphinxcontrib-htmlhelp==2.0.3
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-qthelp==1.0.4
sphinxcontrib-qthelp==1.0.5
# via sphinx
sphinxcontrib-serializinghtml==1.1.6
sphinxcontrib-serializinghtml==1.1.7
# via sphinx
sqlparse==0.4.4
# via django
toml==0.10.2
# via -r requirements.in
twine==4.0.2
# via -r requirements.in
urllib3==2.0.4
Expand Down
48 changes: 48 additions & 0 deletions runtest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python
import sys

try:
import django
from django.conf import settings
from django.test.utils import get_runner

settings.configure(
DEBUG=True,
USE_TZ=True,
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
}
},
ROOT_URLCONF="redis_metrics.urls",
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"user_sessions",
"django_redis",
"django.contrib.sessions",
"redis_metrics",
],
MIDDLEWARE=[
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
],
SECRET_KEY="notasecret",
NOSE_ARGS=["-s"],
TEMPLATES=[
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["redis_metrics/templatetags", "redis_metrics/templates"],
}
],
)
django.setup()
except ImportError:
raise ImportError("To fix this error, run: pip install -r requirements.txt")


if __name__ == "__main__":
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["redis_metrics.tests"])
sys.exit(bool(failures))

0 comments on commit fcf26fc

Please sign in to comment.