|
| 1 | +# This workflow is provided via the organization template repository |
| 2 | +# |
| 3 | +# https://github.com/nextcloud/.github |
| 4 | +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization |
| 5 | +# |
| 6 | +# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors |
| 7 | +# SPDX-License-Identifier: MIT |
| 8 | + |
| 9 | +name: Node tests |
| 10 | + |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + push: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + - master |
| 17 | + - stable* |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: node-tests-${{ github.head_ref || github.run_id }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + changes: |
| 28 | + runs-on: ubuntu-latest-low |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + pull-requests: read |
| 32 | + |
| 33 | + outputs: |
| 34 | + src: ${{ steps.changes.outputs.src}} |
| 35 | + |
| 36 | + steps: |
| 37 | + - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 38 | + id: changes |
| 39 | + continue-on-error: true |
| 40 | + with: |
| 41 | + filters: | |
| 42 | + src: |
| 43 | + - '.github/workflows/**' |
| 44 | + - '__tests__/**' |
| 45 | + - '__mocks__/**' |
| 46 | + - 'src/**' |
| 47 | + - 'appinfo/info.xml' |
| 48 | + - 'package.json' |
| 49 | + - 'package-lock.json' |
| 50 | + - 'tsconfig.json' |
| 51 | + - '**.js' |
| 52 | + - '**.ts' |
| 53 | + - '**.vue' |
| 54 | + |
| 55 | + test: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + |
| 58 | + needs: changes |
| 59 | + if: needs.changes.outputs.src != 'false' |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout |
| 63 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 64 | + with: |
| 65 | + persist-credentials: false |
| 66 | + |
| 67 | + - name: Read package.json node and npm engines version |
| 68 | + uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3 |
| 69 | + id: versions |
| 70 | + with: |
| 71 | + fallbackNode: '^24' |
| 72 | + fallbackNpm: '^11.3' |
| 73 | + |
| 74 | + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} |
| 75 | + uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 |
| 76 | + with: |
| 77 | + node-version: ${{ steps.versions.outputs.nodeVersion }} |
| 78 | + |
| 79 | + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} |
| 80 | + run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}' |
| 81 | + |
| 82 | + - name: Install dependencies & build |
| 83 | + env: |
| 84 | + CYPRESS_INSTALL_BINARY: 0 |
| 85 | + run: | |
| 86 | + npm ci |
| 87 | + npm run build --if-present |
| 88 | + |
| 89 | + - name: Test |
| 90 | + run: npm run test --if-present |
| 91 | + |
| 92 | + - name: Test and process coverage |
| 93 | + run: npm run test:coverage --if-present |
| 94 | + |
| 95 | + - name: Collect coverage |
| 96 | + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 |
| 97 | + with: |
| 98 | + files: ./coverage/lcov.info |
| 99 | + |
| 100 | + summary: |
| 101 | + permissions: |
| 102 | + contents: none |
| 103 | + runs-on: ubuntu-latest-low |
| 104 | + needs: [changes, test] |
| 105 | + |
| 106 | + if: always() |
| 107 | + |
| 108 | + name: test-summary |
| 109 | + |
| 110 | + steps: |
| 111 | + - name: Summary status |
| 112 | + run: if ${{ needs.changes.outputs.src != 'false' && needs.test.result != 'success' }}; then exit 1; fi |
0 commit comments