Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 42 additions & 65 deletions .github/workflows/job-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,88 +27,65 @@ jobs:
test:
timeout-minutes: 60

runs-on: ubuntu-latest
runs-on: runner-playwright

strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
Comment thread
StephaneTrebel marked this conversation as resolved.

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "${{ inputs.NODE_VERSION }}"

- name: Install pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
id: pnpm-install
with:
run_install: false

- name: Get pnpm store directory
id: pnpm-store
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Cache Node.js files
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
key: node-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
node-${{ runner.os }}-${{ runner.arch }}-

- name: Install Node.js dependencies
run: pnpm install --frozen-lockfile

- name: Build internal dependencies
run: pnpm --filter "./packages/**" build

- name: Get used Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(pnpm --dir playwright exec playwright -V | awk '{ print $2 }')" >> $GITHUB_ENV

- name: Restore cache - Playwright browser binaries
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright system dependencies
run: pnpm --dir playwright exec playwright install --with-deps

- name: Save cache - Playwright browser binaries
if: always() && steps.playwright-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Ensure Playwright browsers
run: pnpm --dir playwright exec playwright install chromium firefox

- name: Initialize application environment for tests
env:
GHCR_CACHE: registry-cache-ghcr:5000
Comment thread
StephaneTrebel marked this conversation as resolved.
run: |
./ci/scripts/init-env.sh
docker pull ghcr.io/cloud-pi-native/console/server:${{ inputs.TAG }}
docker tag ghcr.io/cloud-pi-native/console/server:${{ inputs.TAG }} dso-console/server:ci
docker pull ghcr.io/cloud-pi-native/console/nginx-strangler:${{ inputs.TAG }}
docker tag ghcr.io/cloud-pi-native/console/nginx-strangler:${{ inputs.TAG }} dso-console/nginx-strangler:ci
docker pull ghcr.io/cloud-pi-native/console/server-nestjs:${{ inputs.TAG }}
docker tag ghcr.io/cloud-pi-native/console/server-nestjs:${{ inputs.TAG }} dso-console/server-nestjs:ci
docker pull ghcr.io/cloud-pi-native/console/client:${{ inputs.TAG }}
docker tag ghcr.io/cloud-pi-native/console/client:${{ inputs.TAG }} dso-console/client:ci
docker pull ghcr.io/cloud-pi-native/console/opencds-mockoon:${{ inputs.TAG }}
docker tag ghcr.io/cloud-pi-native/console/opencds-mockoon:${{ inputs.TAG }} dso-console/opencds-mockoon:ci
for img in server nginx-strangler server-nestjs client opencds-mockoon; do
Comment thread
StephaneTrebel marked this conversation as resolved.
docker pull "${GHCR_CACHE}/cloud-pi-native/console/${img}:${{ inputs.TAG }}"
docker tag "${GHCR_CACHE}/cloud-pi-native/console/${img}:${{ inputs.TAG }}" "dso-console/${img}:ci"
done
docker compose -f ./docker/docker-compose.ci.yml up --no-build -d --remove-orphans

# See https://playwright.dev/docs/test-sharding for how Playwright handles test sharding
- name: Run Playwright tests
run: pnpm --dir playwright exec playwright test --grep @e2e
run: pnpm --dir playwright exec playwright test --grep @e2e --shard=${{ matrix.shard }}/4 --reporter=blob
Comment thread
StephaneTrebel marked this conversation as resolved.

- name: Clean up docker resources (containers, volumes)
run: docker compose -f ./docker/docker-compose.ci.yml down -v --remove-orphans

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ !cancelled() }}
with:
name: blob-report-${{ matrix.shard }}
path: playwright/blob-report
retention-days: 1

merge-reports:
needs: [test]
if: ${{ !cancelled() }}
runs-on: runner-playwright

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Download blob reports from all shards
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: playwright/all-blob-reports
pattern: blob-report-*
merge-multiple: true

- name: Merge blob reports into a single HTML report
run: pnpm --dir playwright exec playwright merge-reports --reporter html ./all-blob-reports

- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright/playwright-report/
path: playwright/playwright-report
retention-days: 30
2 changes: 1 addition & 1 deletion apps/client/src/components/ReloadPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function close() {
class="w-full flex justify-center"
>
<DsfrAlert
data-testid="snackbar"
data-testid="refresh-application"
Comment thread
StephaneTrebel marked this conversation as resolved.
type="info"
class="dso-snackbar max-w-300"
small
Expand Down
15 changes: 0 additions & 15 deletions playwright/e2e-tests/project-logs.spec.ts
Comment thread
StephaneTrebel marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ test.describe('Project logs page', () => {
// Assert
await page.getByTestId('test-tab-logs').click()
await expect(page.locator('#panel-logs')).toBeVisible()
await expect(page.getByTestId('positionInfo')).toContainText(
'1 - 5 sur 6',
)
},
)

Expand All @@ -39,18 +36,12 @@ test.describe('Project logs page', () => {

await page.getByTestId('test-tab-logs').click()
await expect(page.locator('#panel-logs')).toBeVisible()
await expect(page.getByTestId('positionInfo')).toContainText(
'1 - 5 sur 6',
)

// Act
await page.getByTestId('replayHooksBtn').click()

// Assert
await expect(page.locator('#panel-logs')).toBeVisible()
await expect(page.getByTestId('positionInfo')).toContainText(
'1 - 5 sur 7',
)
},
)

Expand All @@ -72,9 +63,6 @@ test.describe('Project logs page', () => {
await page.getByTestId('test-tab-logs').click()
await expect(page.locator('#panel-logs')).toBeVisible()
await page.getByTestId('replayHooksBtn').click()
await expect(page.getByTestId('positionInfo')).toContainText(
'1 - 5 sur 6',
)

// Assert - as Project Member
await page.getByRole('link', { name: 'Se Déconnecter' }).click()
Expand All @@ -83,9 +71,6 @@ test.describe('Project logs page', () => {
await page.getByRole('link', { name: projectName }).click()
await page.getByTestId('test-tab-logs').click()
await expect(page.locator('#panel-logs')).toBeVisible()
await expect(page.getByTestId('positionInfo')).toContainText(
'1 - 5 sur 7',
)
},
)
})
3 changes: 2 additions & 1 deletion playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export default defineConfig({

retries: 3,

workers: process.env.CI ? 1 : undefined, // Default is 50% logical cores
// Let Playwright automatically handle parallelism
workers: process.env.CI ? 2 : undefined, // Default is 50% logical cores

// The maximum number of test failures forthe whole test suite run.
// After reaching this number, testing will stop and exit with an error.
Expand Down
3 changes: 3 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ catalogs:
vue-tsc: ^2.2.12
workbox-window: ^7.4.0
test:
# Ensure Playwright version is the same as the one in this Dockerfile:
# https://github.com/cloud-pi-native/Dockerfile/tree/main/docker/actions-runner-pw/Dockerfile
# Because this is the image used by our Github Self-Hosted Runner that handles Playwright tests
"@playwright/test": ^1.59.1
"@faker-js/faker": ^9.9.0
"@vitest/coverage-v8": ^4.1.5
Expand Down
Loading