Skip to content

Commit

Permalink
Attempt to run in Github Action
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamHawtin committed Nov 18, 2024
1 parent 875228f commit 13f6c9f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,58 @@ jobs:
- uses: actions/checkout@v4
- name: Build Docker Image
run: docker build --target web -t ons .

functional_tests:
runs-on: ubuntu-latest
needs:
- lint
- lint-front-end
- compile_static

env:
DJANGO_SETTINGS_MODULE: cms.settings.functional_test
DATABASE_URL: postgres://postgres:postgres@localhost/postgres # pragma: allowlist secret
ENABLE_DJANGO_DEFENDER: 'false'
POSTGRES_HOST_AUTH_METHOD: trust
SECRET_KEY: fake_secret_key_to_run_tests # pragma: allowlist secret

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

# Do we need Redis?

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==${{ env.POETRY_VERSION }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry

- name: Install dependencies
run: make install-dev

- uses: actions/download-artifact@v4
with:
name: static
path: cms/static_compiled/

- name: Fetch Design System templates
run: make load-design-system-templates

- name: Collect Static Files
run: poetry run ./manage.py collectstatic --verbosity 0 --noinput --clear

- name: Run Functional Tests
run: poetry run behave functional_tests
8 changes: 7 additions & 1 deletion functional_tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def before_all(context: Context):
"""Runs once before all tests.
Sets up playwright browser and context to be used in all scenarios.
"""
# Ensure Django uses the functional test settings
os.environ["DJANGO_SETTINGS_MODULE"] = "cms.settings.functional_test"

# This is required for Django to run within a Poetry shell
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "True"

# Register our django test runner so the entire test run is wrapped in a django test runner
use_fixture(django_test_runner, context=context)

Expand Down Expand Up @@ -42,7 +48,7 @@ def before_all(context: Context):

def after_all(context: Context):
"""Runs once after all tests.
Cleans up playwright browser context.
Cleans up playwright objects.
"""
context.browser_context.close()
context.browser.close()
Expand Down

0 comments on commit 13f6c9f

Please sign in to comment.