|
| 1 | +name: Static analysis |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, test, dev] |
| 6 | + types: [closed] |
| 7 | + push: |
| 8 | + branches: [dev] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + changes: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + php_src: ${{ steps.filter.outputs.php_src }} |
| 16 | + js_src: ${{ steps.filter.outputs.js_src }} |
| 17 | + py_src: ${{ steps.filter.outputs.py_src }} |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + - uses: dorny/paths-filter@v2 |
| 21 | + id: filter |
| 22 | + with: |
| 23 | + base: ${{ github.ref }} |
| 24 | + filters: | |
| 25 | + php_src: |
| 26 | + - '**/*.php' |
| 27 | + js_src: |
| 28 | + - '*.js' |
| 29 | + - '**/*.js' |
| 30 | + py_src: |
| 31 | + - 'lib/Service/python/**' |
| 32 | + - 'lib/Service/python/*.py' |
| 33 | +
|
| 34 | + linters-php: |
| 35 | + needs: changes |
| 36 | + if: ${{ needs.changes.outputs.php_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 37 | + runs-on: ubuntu-latest |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + php-versions: [7.4, 8.0] |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Setup php${{ matrix.php-versions }} |
| 45 | + uses: shivammathur/setup-php@master |
| 46 | + with: |
| 47 | + php-version: ${{ matrix.php-versions }} |
| 48 | + tools: composer:v2 |
| 49 | + coverage: none |
| 50 | + |
| 51 | + - name: PHP Lint |
| 52 | + run: composer run lint |
| 53 | + |
| 54 | + linters-js: |
| 55 | + needs: changes |
| 56 | + if: ${{ needs.changes.outputs.js_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 57 | + runs-on: ubuntu-latest |
| 58 | + name: ESLint |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v2 |
| 61 | + |
| 62 | +# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#installed-software |
| 63 | +# do we need this step? this is already installed in github's ubuntu... |
| 64 | + # - name: Setup Node |
| 65 | + |
| 66 | + # with: |
| 67 | + # node-version: 14.x |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: npm ci |
| 71 | + |
| 72 | + - name: ESLint |
| 73 | + run: npm run lint |
| 74 | + |
| 75 | + linters-python: |
| 76 | + needs: changes |
| 77 | + if: ${{ needs.changes.outputs.py_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 78 | + runs-on: ubuntu-latest |
| 79 | + name: PyLint |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v2 |
| 82 | + |
| 83 | + - name: pylint installation |
| 84 | + run: | |
| 85 | + python -m pip install --upgrade pip |
| 86 | + pip install pylint |
| 87 | +
|
| 88 | + - name: pylint analysis |
| 89 | + run: | |
| 90 | + pylint --rcfile .pylintrc lib/Service/python/* |
| 91 | +
|
| 92 | + security-analysis: |
| 93 | + needs: [changes, linters-php] |
| 94 | + if: ${{ needs.changes.outputs.php_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 95 | + runs-on: ubuntu-latest |
| 96 | + name: Security analysis |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v2 |
| 99 | + with: |
| 100 | + submodules: recursive |
| 101 | + |
| 102 | + - name: Psalm |
| 103 | + uses: docker://vimeo/psalm-github-actions:4.9.3 |
| 104 | + with: |
| 105 | + security_analysis: true |
| 106 | + composer_ignore_platform_reqs: false |
| 107 | + report_file: results.sarif |
| 108 | + |
| 109 | + - name: Upload Security Analysis results to GitHub |
| 110 | + uses: github/codeql-action/upload-sarif@v1 |
| 111 | + with: |
| 112 | + sarif_file: results.sarif |
| 113 | + |
| 114 | + psalm-analysis: |
| 115 | + needs: [changes, linters-php] |
| 116 | + if: ${{ needs.changes.outputs.php_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 117 | + runs-on: ubuntu-latest |
| 118 | + strategy: |
| 119 | + matrix: |
| 120 | + ocp-version: [ 'dev-master', 'dev-stable21', 'dev-stable22' ] |
| 121 | + name: Psalm statis-analysis |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v2 |
| 124 | + |
| 125 | + - name: Set up php |
| 126 | + uses: shivammathur/setup-php@master |
| 127 | + with: |
| 128 | + php-version: 7.4 |
| 129 | + tools: composer:v2 |
| 130 | + coverage: none |
| 131 | + |
| 132 | + - name: Install dependencies |
| 133 | + run: composer i |
| 134 | + |
| 135 | + - name: Install dependencies |
| 136 | + run: composer require --dev christophwurst/nextcloud:${{ matrix.ocp-version }} |
| 137 | + |
| 138 | + - name: Run coding standards check |
| 139 | + run: composer run psalm |
| 140 | + |
| 141 | + npm-audit: |
| 142 | + needs: [changes, linters-js] |
| 143 | + if: ${{ needs.changes.outputs.js_src == 'true' || github.event_name == 'workflow_dispatch' }} |
| 144 | + runs-on: ubuntu-latest |
| 145 | + name: npm-audit |
| 146 | + steps: |
| 147 | + - uses: actions/checkout@v2 |
| 148 | + |
| 149 | +# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#installed-software |
| 150 | +# do we need this step? this is already installed in github's ubuntu... |
| 151 | + # - name: Setup Node |
| 152 | + |
| 153 | + # with: |
| 154 | + # node-version: 14.x |
| 155 | + |
| 156 | + - name: Audit |
| 157 | + run: npm audit |
0 commit comments