feat(e2e): add Playwright e2e tests for first-run wizard and settings page #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | |
| # SPDX-License-Identifier: AGPL-3.0-or-later | |
| name: E2E Tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| - stable* | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: e2e-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-latest-low | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| src: ${{ steps.changes.outputs.src }} | |
| steps: | |
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 | |
| id: changes | |
| continue-on-error: true | |
| with: | |
| filters: | | |
| src: | |
| - '.github/workflows/e2e.yml' | |
| - 'appinfo/**' | |
| - 'lib/**' | |
| - 'src/**' | |
| - 'templates/**' | |
| - 'e2e/**' | |
| - 'playwright.config.ts' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| matrix: | |
| runs-on: ubuntu-latest-low | |
| outputs: | |
| server-max: ${{ steps.versions.outputs.branches-max-list }} | |
| steps: | |
| - name: Checkout app | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Get version matrix | |
| id: versions | |
| uses: icewind1991/nextcloud-version-matrix@8a7bac6300b2f0f3100088b297995a229558ddba # v1.3.2.3.1.3.2 | |
| e2e-tests: | |
| runs-on: ubuntu-latest | |
| needs: [changes, matrix] | |
| if: needs.changes.outputs.src != 'false' | |
| strategy: | |
| matrix: | |
| server-versions: ${{ fromJson(needs.matrix.outputs.server-max) }} | |
| env: | |
| APP_NAME: firstrunwizard | |
| NEXTCLOUD_URL: http://localhost:8080 | |
| name: Playwright E2E (Nextcloud ${{ matrix.server-versions }}) | |
| steps: | |
| - name: Set app env | |
| if: ${{ env.APP_NAME == '' }} | |
| run: | | |
| # Split and keep last | |
| echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | |
| - name: Checkout server | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| submodules: true | |
| repository: nextcloud/server | |
| ref: ${{ matrix.server-versions }} | |
| - name: Checkout app | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| path: apps/${{ env.APP_NAME }} | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2.37.0 | |
| with: | |
| php-version: '8.3' | |
| extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite | |
| coverage: none | |
| ini-file: development | |
| ini-values: disable_functions= | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Nextcloud | |
| run: | | |
| mkdir data | |
| ./occ maintenance:install \ | |
| --verbose \ | |
| --database=sqlite \ | |
| --database-name=nextcloud \ | |
| --database-host=127.0.0.1 \ | |
| --database-user=root \ | |
| --database-pass=rootpassword \ | |
| --admin-user admin \ | |
| --admin-pass admin | |
| ./occ app:enable --force ${{ env.APP_NAME }} | |
| ./occ config:system:set --value true debug | |
| - name: Run Nextcloud | |
| run: php -S localhost:8080 & | |
| - name: Read package.json node and npm engines version | |
| uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 | |
| id: versions | |
| with: | |
| path: apps/${{ env.APP_NAME }} | |
| fallbackNode: '^24' | |
| fallbackNpm: '^11.3' | |
| - name: Set up node ${{ steps.versions.outputs.nodeVersion }} | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: ${{ steps.versions.outputs.nodeVersion }} | |
| - name: Set up npm ${{ steps.versions.outputs.npmVersion }} | |
| run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' | |
| - name: Install dependencies | |
| working-directory: apps/${{ env.APP_NAME }} | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| working-directory: apps/${{ env.APP_NAME }} | |
| run: npx playwright install chromium --with-deps | |
| - name: Build assets | |
| working-directory: apps/${{ env.APP_NAME }} | |
| run: npm run build | |
| - name: Enable app assets | |
| run: ./occ maintenance:update:htaccess | |
| - name: Run E2E tests | |
| working-directory: apps/${{ env.APP_NAME }} | |
| run: npm run test:e2e | |
| env: | |
| NEXTCLOUD_URL: ${{ env.NEXTCLOUD_URL }} | |
| NEXTCLOUD_ADMIN_USER: admin | |
| NEXTCLOUD_ADMIN_PASSWORD: admin | |
| - name: Upload Playwright report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report | |
| path: apps/${{ env.APP_NAME }}/playwright-report/ | |
| retention-days: 30 | |
| - name: Print Nextcloud logs | |
| if: always() | |
| run: cat data/nextcloud.log 2>/dev/null || true | |
| summary: | |
| permissions: | |
| contents: none | |
| runs-on: ubuntu-latest-low | |
| needs: [changes, matrix, e2e-tests] | |
| if: always() | |
| name: e2e-summary | |
| steps: | |
| - name: Summary status | |
| run: if ${{ needs.changes.outputs.src != 'false' && needs.e2e-tests.result != 'success' }}; then exit 1; fi |