Skip to content
Draft
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
209 changes: 156 additions & 53 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

name: Playwright Tests

on: pull_request
on:
pull_request:
# Pushes only refresh the shared node_modules cache, pull requests can not share caches with each other
push:
branches:
- master
- stable*

permissions:
contents: read
Expand All @@ -13,36 +19,103 @@ concurrency:
cancel-in-progress: true

jobs:
changes:
if: github.event_name == 'pull_request'
runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST_LOW || '"ubuntu-latest-low"') }}
permissions:
contents: read
pull-requests: read

outputs:
frontend: ${{ steps.changes.outputs.frontend }}

steps:
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
continue-on-error: true
with:
# Inputs of `npm run build`, without changes to them the committed assets are up to date
filters: |
frontend:
- 'apps/*/css/**'
- 'apps/*/img/**'
- 'apps/*/src/**'
- 'build/icons.mjs'
- 'build/npm-post-build.sh'
- 'core/css/**'
- 'core/img/**'
- 'core/src/**'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'vite.config.ts'

playwright-setup:
needs: [changes]
# On pull requests only needed to build changed assets, on pushes it only refreshes the node_modules cache
if: >-
!cancelled()
&& (github.event_name == 'push' || needs.changes.outputs.frontend != 'false')
timeout-minutes: 15
name: Playwright setup
runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST || '"ubuntu-latest"') }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
submodules: true # for 3rdparty

- name: Read package.json
uses: nextcloud-libraries/parse-package-engines-action@39fcc545a815c353dd0a3fd8fd2ef6e59fd02b92 # v0.2.0
id: versions

- name: Set up node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ steps.versions.outputs.node-version }}

- name: Set up npm
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'
- name: Install dependencies and build
run: |
npm ci
npm run build --if-present
- name: Save context

- name: Restore node_modules
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-node-modules-${{ runner.os }}-node${{ steps.versions.outputs.node-version }}-${{ hashFiles('package-lock.json') }}
path: node_modules

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

- name: Save node_modules
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-context-${{ github.run_id }}
path: ./
key: ${{ steps.cache.outputs.cache-primary-key }}
path: node_modules

- name: Build assets
if: github.event_name == 'pull_request'
run: npm run build

- name: Upload assets
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: playwright-assets
path: |
dist/
core/css/*.css
apps/*/css/*.css
retention-days: 1

playwright-tests:
needs: [playwright-setup]
needs: [changes, playwright-setup]
if: >-
!cancelled()
&& github.event_name == 'pull_request'
&& needs.changes.result == 'success'
&& (needs.playwright-setup.result == 'success' || needs.playwright-setup.result == 'skipped')
timeout-minutes: 60
name: Playwright tests ${{ matrix.shardIndex }} / ${{ matrix.shardTotal }}
runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST || '"ubuntu-latest"') }}
Expand All @@ -51,20 +124,9 @@ jobs:
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8]
outputs:
node-version: ${{ steps.versions.outputs.node-version }}
package-manager-version: ${{ steps.versions.outputs.package-manager-version }}

steps:
- name: Restore context
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-context-${{ github.run_id }}
path: ./

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.cache.outputs.cache-hit != 'true'
with:
persist-credentials: false
submodules: true # for 3rdparty
Expand All @@ -81,11 +143,32 @@ jobs:
- name: Set up npm
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'

- name: Install dependencies and build
- name: Restore node_modules
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-node-modules-${{ runner.os }}-node${{ steps.versions.outputs.node-version }}-${{ hashFiles('package-lock.json') }}
path: node_modules

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm ci
npm run build --if-present
run: npm ci

- name: Remove committed assets
if: needs.playwright-setup.result == 'success'
run: rm -rf dist

- name: Download assets built from this pull request
if: needs.playwright-setup.result == 'success'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: playwright-assets
path: ./

- name: Compile app styles
if: needs.playwright-setup.result == 'skipped'
# Only dist/ and core/css are recompiled after merges, so committed app styles can be outdated
run: npm run sass

- name: Install Playwright browsers
run: npm run playwright:install-ci --if-present
Expand All @@ -112,7 +195,12 @@ jobs:
retention-days: 1

playwright-installer-tests:
needs: [playwright-setup]
needs: [changes, playwright-setup]
if: >-
!cancelled()
&& github.event_name == 'pull_request'
&& needs.changes.result == 'success'
&& (needs.playwright-setup.result == 'success' || needs.playwright-setup.result == 'skipped')
timeout-minutes: 30
name: Playwright tests for installer
runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST || '"ubuntu-latest"') }}
Expand Down Expand Up @@ -163,15 +251,7 @@ jobs:
options: --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10

steps:
- name: Restore context
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-context-${{ github.run_id }}
path: ./

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.cache.outputs.cache-hit != 'true'
with:
persist-credentials: false
submodules: true # for 3rdparty
Expand All @@ -188,11 +268,32 @@ jobs:
- name: Set up npm
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'

- name: Install dependencies and build
- name: Restore node_modules
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-node-modules-${{ runner.os }}-node${{ steps.versions.outputs.node-version }}-${{ hashFiles('package-lock.json') }}
path: node_modules

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm ci
npm run build --if-present
run: npm ci

- name: Remove committed assets
if: needs.playwright-setup.result == 'success'
run: rm -rf dist

- name: Download assets built from this pull request
if: needs.playwright-setup.result == 'success'
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: playwright-assets
path: ./

- name: Compile app styles
if: needs.playwright-setup.result == 'skipped'
# Only dist/ and core/css are recompiled after merges, so committed app styles can be outdated
run: npm run sass

- name: Install Playwright browsers
run: npm run playwright:install-ci --if-present
Expand Down Expand Up @@ -222,31 +323,33 @@ jobs:

merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
needs: [playwright-tests, playwright-installer-tests]

runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST_LOW || '"ubuntu-latest-low"') }}
steps:
- name: Restore context
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-context-${{ github.run_id }}
path: ./

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.cache.outputs.cache-hit != 'true'
with:
persist-credentials: false

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
if: steps.cache.outputs.cache-hit != 'true'
- name: Read package.json
uses: nextcloud-libraries/parse-package-engines-action@39fcc545a815c353dd0a3fd8fd2ef6e59fd02b92 # v0.2.0
id: versions

- name: Set up node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ needs.playwright-tests.outputs.node-version }}
node-version: ${{ steps.versions.outputs.node-version }}

- name: Set up npm
if: steps.cache.outputs.cache-hit != 'true'
run: npm i -g 'npm@${{ needs.playwright-tests.outputs.package-manager-version }}'
run: npm i -g 'npm@${{ steps.versions.outputs.package-manager-version }}'

- name: Restore node_modules
id: cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: playwright-node-modules-${{ runner.os }}-node${{ steps.versions.outputs.node-version }}-${{ hashFiles('package-lock.json') }}
path: node_modules

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -281,7 +384,7 @@ jobs:
runs-on: ${{ fromJSON(vars.RUNS_ON_UBUNTU_LATEST_LOW || '"ubuntu-latest-low"') }}
needs: [playwright-tests, playwright-installer-tests]

if: always()
if: always() && github.event_name == 'pull_request'

name: playwright-test-summary

Expand Down
Loading