Skip to content

Commit

Permalink
Add nightly test job and limit pipeline tests
Browse files Browse the repository at this point in the history
Execute e2e tests in pipeline only on a single browser (chromium) to reduce time to production. Add a workflow that runs once per night at 2am and executes e2e tests on all browsers.
  • Loading branch information
mpanne committed Jan 21, 2025
1 parent 553e544 commit c5d76e0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/check-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
type: boolean
description: "Whether to run integration tests (E2E and A11y). Default is true."
default: true
ciE2eTestsOnly:
required: false
type: boolean
description: "If enabled e2e tests only ci tests are executed (e.g. testing only on a single browser)."
default: false

env:
WORKSPACE: "@digitalcheck/${{ inputs.package }}"
Expand Down Expand Up @@ -68,8 +73,13 @@ jobs:
- name: Install E2E & A11y test dependencies
run: npx --yes playwright install --with-deps

- name: Run CI E2E tests
if: inputs.shouldRunIntegrationTests && inputs.ciE2eTestsOnly
id: e2e
run: npm run test:e2e-ci --workspace ${{ env.WORKSPACE }}

- name: Run E2E tests
if: inputs.shouldRunIntegrationTests
if: inputs.shouldRunIntegrationTests && !inputs.ciE2eTestsOnly
id: e2e
run: npm run test:e2e --workspace ${{ env.WORKSPACE }}

Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Nightly Tests

on:
schedule:
- cron: "0 2 * * *" # Runs daily at 2am
# Allow to run this workflow manually
workflow_dispatch:

jobs:
check-test-build-deploy:
strategy:
fail-fast: false
max-parallel: 1
matrix:
package: ${{ fromJSON(needs.changes.outputs.packages) }}
exclude:
- package: shared
uses: ./.github/workflows/check-and-test.yml
with:
package: ${{ matrix.package }}
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/test-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: ./.github/workflows/check-and-test.yml
with:
package: ${{ inputs.package }}
ciE2eTestsOnly: "true"
secrets: inherit

build-and-push-image:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dev:tool-finder": "npm run dev --workspace=packages/tool-finder",
"test": "npm run test --workspaces",
"test:e2e": "npm run test:e2e --workspaces --if-present",
"test:e2e-ci": "npm run test:e2e-ci --workspaces --if-present",
"test:a11y": "npm run test:a11y --workspaces --if-present",
"tests": "npm run tests --workspaces",
"test:generate-coverage": "npm run test:generate-coverage --workspaces --if-present",
Expand Down
1 change: 1 addition & 0 deletions packages/dito/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"lint:fix": "npm run lint:check -- --fix",
"test": "vitest",
"test:e2e": "playwright test tests/e2e --config=tests/playwright.config.ts",
"test:e2e-ci": "playwright test tests/e2e --config=tests/playwright.config.ts --project chromium",
"test:a11y": "playwright test tests/a11y --config=tests/playwright.config.ts",
"test:snapshots": "playwright test tests/snapshots --config=tests/playwright-snapshots.config.ts",
"test:update-snapshots": "playwright test tests/snapshots --config=tests/playwright-snapshots.config.ts --update-snapshots",
Expand Down
1 change: 1 addition & 0 deletions packages/tool-finder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint:fix": "npm run lint:check -- --fix",
"test": "vitest",
"test:e2e": "playwright test tests/playwright/e2e --config=tests/playwright/playwright.config.ts",
"test:e2e-ci": "playwright test tests/playwright/e2e --config=tests/playwright/playwright.config.ts --project chromium",
"test:a11y": "playwright test tests/playwright/a11y --config=tests/playwright/playwright.config.ts",
"tests": "vitest run && npm run test:e2e && npm run test:a11y",
"typecheck": "tsc"
Expand Down

0 comments on commit c5d76e0

Please sign in to comment.