From ead1ebc2aa0ffa9e1468f127f12159c6d05ccd11 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Mon, 16 Jun 2025 20:45:36 +0000 Subject: [PATCH] ci: update cypress.yml workflow from template Signed-off-by: Nextcloud bot --- .github/workflows/cypress.yml | 105 ++++++---------------------------- 1 file changed, 17 insertions(+), 88 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index cd22fa0889b..dd4d93a4c1a 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -22,7 +22,7 @@ env: # Usually it's the base branch of the PR, but for pushes it's the branch itself. # e.g. 'main', 'stable27' or 'feature/my-feature' # n.b. server will use head_ref, as we want to test the PR branch. - BRANCH: ${{ github.head_ref || github.ref_name }} + BRANCH: ${{ github.base_ref || github.ref_name }} permissions: @@ -36,8 +36,6 @@ jobs: npmVersion: ${{ steps.versions.outputs.npmVersion }} env: - # We'll install cypress in the cypress job - CYPRESS_INSTALL_BINARY: 0 PUPPETEER_SKIP_DOWNLOAD: true steps: @@ -47,12 +45,10 @@ jobs: echo 'Can not run cypress on forks' exit 1 - - name: Checkout server + - name: Checkout app uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - # We need to checkout submodules for 3rdparty - submodules: true - name: Check composer.json id: check_composer @@ -84,9 +80,6 @@ jobs: npm ci TESTING=true npm run build --if-present - - name: Show cypress version - run: npm run cypress:version - - name: Save context uses: buildjet/cache/save@3e70d19e31d6a8030aeddf6ed8dbe601f94d09f4 # v4.0.2 with: @@ -101,56 +94,8 @@ jobs: fail-fast: false matrix: # Run multiple copies of the current job in parallel - # Please increase the number or runners as your tests suite grows (0 based index for e2e tests) - containers: ['component', 'setup', '0', '1', '2', '3', '4', '5', '6', '7'] - # Hack as strategy.job-total includes the component and GitHub does not allow math expressions - # Always align this number with the total of e2e runners (max. index + 1) - total-containers: [8] - - services: - mysql: - # Only start mysql if we are running the setup tests - image: ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-mysql-8.4:latest' || ''}} - ports: - - '3306/tcp' - env: - MYSQL_ROOT_PASSWORD: rootpassword - MYSQL_USER: oc_autotest - MYSQL_PASSWORD: nextcloud - MYSQL_DATABASE: oc_autotest - options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 10 - - mariadb: - # Only start mariadb if we are running the setup tests - image: ${{matrix.containers == 'setup' && 'mariadb:11.4' || ''}} - ports: - - '3306/tcp' - env: - MYSQL_ROOT_PASSWORD: rootpassword - MYSQL_USER: oc_autotest - MYSQL_PASSWORD: nextcloud - MYSQL_DATABASE: oc_autotest - options: --health-cmd="mariadb-admin ping" --health-interval 5s --health-timeout 2s --health-retries 5 - - postgres: - # Only start postgres if we are running the setup tests - image: ${{matrix.containers == 'setup' && 'ghcr.io/nextcloud/continuous-integration-postgres-17:latest' || ''}} - ports: - - '5432/tcp' - env: - POSTGRES_USER: root - POSTGRES_PASSWORD: rootpassword - POSTGRES_DB: nextcloud - options: --mount type=tmpfs,destination=/var/lib/postgresql/data --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 - - oracle: - # Only start oracle if we are running the setup tests - image: ${{matrix.containers == 'setup' && 'ghcr.io/gvenzl/oracle-free:23' || ''}} - ports: - - '1521' - env: - ORACLE_PASSWORD: oracle - options: --health-cmd healthcheck.sh --health-interval 20s --health-timeout 10s --health-retries 10 + # Please increase the number or runners as your tests suite grows + containers: ['component', '1', '2', '3'] name: runner ${{ matrix.containers }} @@ -170,19 +115,17 @@ jobs: - name: Set up npm ${{ needs.init.outputs.npmVersion }} run: npm i -g 'npm@${{ needs.init.outputs.npmVersion }}' - - name: Install cypress - run: ./node_modules/cypress/bin/cypress install - - name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests - uses: cypress-io/github-action@be1bab96b388bbd9ce3887e397d373c8557e15af # v6.9.2 + uses: cypress-io/github-action@615dcf65299b63c35268d795f4dfb79532388f64 # v6.10.0 with: - # We already installed the dependencies in the init job - install: false + record: ${{ secrets.CYPRESS_RECORD_KEY && true }} + parallel: ${{ secrets.CYPRESS_RECORD_KEY && true }} + # cypress run type component: ${{ matrix.containers == 'component' }} - group: ${{ matrix.use-cypress-cloud && matrix.containers == 'component' && 'Run component' || matrix.use-cypress-cloud && 'Run E2E' || '' }} + group: ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_GROUP }} # cypress env - ci-build-id: ${{ matrix.use-cypress-cloud && format('{0}-{1}', github.sha, github.run_number) || '' }} - tag: ${{ matrix.use-cypress-cloud && github.event_name || '' }} + ci-build-id: ${{ secrets.CYPRESS_RECORD_KEY && env.CYPRESS_BUILD_ID }} + tag: ${{ secrets.CYPRESS_RECORD_KEY && github.event_name }} env: # Needs to be prefixed with CYPRESS_ CYPRESS_BRANCH: ${{ env.BRANCH }} @@ -192,22 +135,19 @@ jobs: TESTING: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - SPLIT: ${{ matrix.total-containers }} - SPLIT_INDEX: ${{ matrix.containers == 'component' && 0 || matrix.containers }} - SETUP_TESTING: ${{ matrix.containers == 'setup' && 'true' || '' }} + CYPRESS_BUILD_ID: ${{ github.sha }}-${{ github.run_number }} + CYPRESS_GROUP: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} - - name: Upload snapshots and videos + - name: Upload snapshots uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 if: always() with: - name: snapshots_videos_${{ matrix.containers }} - path: | - cypress/snapshots - cypress/videos + name: snapshots_${{ matrix.containers }} + path: cypress/snapshots - name: Extract NC logs if: failure() && matrix.containers != 'component' - run: docker logs nextcloud-cypress-tests_${{ env.APP_NAME }} > nextcloud.log + run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log - name: Upload NC logs uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 @@ -216,17 +156,6 @@ jobs: name: nc_logs_${{ matrix.containers }} path: nextcloud.log - - name: Create data dir archive - if: failure() && matrix.containers != 'component' - run: docker exec nextcloud-cypress-tests_${{ env.APP_NAME }} tar -cvjf - data > data.tar - - - name: Upload data dir archive - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - if: failure() && matrix.containers != 'component' - with: - name: nc_data_${{ matrix.containers }} - path: data.tar - summary: runs-on: ubuntu-latest-low needs: [init, cypress]