|
| 1 | +name: Lint and Code Style |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - synchronize |
| 11 | + - reopened |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: lint-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + lint-php-codestyle: |
| 19 | + name: PHP Code Style |
| 20 | + runs-on: ubuntu-latest |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + php-version: ["7.4"] |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Check if changes affect PHP |
| 32 | + id: changes |
| 33 | + uses: dorny/paths-filter@v2 |
| 34 | + with: |
| 35 | + filters: | |
| 36 | + php: |
| 37 | + - '**/*.php' |
| 38 | + - '!tests/acceptance/**' |
| 39 | + - '!build/**' |
| 40 | +
|
| 41 | + - name: Setup PHP |
| 42 | + if: steps.changes.outputs.php == 'true' |
| 43 | + uses: shivammathur/setup-php@v2 |
| 44 | + with: |
| 45 | + php-version: ${{ matrix.php-version }} |
| 46 | + extensions: curl, gd, json, xml, zip |
| 47 | + ini-values: "memory_limit=1024M" |
| 48 | + tools: phpstan, codesniffer |
| 49 | + |
| 50 | + - name: Cache Composer dependencies |
| 51 | + if: steps.changes.outputs.php == 'true' |
| 52 | + uses: actions/cache@v3 |
| 53 | + with: |
| 54 | + path: vendor/ |
| 55 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-composer- |
| 58 | +
|
| 59 | + - name: Install Composer dependencies |
| 60 | + if: steps.changes.outputs.php == 'true' |
| 61 | + run: | |
| 62 | + composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader |
| 63 | +
|
| 64 | + - name: Install vendor-bin dependencies |
| 65 | + if: steps.changes.outputs.php == 'true' |
| 66 | + run: | |
| 67 | + composer install --no-progress --no-interaction --prefer-dist --working-dir=vendor-bin/owncloud-codestyle |
| 68 | + composer install --no-progress --no-interaction --prefer-dist --working-dir=vendor-bin/phpstan |
| 69 | + composer install --no-progress --no-interaction --prefer-dist --working-dir=vendor-bin/phan |
| 70 | +
|
| 71 | + - name: Run PHP Code Sniffer |
| 72 | + if: steps.changes.outputs.php == 'true' |
| 73 | + run: make test-php-style |
| 74 | + continue-on-error: true |
| 75 | + |
| 76 | + phpstan-analysis: |
| 77 | + name: PHPStan Static Analysis |
| 78 | + runs-on: ubuntu-latest |
| 79 | + strategy: |
| 80 | + fail-fast: false |
| 81 | + matrix: |
| 82 | + php-version: ["7.4"] |
| 83 | + steps: |
| 84 | + - name: Checkout code |
| 85 | + uses: actions/checkout@v4 |
| 86 | + with: |
| 87 | + fetch-depth: 0 |
| 88 | + |
| 89 | + - name: Check if changes affect PHP |
| 90 | + id: changes |
| 91 | + uses: dorny/paths-filter@v2 |
| 92 | + with: |
| 93 | + filters: | |
| 94 | + php: |
| 95 | + - '**/*.php' |
| 96 | + - '!tests/acceptance/**' |
| 97 | + - '!build/**' |
| 98 | +
|
| 99 | + - name: Setup PHP |
| 100 | + if: steps.changes.outputs.php == 'true' |
| 101 | + uses: shivammathur/setup-php@v2 |
| 102 | + with: |
| 103 | + php-version: ${{ matrix.php-version }} |
| 104 | + extensions: curl, gd, json, xml, zip |
| 105 | + ini-values: "memory_limit=1024M" |
| 106 | + |
| 107 | + - name: Cache Composer dependencies |
| 108 | + if: steps.changes.outputs.php == 'true' |
| 109 | + uses: actions/cache@v3 |
| 110 | + with: |
| 111 | + path: vendor/ |
| 112 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 113 | + restore-keys: | |
| 114 | + ${{ runner.os }}-composer- |
| 115 | +
|
| 116 | + - name: Install Composer dependencies |
| 117 | + if: steps.changes.outputs.php == 'true' |
| 118 | + run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader |
| 119 | + |
| 120 | + - name: Install vendor-bin dependencies |
| 121 | + if: steps.changes.outputs.php == 'true' |
| 122 | + run: composer install --no-progress --no-interaction --prefer-dist --working-dir=vendor-bin/phpstan |
| 123 | + |
| 124 | + - name: Install server dependencies |
| 125 | + if: steps.changes.outputs.php == 'true' |
| 126 | + run: make install-server |
| 127 | + |
| 128 | + - name: Run PHPStan |
| 129 | + if: steps.changes.outputs.php == 'true' |
| 130 | + run: make test-php-phpstan |
| 131 | + continue-on-error: true |
| 132 | + |
| 133 | + phan-analysis: |
| 134 | + name: Phan Static Analysis |
| 135 | + runs-on: ubuntu-latest |
| 136 | + strategy: |
| 137 | + fail-fast: false |
| 138 | + matrix: |
| 139 | + php-version: ["7.4"] |
| 140 | + steps: |
| 141 | + - name: Checkout code |
| 142 | + uses: actions/checkout@v4 |
| 143 | + with: |
| 144 | + fetch-depth: 0 |
| 145 | + |
| 146 | + - name: Check if changes affect PHP |
| 147 | + id: changes |
| 148 | + uses: dorny/paths-filter@v2 |
| 149 | + with: |
| 150 | + filters: | |
| 151 | + php: |
| 152 | + - '**/*.php' |
| 153 | + - '!tests/acceptance/**' |
| 154 | + - '!build/**' |
| 155 | +
|
| 156 | + - name: Setup PHP |
| 157 | + if: steps.changes.outputs.php == 'true' |
| 158 | + uses: shivammathur/setup-php@v2 |
| 159 | + with: |
| 160 | + php-version: ${{ matrix.php-version }} |
| 161 | + extensions: curl, gd, json, xml, zip |
| 162 | + ini-values: "memory_limit=1024M" |
| 163 | + |
| 164 | + - name: Cache Composer dependencies |
| 165 | + if: steps.changes.outputs.php == 'true' |
| 166 | + uses: actions/cache@v3 |
| 167 | + with: |
| 168 | + path: vendor/ |
| 169 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 170 | + restore-keys: | |
| 171 | + ${{ runner.os }}-composer- |
| 172 | +
|
| 173 | + - name: Install Composer dependencies |
| 174 | + if: steps.changes.outputs.php == 'true' |
| 175 | + run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader |
| 176 | + |
| 177 | + - name: Install vendor-bin dependencies |
| 178 | + if: steps.changes.outputs.php == 'true' |
| 179 | + run: composer install --no-progress --no-interaction --prefer-dist --working-dir=vendor-bin/phan |
| 180 | + |
| 181 | + - name: Install server dependencies |
| 182 | + if: steps.changes.outputs.php == 'true' |
| 183 | + run: make install-server |
| 184 | + |
| 185 | + - name: Run Phan |
| 186 | + if: steps.changes.outputs.php == 'true' |
| 187 | + run: make test-php-phan |
| 188 | + continue-on-error: true |
| 189 | + |
| 190 | + javascript-lint: |
| 191 | + name: JavaScript Linting |
| 192 | + runs-on: ubuntu-latest |
| 193 | + steps: |
| 194 | + - name: Checkout code |
| 195 | + uses: actions/checkout@v4 |
| 196 | + with: |
| 197 | + fetch-depth: 0 |
| 198 | + |
| 199 | + - name: Check if changes affect JavaScript |
| 200 | + id: changes |
| 201 | + uses: dorny/paths-filter@v2 |
| 202 | + with: |
| 203 | + filters: | |
| 204 | + javascript: |
| 205 | + - '**/*.js' |
| 206 | + - 'package.json' |
| 207 | + - 'package-lock.json' |
| 208 | +
|
| 209 | + - name: Setup Node.js |
| 210 | + if: steps.changes.outputs.javascript == 'true' |
| 211 | + uses: actions/setup-node@v3 |
| 212 | + with: |
| 213 | + node-version: "14" |
| 214 | + cache: npm |
| 215 | + |
| 216 | + - name: Install Node dependencies |
| 217 | + if: steps.changes.outputs.javascript == 'true' |
| 218 | + run: npm ci |
| 219 | + |
| 220 | + - name: Run JavaScript linting |
| 221 | + if: steps.changes.outputs.javascript == 'true' |
| 222 | + run: npm run lint |
| 223 | + continue-on-error: true |
| 224 | + |
| 225 | + git-commit-messages: |
| 226 | + name: Git Commit Messages |
| 227 | + runs-on: ubuntu-latest |
| 228 | + if: github.event_name == 'pull_request' |
| 229 | + steps: |
| 230 | + - name: Checkout code |
| 231 | + uses: actions/checkout@v4 |
| 232 | + with: |
| 233 | + fetch-depth: 0 |
| 234 | + |
| 235 | + - name: Validate commit messages |
| 236 | + run: | |
| 237 | + # Get all commits in the PR |
| 238 | + git log --format=%B origin/master..${{ github.head_ref }} | while read line; do |
| 239 | + # Check for common issues |
| 240 | + if [[ $line =~ ^Merge\ branch ]]; then |
| 241 | + echo "⚠️ Merge commits detected" |
| 242 | + fi |
| 243 | + done |
| 244 | + continue-on-error: true |
| 245 | + |
| 246 | + changelog-check: |
| 247 | + name: Changelog Check |
| 248 | + runs-on: ubuntu-latest |
| 249 | + steps: |
| 250 | + - name: Checkout code |
| 251 | + uses: actions/checkout@v4 |
| 252 | + with: |
| 253 | + fetch-depth: 0 |
| 254 | + |
| 255 | + - name: Check for changelog entry |
| 256 | + run: | |
| 257 | + if [ -d "changelog/unreleased" ]; then |
| 258 | + if [ "$(ls -A changelog/unreleased)" ]; then |
| 259 | + echo "✓ Changelog entry found" |
| 260 | + else |
| 261 | + echo "⚠️ No changelog entry in changelog/unreleased" |
| 262 | + fi |
| 263 | + fi |
| 264 | + continue-on-error: true |
0 commit comments