Skip to content

Commit

Permalink
Add Playwright workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Stormheg committed Nov 29, 2024
1 parent 386e033 commit 2d6b701
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ on:
workflow_dispatch:

jobs:
nightly-e2e:
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
# See: https://github.com/actions/runner/issues/520
if: ${{ github.repository == 'Stormbase/django-otp-webauthn' }}
uses: ./.github/workflows/playwright-tests.yml
nightly-test:
# Cannot check the existence of secrets, so limiting to repository name to prevent all forks to run nightly.
# See: https://github.com/actions/runner/issues/520
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/playwright-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Playwright Tests
on:
workflow_call:
workflow_dispatch:

env:
FORCE_COLOR: "1" # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_NO_PYTHON_VERSION_WARNING: "1"

jobs:
playwright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.13"
cache: "pip"
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Install additional system packages
run: |
sudo apt-get update -y
# Need `gettext` to compile translations
sudo apt-get install gettext
- name: Install dependencies
run: |
yarn install --frozen-lockfile
- name: Compile JavaScript
run: |
yarn build
- name: Install dependencies
run: |
python -m pip install .[testing,playwright]
- name: Compile translations
run: /bin/sh ./scripts/compile_translations.sh
- name: Run E2E tests
run: |
/bin/sh ./scripts/run_e2e_testsuite.sh
- name: Upload Playwright traces
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-traces
path: test-results/
retention-days: 3
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ jobs:
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

e2e_tests:
name: End-to-End Tests
uses: ./.github/workflows/playwright-tests.yml
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ testing = [
"pytest-mock>=3.14,<4",
"jsonschema ~= 4.23",
]
playwright = ["pytest-playwright>=0.5.2,<1", "playwright>=1.49,<2"]
playwright = [
"playwright>=1.49,<2",
"pytest-playwright>=0.5.2,<1",
]

[project.urls]
# TODO: documentation link
Expand Down Expand Up @@ -131,6 +134,7 @@ known-first-party = ["django_otp_webauthn", "sandbox", "tests"]
pythonpath = "sandbox"
DJANGO_SETTINGS_MODULE = "settings"
testpaths = "tests/"
norecursedirs = ["tests/e2e"]
addopts = "--reuse-db"

[tool.coverage.run]
Expand Down

0 comments on commit 2d6b701

Please sign in to comment.