|
| 1 | + |
| 2 | +# This file is part of Phalcon. |
| 3 | +# |
| 4 | +# (c) Phalcon Team <[email protected]> |
| 5 | +# |
| 6 | +# For the full copyright and license information, please view |
| 7 | +# the LICENSE file that was distributed with this source code. |
| 8 | + |
1 | 9 | name: REST API v6 CI
|
2 | 10 | on:
|
3 | 11 | push:
|
| 12 | + paths-ignore: |
| 13 | + - '**.md' |
| 14 | + - '**.txt' |
4 | 15 | pull_request:
|
5 |
| - types: [opened, synchronize, reopened] |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +env: |
| 19 | + fail-fast: true |
| 20 | + |
| 21 | + # PHP extensions required by Composer |
| 22 | + EXTENSIONS: json, mbstring, pdo, pdo_mysql |
| 23 | + |
| 24 | +permissions: { } |
6 | 25 | jobs:
|
7 |
| - sonarqube: |
8 |
| - name: SonarQube |
9 |
| - runs-on: ubuntu-latest |
| 26 | + |
| 27 | + # PHP CodeSniffer inspection |
| 28 | + phpcs: |
| 29 | + name: "Quality gate" |
| 30 | + if: "!contains(github.event.head_commit.message, 'ci skip')" |
| 31 | + |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | + runs-on: ubuntu-22.04 |
| 36 | + |
| 37 | + strategy: |
| 38 | + fail-fast: true |
| 39 | + matrix: |
| 40 | + php: |
| 41 | + - '8.2' |
| 42 | + - '8.3' |
| 43 | + - '8.4' |
10 | 44 | steps:
|
11 | 45 | - uses: actions/checkout@v4
|
| 46 | + |
| 47 | + - name: "Setup PHP" |
| 48 | + uses: shivammathur/[email protected] |
12 | 49 | with:
|
13 |
| - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
14 |
| - - name: SonarQube Scan |
| 50 | + php-version: ${{ matrix.php }} |
| 51 | + extensions: ${{ env.EXTENSIONS }} |
| 52 | + tools: pecl |
| 53 | + env: |
| 54 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: "Install development dependencies with Composer" |
| 57 | + uses: "ramsey/composer-install@v3" |
| 58 | + with: |
| 59 | + composer-options: "--prefer-dist" |
| 60 | + |
| 61 | + - name: "PHPCS" |
| 62 | + run: | |
| 63 | + composer cs |
| 64 | +
|
| 65 | +# - name: "PHPStan" |
| 66 | +# run: | |
| 67 | +# composer analyze |
| 68 | + |
| 69 | + unit-tests: |
| 70 | + needs: phpcs |
| 71 | + |
| 72 | + permissions: |
| 73 | + contents: read # to fetch code (actions/checkout) |
| 74 | + |
| 75 | + name: Unit tests / PHP-${{ matrix.php }} |
| 76 | + runs-on: ubuntu-22.04 |
| 77 | + |
| 78 | + strategy: |
| 79 | + matrix: |
| 80 | + php: |
| 81 | + - '8.2' |
| 82 | + - '8.3' |
| 83 | + - '8.4' |
| 84 | + |
| 85 | + services: |
| 86 | + mariadb: |
| 87 | + image: mariadb:10.6 |
| 88 | + ports: |
| 89 | + - "3306:3306" |
| 90 | + env: |
| 91 | + MYSQL_ROOT_PASSWORD: secret |
| 92 | + MYSQL_USER: phalcon |
| 93 | + MYSQL_DATABASE: phalcon |
| 94 | + MYSQL_PASSWORD: secret |
| 95 | + |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: "Setup PHP" |
| 100 | + uses: shivammathur/[email protected] |
| 101 | + with: |
| 102 | + php-version: ${{ matrix.php }} |
| 103 | + extensions: ${{ env.EXTENSIONS }} |
| 104 | + tools: pecl |
| 105 | + env: |
| 106 | + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 107 | + |
| 108 | + - name: "Install development dependencies with Composer" |
| 109 | + uses: "ramsey/composer-install@v3" |
| 110 | + with: |
| 111 | + composer-options: "--prefer-dist" |
| 112 | + |
| 113 | + - name: "Setup Tests" |
| 114 | + shell: bash |
| 115 | + run: | |
| 116 | + cp config/.env.ci .env |
| 117 | +
|
| 118 | + - name: "Run Unit Tests" |
| 119 | + if: always() |
| 120 | + run: | |
| 121 | + composer test-unit |
| 122 | +
|
| 123 | + - name: "Run Migrations" |
| 124 | + if: always() |
| 125 | + run: | |
| 126 | + composer migrate |
| 127 | +
|
| 128 | + - name: SonarCloud Scan |
15 | 129 | uses: SonarSource/sonarqube-scan-action@v5
|
16 | 130 | env:
|
| 131 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
17 | 132 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
| 133 | + with: |
| 134 | + projectBaseDir: ./ |
| 135 | + args: > |
| 136 | + -Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }} |
| 137 | + -Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }} |
| 138 | + -Dsonar.sources=src/ |
| 139 | + -Dsonar.exclusions=vendor/**,cv/**,tests/** |
| 140 | + -Dsonar.sourceEncoding=UTF-8 |
| 141 | + -Dsonar.language=php |
| 142 | + -Dsonar.tests=tests/ |
0 commit comments