From 0400f09d55016f62009f04c2905b77c40224a808 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 19 Sep 2024 15:21:58 +0200 Subject: [PATCH] .github workflow tests: run those using the packaged wheel --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++----- bugsink/settings/default.py | 4 ++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5436b04..2b88ec7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: branches: [ "main" ] env: - SAMPLES_DIR: "event-samples" + DJANGO_SETTINGS_MODULE: "bugsink.settings.development" jobs: flake8: @@ -40,19 +40,39 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install Dependencies + - name: Install build run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install build + - name: Build wheel + run: | + python -m build --wheel + - name: Install from wheel + run: | + python -m pip install dist/*.whl + - name: Install development dependencies + run: | pip install -r requirements.development.txt - name: Check out event-samples uses: actions/checkout@master with: repository: bugsink/event-samples path: "event-samples" + - name: Create separate dir to avoid accidentally using non-packaged code + run: | + mkdir separate_dir - name: Run Makemigrations --check + working-directory: separate_dir run: | - python manage.py makemigrations --check + bugsink-manage makemigrations --check - name: Run Tests + working-directory: separate_dir + env: + SAMPLES_DIR: "${{ github.workspace }}/event-samples" run: | - python manage.py test -v2 + # because we're outside the project directory, the test discovery won't find our packages. We simply enumerate + # them using some shell-magic. Note that the only non-app that we still care about is 'bugsink' (project, not app) + # which we mention separately + bugsink-manage test `bugsink-manage shell -c 'from django.conf import settings; print(" ".join(settings.BUGSINK_APPS))'` bugsink -v2 + # bugsink-manage test ${GITHUB_WORKSPACE} -v2 # fails with the following, which I don't understand: + # ImportError: 'tests' module incorrectly imported from '/opt/hostedtoolcache/Python/3.10.15/x64/lib/python3.10/site-packages/alerts'. Expected '/home/runner/work/bugsink-private/bugsink-private/alerts'. Is this module globally installed? diff --git a/bugsink/settings/default.py b/bugsink/settings/default.py index fe9885f..3a1fa1b 100644 --- a/bugsink/settings/default.py +++ b/bugsink/settings/default.py @@ -51,7 +51,9 @@ INSTALLED_APPS = [ 'tailwind', # As currently set up, this is also needed in production (templatetags) 'admin_auto_filters', +] +BUGSINK_APPS = [ 'users', 'theme', 'snappea', @@ -67,6 +69,8 @@ INSTALLED_APPS = [ 'performance', ] +INSTALLED_APPS += BUGSINK_APPS + AUTH_USER_MODEL = "users.User" TAILWIND_APP_NAME = 'theme'