User Tools

Site Tools


gitlab-ci-code-quality-phpstan

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gitlab-ci-code-quality-phpstan [2020/12/01 23:02] – [Install PHPStan] admingitlab-ci-code-quality-phpstan [2020/12/02 14:34] (current) admin
Line 1: Line 1:
 ====== Gitlab Code Quality Widget and PHPStan ====== ====== Gitlab Code Quality Widget and PHPStan ======
 +
 +{{ ::gitlab-code-quality-widget.png?600 |}}
  
 <note tip>Make sure you run it on ''master'' branch first. If no artifact exists on master Gitlab can't compare code quality</note> <note tip>Make sure you run it on ''master'' branch first. If no artifact exists on master Gitlab can't compare code quality</note>
Line 6: Line 8:
 ===== Install  ===== ===== Install  =====
  
-PHPStan+**PHPStan**
  
 <code bash> <code bash>
Line 12: Line 14:
 </code> </code>
  
 +**Add ''.gitlab-ci.yml'':**
  
-===== Command explained ===== 
- 
- 
-^ ./vendor/bin/phpstan analyse ^ --error-format=gitlab              ^ --no-progress           ^ Classes/ ^ > gl-code-quality-report.json ^ exit 0 ^ 
-| Run analyzer                 | Output Gitlab readable JSON format | Hide progress indicator | Folders to analyze | Write output to file | Make sure job always passes | 
- 
- 
-===== Exampl CI File ===== 
  
 <code yaml .gitlab-ci.yml> <code yaml .gitlab-ci.yml>
Line 26: Line 21:
   - test   - test
  
-code_quality:+php_stan:
   image: composer   image: composer
   stage: test   stage: test
   script:   script:
     - composer install --no-ansi     - composer install --no-ansi
-    # Set output to 'gitlab' using '--error-format=gitlab', 'exit 0' is required and the artifact gets uploaded +    # Set output to 'gitlab' using '--error-format=gitlab', the artifact gets uploaded 
-    - ./vendor/bin/phpstan analyse --error-format=gitlab --no-progress Classes/ > gl-code-quality-report.json || exit 0+    - ./vendor/bin/phpstan analyse --error-format=gitlab --no-progress Classes/ > gl-phpstan-report.json || exit 0
   artifacts:   artifacts:
     reports:     reports:
       # Tell Gitlab about the custom generated reports JSON file       # Tell Gitlab about the custom generated reports JSON file
-      codequality: gl-code-quality-report.json +      codequality: gl-phpstan-report.json 
-    paths: [gl-code-quality-report.json] +    # Optional 
 +    paths: [gl-phpstan-report.json]
 </code> </code>
 +
 +===== Command explained =====
 +
 +
 +^ ./vendor/bin/phpstan analyse ^ --error-format=gitlab              ^ --no-progress           ^ Classes/ ^ > gl-code-quality-report.json ^ exit 0 ^
 +| Run analyzer                 | Output Gitlab readable JSON format | Hide progress indicator | Folders to analyze | Write output to file | Optional: Make sure job always passes |
 +
 +
gitlab-ci-code-quality-phpstan.1606863761.txt.gz · Last modified: 2020/12/01 23:02 by admin