|
| 1 | +--- |
| 2 | + |
| 3 | +on: # yamllint disable-line rule:truthy |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - develop |
| 8 | + |
| 9 | +name: 🧹 Fix PHP coding standards |
| 10 | + |
| 11 | +env: |
| 12 | + # Disable docker support in Makefile |
| 13 | + APP_RUNNER: 'cd app &&' |
| 14 | + |
| 15 | +jobs: |
| 16 | + commit-linting: |
| 17 | + timeout-minutes: 4 |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: read |
| 22 | + steps: |
| 23 | + - name: 📦 Check out the codebase |
| 24 | + uses: actions/checkout@v4.1.6 |
| 25 | + |
| 26 | + - name: 🧐 Lint commits using "commitlint" |
| 27 | + uses: wagoid/commitlint-github-action@v6.0.1 |
| 28 | + with: |
| 29 | + configFile: ${{ github.workspace }}/.github/.commitlint.config.mjs |
| 30 | + failOnWarnings: false |
| 31 | + failOnErrors: false |
| 32 | + helpURL: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' |
| 33 | + |
| 34 | + yaml-linting: |
| 35 | + timeout-minutes: 4 |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + pull-requests: read |
| 40 | + steps: |
| 41 | + - name: 📦 Check out the codebase |
| 42 | + uses: actions/checkout@v4.1.6 |
| 43 | + |
| 44 | + - name: 🧐 Lint YAML files |
| 45 | + uses: ibiqlik/action-yamllint@v3.1.1 |
| 46 | + with: |
| 47 | + config_file: .github/.yamllint.yaml |
| 48 | + file_or_dir: '.' |
| 49 | + strict: true |
| 50 | + |
| 51 | + markdown-linting: |
| 52 | + timeout-minutes: 4 |
| 53 | + runs-on: ubuntu-latest |
| 54 | + concurrency: |
| 55 | + cancel-in-progress: true |
| 56 | + group: markdown-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 57 | + steps: |
| 58 | + - name: 📦 Check out the codebase |
| 59 | + uses: actions/checkout@v4.1.6 |
| 60 | + |
| 61 | + - name: 🧐 Lint Markdown files |
| 62 | + uses: DavidAnson/markdownlint-cli2-action@v16.0.0 |
| 63 | + with: |
| 64 | + globs: | |
| 65 | + **/*.md |
| 66 | + !CHANGELOG.md |
| 67 | + !app/vendor |
| 68 | + !app/node_modules |
| 69 | +
|
| 70 | + composer-linting: |
| 71 | + timeout-minutes: 4 |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + concurrency: |
| 74 | + cancel-in-progress: true |
| 75 | + group: composer-linting-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + os: |
| 79 | + - ubuntu-latest |
| 80 | + php-version: |
| 81 | + - '8.3' |
| 82 | + dependencies: |
| 83 | + - locked |
| 84 | + permissions: |
| 85 | + contents: write |
| 86 | + steps: |
| 87 | + - name: 🛠️ Setup PHP |
| 88 | + uses: shivammathur/setup-php@2.30.4 |
| 89 | + with: |
| 90 | + php-version: ${{ matrix.php-version }} |
| 91 | + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql |
| 92 | + ini-values: error_reporting=E_ALL |
| 93 | + coverage: none |
| 94 | + tools: phive |
| 95 | + |
| 96 | + - name: 📦 Check out the codebase |
| 97 | + uses: actions/checkout@v4.1.6 |
| 98 | + |
| 99 | + - name: 🛠️ Setup problem matchers |
| 100 | + run: | |
| 101 | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 102 | +
|
| 103 | + - name: 🤖 Validate composer.json and composer.lock |
| 104 | + run: make validate-composer |
| 105 | + |
| 106 | + - name: 🔍 Get composer cache directory |
| 107 | + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 |
| 108 | + with: |
| 109 | + working-directory: app |
| 110 | + |
| 111 | + - name: ♻️ Restore cached dependencies installed with composer |
| 112 | + uses: actions/cache@v4.0.2 |
| 113 | + with: |
| 114 | + path: ${{ env.COMPOSER_CACHE_DIR }} |
| 115 | + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} |
| 116 | + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- |
| 117 | + |
| 118 | + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer |
| 119 | + uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 |
| 120 | + with: |
| 121 | + working-directory: app |
| 122 | + dependencies: ${{ matrix.dependencies }} |
| 123 | + |
| 124 | + - name: 📥 Install dependencies with phive |
| 125 | + working-directory: app |
| 126 | + env: |
| 127 | + PHIVE_HOME: .phive |
| 128 | + run: phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D,0x47436587D82C4A39 |
| 129 | + shell: bash |
| 130 | + |
| 131 | + - name: 🔍 Run ergebnis/composer-normalize |
| 132 | + working-directory: app |
| 133 | + run: .phive/composer-normalize --ansi --dry-run |
| 134 | + |
| 135 | + coding-standards: |
| 136 | + timeout-minutes: 4 |
| 137 | + runs-on: ${{ matrix.os }} |
| 138 | + concurrency: |
| 139 | + cancel-in-progress: true |
| 140 | + group: coding-standards-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 141 | + strategy: |
| 142 | + matrix: |
| 143 | + os: |
| 144 | + - ubuntu-latest |
| 145 | + php-version: |
| 146 | + - '8.3' |
| 147 | + dependencies: |
| 148 | + - locked |
| 149 | + permissions: |
| 150 | + contents: write |
| 151 | + steps: |
| 152 | + - name: ⚙️ Set git to use LF line endings |
| 153 | + run: | |
| 154 | + git config --global core.autocrlf false |
| 155 | + git config --global core.eol lf |
| 156 | +
|
| 157 | + - name: 🛠️ Setup PHP |
| 158 | + uses: shivammathur/setup-php@2.30.4 |
| 159 | + with: |
| 160 | + php-version: ${{ matrix.php-version }} |
| 161 | + extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql |
| 162 | + ini-values: error_reporting=E_ALL |
| 163 | + coverage: none |
| 164 | + |
| 165 | + - name: 📦 Check out the codebase |
| 166 | + uses: actions/checkout@v4.1.6 |
| 167 | + |
| 168 | + - name: 🛠️ Setup problem matchers |
| 169 | + run: | |
| 170 | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" |
| 171 | +
|
| 172 | + - name: 🤖 Validate composer.json and composer.lock |
| 173 | + run: make validate-composer |
| 174 | + |
| 175 | + - name: 🔍 Get composer cache directory |
| 176 | + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@v3.1.0 |
| 177 | + with: |
| 178 | + working-directory: app |
| 179 | + |
| 180 | + - name: ♻️ Restore cached dependencies installed with composer |
| 181 | + uses: actions/cache@v4.0.2 |
| 182 | + with: |
| 183 | + path: ${{ env.COMPOSER_CACHE_DIR }} |
| 184 | + key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }} |
| 185 | + restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}- |
| 186 | + |
| 187 | + - name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer |
| 188 | + uses: wayofdev/gh-actions/actions/composer/install@v3.1.0 |
| 189 | + with: |
| 190 | + working-directory: app |
| 191 | + dependencies: ${{ matrix.dependencies }} |
| 192 | + |
| 193 | + - name: 🛠️ Prepare environment |
| 194 | + run: make prepare |
| 195 | + |
| 196 | + - name: 🚨 Run coding standards task |
| 197 | + run: make lint-php |
| 198 | + env: |
| 199 | + PHP_CS_FIXER_IGNORE_ENV: true |
| 200 | + |
| 201 | + - name: 📤 Commit and push changed files back to GitHub |
| 202 | + uses: stefanzweifel/git-auto-commit-action@v5.0.1 |
| 203 | + with: |
| 204 | + commit_message: 'style(php-cs-fixer): lint php files and fix coding standards' |
| 205 | + branch: ${{ github.head_ref }} |
| 206 | + commit_author: 'github-actions <github-actions@users.noreply.github.com>' |
| 207 | + env: |
| 208 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments