From 5ebff5681fa469d7ec131fef905dbfe0992aa959 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Mon, 30 Dec 2024 14:19:08 +0100 Subject: [PATCH] chore: update cypress and node workflows Signed-off-by: skjnldsv --- .github/workflows/cypress.yml | 46 +++++++++++++++-------- .github/workflows/node-when-unrelated.yml | 43 --------------------- .github/workflows/node.yml | 18 ++++++--- 3 files changed, 44 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/node-when-unrelated.yml diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 9c1be930c..216f41065 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -1,3 +1,11 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT + name: Cypress on: pull_request @@ -12,7 +20,7 @@ env: # This represents the server branch to checkout. # 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 + # 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.base_ref || github.ref_name }} @@ -27,12 +35,20 @@ jobs: PUPPETEER_SKIP_DOWNLOAD: true steps: + - name: Disabled on forks + if: ${{ github.event.pull_request.head.repo.full_name != github.repository }} + run: | + echo 'Can not run cypress on forks' + exit 1 + - name: Checkout app - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false - name: Check composer.json id: check_composer - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v2 + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 with: files: "composer.json" @@ -41,19 +57,19 @@ jobs: run: composer install --no-dev - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + 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@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install node dependencies & build app run: | @@ -61,7 +77,7 @@ jobs: TESTING=true npm run build --if-present - name: Save context - uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3 + uses: buildjet/cache/save@v4 with: key: cypress-context-${{ github.run_id }} path: ./ @@ -75,28 +91,28 @@ jobs: matrix: # Run multiple copies of the current job in parallel # Please increase the number or runners as your tests suite grows - containers: [1, 2, 3] + containers: ['1', '2', '3'] name: runner ${{ matrix.containers }} steps: - name: Restore context - uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3 + uses: buildjet/cache/restore@v4 with: fail-on-cache-miss: true key: cypress-context-${{ github.run_id }} path: ./ - name: Set up node ${{ needs.init.outputs.nodeVersion }} - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: ${{ needs.init.outputs.nodeVersion }} - name: Set up npm ${{ needs.init.outputs.npmVersion }} - run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}" + run: npm i -g 'npm@${{ needs.init.outputs.npmVersion }}' - name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests - uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1 + uses: cypress-io/github-action@57b70560982e6a11d23d4b8bec7f8a487cdbb71b # v6.7.8 with: record: ${{ secrets.CYPRESS_RECORD_KEY && true }} parallel: ${{ secrets.CYPRESS_RECORD_KEY && true }} @@ -119,7 +135,7 @@ jobs: CYPRESS_GROUP: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} - name: Upload snapshots - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: always() with: name: snapshots_${{ matrix.containers }} @@ -130,14 +146,14 @@ jobs: run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log - name: Upload NC logs - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 if: failure() && matrix.containers != 'component' with: name: nc_logs_${{ matrix.containers }} path: nextcloud.log summary: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-low needs: [init, cypress] if: always() diff --git a/.github/workflows/node-when-unrelated.yml b/.github/workflows/node-when-unrelated.yml deleted file mode 100644 index db32b0dba..000000000 --- a/.github/workflows/node-when-unrelated.yml +++ /dev/null @@ -1,43 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -# -# Use node together with node-when-unrelated to make eslint a required check for GitHub actions -# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks - -name: Node - -on: - pull_request: - paths-ignore: - - '.github/workflows/**' - - 'src/**' - - 'appinfo/info.xml' - - 'package.json' - - 'package-lock.json' - - 'tsconfig.json' - - '**.js' - - '**.ts' - - '**.vue' - push: - branches: - - main - - master - - stable* - -concurrency: - group: node-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - build: - permissions: - contents: none - - runs-on: ubuntu-latest - - name: node - steps: - - name: Skip - run: 'echo "No JS/TS files changed, skipped Node"' diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 89585cb6e..461b09e7b 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -2,6 +2,9 @@ # # https://github.com/nextcloud/.github # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization +# +# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-License-Identifier: MIT name: Node @@ -16,7 +19,10 @@ concurrency: jobs: changes: - runs-on: ubuntu-latest-low + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read outputs: src: ${{ steps.changes.outputs.src}} @@ -47,22 +53,24 @@ jobs: name: NPM build steps: - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + 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@60edb5dd545a775178f52524783378180af0d1f8 # v3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: ${{ steps.versions.outputs.nodeVersion }} - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' - name: Install dependencies & build env: