diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..cb297e3 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,112 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install "Django>=4.2,<5" coverage + env: + PYTHONPATH: . + + - name: Run unit tests + run: | + coverage run -m unittest coldfront_notifications.tests.test_unit -v + coverage report --show-missing --fail-under=80 \ + --include="coldfront_notifications/resolvers.py,coldfront_notifications/validators.py,coldfront_notifications/conf.py,coldfront_notifications/__init__.py" + env: + PYTHONPATH: . + + - name: Upload coverage + if: matrix.python-version == '3.10' + uses: actions/upload-artifact@v4 + with: + name: unit-coverage + path: .coverage + + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + pip install --upgrade pip + pip install flake8 + + - name: Flake8 + run: | + flake8 coldfront_notifications/ \ + --max-line-length=120 \ + --exclude=migrations,__pycache__,tests \ + --ignore=E501,W503,E402,E241,E221,E231,W292 + + build: + name: Build Package + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install build tools + run: pip install build twine + + - name: Build + run: python -m build + + - name: Check package + run: twine check dist/* + + - name: Verify wheel contents + run: | + pip install dist/*.whl + python -c " + import django + from django.conf import settings + settings.configure( + INSTALLED_APPS=[ + 'django.contrib.contenttypes', + 'django.contrib.auth', + 'django.contrib.admin', + 'django.contrib.sessions', + 'django.contrib.messages', + 'coldfront_notifications', + ], + DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}, + DEFAULT_AUTO_FIELD='django.db.models.BigAutoField', + AUTH_USER_MODEL='auth.User', + ROOT_URLCONF='coldfront_notifications.urls', + ) + django.setup() + from coldfront_notifications import urls, models, views, resolvers, validators, tasks, conf + print('All modules importable') + " diff --git a/.gitignore b/.gitignore index c5b94ff..0f03392 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ htmlcov/ # Logs *.log +management diff --git a/README.md b/README.md index 2f9edb9..d9bd789 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,16 @@ for url_prefix, module, namespace in getattr(settings, "EXTRA_APPS_URLS", []): python manage.py migrate coldfront_notifications ``` +### Add the navbar dropdown + +Add this line to your ColdFront `authorized_navbar.html` (typically in `templates/common/authorized_navbar.html`), inside the `