|
| 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: 2022-2024 Nextcloud GmbH and Nextcloud contributors |
| 7 | +# SPDX-License-Identifier: MIT |
| 8 | + |
| 9 | +name: Static analysis |
| 10 | + |
| 11 | +on: pull_request |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: psalm-${{ github.head_ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +jobs: |
| 21 | + matrix: |
| 22 | + runs-on: ubuntu-latest-low |
| 23 | + outputs: |
| 24 | + ocp-matrix: ${{ steps.versions.outputs.ocp-matrix }} |
| 25 | + steps: |
| 26 | + - name: Checkout app |
| 27 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 28 | + with: |
| 29 | + persist-credentials: false |
| 30 | + |
| 31 | + - name: Get version matrix |
| 32 | + id: versions |
| 33 | + uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1 |
| 34 | + |
| 35 | + - name: Check enforcement of minimum PHP version ${{ steps.versions.outputs.php-min }} in psalm.xml |
| 36 | + run: grep 'phpVersion="${{ steps.versions.outputs.php-min }}' psalm.xml |
| 37 | + |
| 38 | + static-analysis: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + needs: matrix |
| 41 | + strategy: |
| 42 | + # do not stop on another job's failure |
| 43 | + fail-fast: false |
| 44 | + matrix: ${{ fromJson(needs.matrix.outputs.ocp-matrix) }} |
| 45 | + |
| 46 | + name: static-psalm-analysis ${{ matrix.ocp-version }} |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 50 | + with: |
| 51 | + persist-credentials: false |
| 52 | + |
| 53 | + - name: Set up php${{ matrix.php-min }} |
| 54 | + uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4 |
| 55 | + with: |
| 56 | + php-version: ${{ matrix.php-min }} |
| 57 | + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite |
| 58 | + coverage: none |
| 59 | + ini-file: development |
| 60 | + # Temporary workaround for missing pcntl_* in PHP 8.3 |
| 61 | + ini-values: disable_functions= |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + - name: Install dependencies |
| 66 | + run: | |
| 67 | + composer remove nextcloud/ocp --dev --no-scripts |
| 68 | + composer i |
| 69 | +
|
| 70 | + - name: Check for vulnerable PHP dependencies |
| 71 | + run: composer require --dev roave/security-advisories:dev-latest |
| 72 | + |
| 73 | + - name: Install dependencies # zizmor: ignore[template-injection] |
| 74 | + run: composer require --dev 'nextcloud/ocp:${{ matrix.ocp-version }}' --ignore-platform-reqs --with-dependencies |
| 75 | + |
| 76 | + - name: Run coding standards check |
| 77 | + run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github |
| 78 | + |
| 79 | + summary: |
| 80 | + runs-on: ubuntu-latest-low |
| 81 | + needs: static-analysis |
| 82 | + |
| 83 | + if: always() |
| 84 | + |
| 85 | + name: static-psalm-analysis-summary |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Summary status |
| 89 | + run: if ${{ needs.static-analysis.result != 'success' }}; then exit 1; fi |
0 commit comments