|
| 1 | +name: CS |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on all pushes and on all pull requests. |
| 5 | + # Prevent the build from running when there are only irrelevant changes. |
| 6 | + push: |
| 7 | + pull_request: |
| 8 | + # Allow manually triggering the workflow. |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 12 | +concurrency: |
| 13 | + # The concurrency group contains the workflow name and the branch name. |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + checkcs: |
| 19 | + name: 'Basic CS and QA checks' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + env: |
| 23 | + XMLLINT_INDENT: ' ' |
| 24 | + # - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI. |
| 25 | + COMPOSER_ROOT_VERSION: '1.99.99' |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Install PHP |
| 32 | + uses: shivammathur/setup-php@v2 |
| 33 | + with: |
| 34 | + php-version: '7.4' |
| 35 | + coverage: none |
| 36 | + tools: cs2pr |
| 37 | + |
| 38 | + # Validate the composer.json file. |
| 39 | + # @link https://getcomposer.org/doc/03-cli.md#validate |
| 40 | + - name: Validate Composer installation |
| 41 | + run: composer validate --no-check-all --strict |
| 42 | + |
| 43 | + - name: 'Composer: adjust dependencies' |
| 44 | + run: | |
| 45 | + # The sniff stage doesn't run the unit tests, so no need for PHPUnit. |
| 46 | + composer remove --no-update --dev phpunit/phpunit --no-scripts |
| 47 | + # Using PHPCS `master` as an early detection system for bugs upstream. |
| 48 | + composer require --no-update squizlabs/php_codesniffer:"dev-master" |
| 49 | +
|
| 50 | + # Install dependencies and handle caching in one go. |
| 51 | + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer |
| 52 | + - name: Install Composer dependencies |
| 53 | + uses: "ramsey/composer-install@v2" |
| 54 | + |
| 55 | + - name: Install xmllint |
| 56 | + run: | |
| 57 | + sudo apt-get update |
| 58 | + sudo apt-get install --no-install-recommends -y libxml2-utils |
| 59 | +
|
| 60 | + # Show XML violations inline in the file diff. |
| 61 | + # @link https://github.com/marketplace/actions/xmllint-problem-matcher |
| 62 | + - uses: korelstar/xmllint-problem-matcher@v1 |
| 63 | + |
| 64 | + # Validate the XML file. |
| 65 | + # @link http://xmlsoft.org/xmllint.html |
| 66 | + - name: Validate rulesets against schema |
| 67 | + run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml |
| 68 | + |
| 69 | + # Check the code-style consistency of the XML file. |
| 70 | + - name: Check XML code style |
| 71 | + run: | |
| 72 | + diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml") |
| 73 | + diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml") |
| 74 | +
|
| 75 | + # Check the code-style consistency of the PHP files. |
| 76 | + - name: Check PHP code style |
| 77 | + id: phpcs |
| 78 | + run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml |
| 79 | + |
| 80 | + - name: Show PHPCS results in PR |
| 81 | + if: ${{ always() && steps.phpcs.outcome == 'failure' }} |
| 82 | + run: cs2pr ./phpcs-report.xml |
| 83 | + |
| 84 | + markdownlint: |
| 85 | + name: 'Lint Markdown' |
| 86 | + runs-on: ubuntu-latest |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Checkout code |
| 90 | + uses: actions/checkout@v3 |
| 91 | + |
| 92 | + # This action also handles the caching of the dependencies. |
| 93 | + # https://github.com/actions/setup-node |
| 94 | + - name: Set up node and enable caching of dependencies |
| 95 | + uses: actions/setup-node@v3 |
| 96 | + with: |
| 97 | + node-version: '16' |
| 98 | + |
| 99 | + # @link https://github.com/DavidAnson/markdownlint-cli2 |
| 100 | + # @link https://github.com/DavidAnson/markdownlint |
| 101 | + - name: Install Markdownlint CLI2 |
| 102 | + run: npm install -g markdownlint-cli2 |
| 103 | + |
| 104 | + # @link https://github.com/marketplace/actions/problem-matcher-for-markdownlint-cli |
| 105 | + - name: Enable showing issue in PRs |
| 106 | + uses: xt0rted/markdownlint-problem-matcher@v2 |
| 107 | + |
| 108 | + - name: Check markdown with CLI2 |
| 109 | + run: markdownlint-cli2 |
| 110 | + |
| 111 | + remark: |
| 112 | + name: 'QA Markdown' |
| 113 | + runs-on: ubuntu-latest |
| 114 | + |
| 115 | + steps: |
| 116 | + - name: Checkout code |
| 117 | + uses: actions/checkout@v3 |
| 118 | + |
| 119 | + - name: Set up node and enable caching of dependencies |
| 120 | + uses: actions/setup-node@v3 |
| 121 | + with: |
| 122 | + node-version: '16' |
| 123 | + |
| 124 | + # To make the command available on CLI, it needs to be installed globally. |
| 125 | + - name: Install Remark CLI globally |
| 126 | + run: npm install --global remark-cli --foreground-scripts true --fund false |
| 127 | + |
| 128 | + # To allow for creating a custom config which references rules which are included |
| 129 | + # in the presets, without having to install all rules individually, a local install |
| 130 | + # works best (and installing the presets in the first place, of course). |
| 131 | + # |
| 132 | + # Note: the first group of packages are all part of the mono "Remark lint" repo. |
| 133 | + # The second group of packages (heading-whitespace and down) are additional |
| 134 | + # "external" rules/plugins. |
| 135 | + - name: Install Remark rules locally |
| 136 | + run: > |
| 137 | + npm install --foreground-scripts true --fund false |
| 138 | + remark-lint |
| 139 | + remark-gfm |
| 140 | + remark-preset-lint-consistent |
| 141 | + remark-preset-lint-recommended |
| 142 | + remark-preset-lint-markdown-style-guide |
| 143 | + remark-lint-checkbox-content-indent |
| 144 | + remark-lint-linebreak-style |
| 145 | + remark-lint-no-duplicate-defined-urls |
| 146 | + remark-lint-no-empty-url |
| 147 | + remark-lint-no-heading-like-paragraph |
| 148 | + remark-lint-no-reference-like-url |
| 149 | + remark-lint-no-unneeded-full-reference-image |
| 150 | + remark-lint-no-unneeded-full-reference-link |
| 151 | + remark-lint-strikethrough-marker |
| 152 | + remark-lint-heading-whitespace |
| 153 | + remark-lint-list-item-punctuation |
| 154 | + remark-lint-match-punctuation |
| 155 | + remark-lint-no-hr-after-heading |
| 156 | + remark-lint-are-links-valid-alive |
| 157 | + remark-lint-are-links-valid-duplicate |
| 158 | + remark-validate-links |
| 159 | +
|
| 160 | + - name: Run Remark-lint |
| 161 | + run: remark . --frail |
| 162 | + |
| 163 | + # @link https://github.com/reviewdog/action-remark-lint |
| 164 | + - name: Show Remark-lint annotations in PR |
| 165 | + if: ${{ failure() && github.event_name == 'pull_request' }} |
| 166 | + uses: reviewdog/action-remark-lint@v5 |
| 167 | + with: |
| 168 | + fail_on_error: true |
| 169 | + install_deps: false |
| 170 | + level: info |
| 171 | + reporter: github-pr-check |
| 172 | + |
| 173 | + yamllint: |
| 174 | + name: 'Lint Yaml' |
| 175 | + runs-on: ubuntu-latest |
| 176 | + |
| 177 | + steps: |
| 178 | + - name: Checkout code |
| 179 | + uses: actions/checkout@v3 |
| 180 | + |
| 181 | + - name: Run Yamllint on all yaml files in repo |
| 182 | + run: yamllint . --format colored --strict |
| 183 | + |
| 184 | + - name: Pipe Yamllint results on to GH for inline display |
| 185 | + if: ${{ failure() }} |
| 186 | + run: yamllint . --format github --strict |
0 commit comments