Merge pull request #709 from nextcloud-libraries/dependabot/npm_and_y… #1608
This file contains 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: 2023-2024 Nextcloud GmbH and Nextcloud contributors | |
# SPDX-License-Identifier: MIT | |
name: Cypress | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- master | |
- stable* | |
env: | |
BRANCH: ${{ github.base_ref || github.event.repository.default_branch }} | |
jobs: | |
cypress-e2e: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# run multiple copies of the current job in parallel | |
containers: [1] | |
name: e2e runner ${{ matrix.containers }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Read package.json node and npm engines version | |
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 | |
id: versions | |
with: | |
fallbackNode: "^20" | |
fallbackNpm: "^10" | |
- name: Set up node ${{ steps.versions.outputs.nodeVersion }} | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.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: Pull server image | |
run: docker pull ghcr.io/nextcloud/continuous-integration-shallow-server | |
- name: Run E2E cypress tests | |
uses: cypress-io/github-action@f1f0912d392f0d06bdd01fb9ebe3b3299e5806fb # v6.7.7 | |
with: | |
# cypress io | |
record: true | |
parallel: true | |
# cypress env | |
ci-build-id: ${{ github.sha }}-${{ github.run_number }} | |
tag: ${{ github.event_name }} | |
group: 'E2E' | |
# Build library before using it | |
build: npm run build:instrumented | |
env: | |
# Needs to be prefixed with CYPRESS_ | |
CYPRESS_BRANCH: ${{ env.BRANCH }} | |
# https://github.com/cypress-io/github-action/issues/124 | |
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
- name: Collect coverage | |
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | |
with: | |
files: ./coverage/lcov.info | |
cypress-component: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
# run multiple copies of the current job in parallel | |
containers: [1] | |
name: component runner ${{ matrix.containers }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Read package.json node and npm engines version | |
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 | |
id: versions | |
with: | |
fallbackNode: '^20' | |
fallbackNpm: '^9' | |
- name: Set up node ${{ steps.versions.outputs.nodeVersion }} | |
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v3 | |
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: Run Components cypress tests | |
uses: cypress-io/github-action@f1f0912d392f0d06bdd01fb9ebe3b3299e5806fb # v6.7.7 | |
with: | |
# to run component tests we need to use "component: true" | |
component: true | |
# cypress io | |
record: true | |
parallel: true | |
# cypress env | |
ci-build-id: ${{ github.sha }}-${{ github.run_number }} | |
tag: ${{ github.event_name }} | |
group: 'Components' | |
# Tests use (instrumented) built files | |
build: npm run build:instrumented | |
env: | |
# Needs to be prefixed with CYPRESS_ | |
CYPRESS_BRANCH: ${{ env.BRANCH }} | |
# https://github.com/cypress-io/github-action/issues/124 | |
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
- name: Collect coverage | |
uses: codecov/codecov-action@7f8b4b4bde536c465e797be725718b88c5d95e0e # v5.1.1 | |
with: | |
files: ./coverage/lcov.info | |
summary: | |
runs-on: ubuntu-latest | |
needs: [cypress-e2e, cypress-component] | |
if: always() | |
name: cypress-summary | |
steps: | |
- name: Summary status | |
run: if ${{ (needs.cypress-e2e.result != 'success' && needs.cypress-e2e.result != 'skipped') || (needs.cypress-component.result != 'success' && needs.cypress-component.result != 'skipped') }}; then exit 1; fi |