|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + # Run on pushes to `master` and on all pull requests. |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + pull_request: |
| 9 | + # Also run this workflow on day 15 of every month as the repo isn't that active. |
| 10 | + schedule: |
| 11 | + - cron: '0 0 15 * *' |
| 12 | + |
| 13 | +jobs: |
| 14 | + xmllint: |
| 15 | + name: 'Check XML' |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + env: |
| 19 | + XMLLINT_INDENT: ' ' |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Install PHP |
| 26 | + uses: shivammathur/setup-php@v2 |
| 27 | + with: |
| 28 | + php-version: '7.4' |
| 29 | + coverage: none |
| 30 | + |
| 31 | + # Install dependencies to make sure the PHPCS XSD file is available. |
| 32 | + - name: Install dependencies |
| 33 | + run: composer install --no-dev --no-interaction --no-progress |
| 34 | + |
| 35 | + - name: Setup xmllint |
| 36 | + run: sudo apt-get install --no-install-recommends -y libxml2-utils |
| 37 | + |
| 38 | + # Show violations inline in the file diff. |
| 39 | + # @link https://github.com/marketplace/actions/xmllint-problem-matcher |
| 40 | + - uses: korelstar/xmllint-problem-matcher@v1 |
| 41 | + |
| 42 | + # Validate the xml file. |
| 43 | + # @link http://xmlsoft.org/xmllint.html |
| 44 | + - name: Validate against schema |
| 45 | + run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml |
| 46 | + |
| 47 | + # Check the code-style consistency of the xml file. |
| 48 | + - name: Check code style |
| 49 | + run: | |
| 50 | + diff -B ./PHPCompatibilityPasswordCompat/ruleset.xml <(xmllint --format "./PHPCompatibilityPasswordCompat/ruleset.xml") |
| 51 | +
|
| 52 | + test: |
| 53 | + needs: xmllint |
| 54 | + runs-on: ubuntu-latest |
| 55 | + |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + php: ['5.4', 'latest'] |
| 59 | + phpcompat: ['stable'] |
| 60 | + experimental: [false] |
| 61 | + |
| 62 | + include: |
| 63 | + - php: '7.4' |
| 64 | + phpcompat: 'dev-develop as 9.99.99' |
| 65 | + experimental: true |
| 66 | + |
| 67 | + name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}" |
| 68 | + continue-on-error: ${{ matrix.experimental }} |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Checkout code |
| 72 | + uses: actions/checkout@v2 |
| 73 | + |
| 74 | + - name: Install PHP |
| 75 | + uses: shivammathur/setup-php@v2 |
| 76 | + with: |
| 77 | + php-version: ${{ matrix.php }} |
| 78 | + coverage: none |
| 79 | + |
| 80 | + - name: Conditionally update PHPCompatibility to develop version |
| 81 | + if: ${{ matrix.phpcompat != 'stable' }} |
| 82 | + run: | |
| 83 | + composer config minimum-stability dev |
| 84 | + composer require --no-update phpcompatibility/php-compatibility:"${{ matrix.phpcompat }}" |
| 85 | +
|
| 86 | + - name: Install dependencies |
| 87 | + run: composer install --no-interaction --no-progress |
| 88 | + |
| 89 | + # Validate the composer.json file. |
| 90 | + # @link https://getcomposer.org/doc/03-cli.md#validate |
| 91 | + - name: Validate Composer installation |
| 92 | + run: composer validate --no-check-all --strict |
| 93 | + |
| 94 | + # Make sure that known polyfills don't trigger any errors. |
| 95 | + - name: Test the ruleset |
| 96 | + run: | |
| 97 | + vendor/bin/phpcs -ps ./Test/PasswordCompatTest.php --standard=PHPCompatibilityPasswordCompat --runtime-set testVersion 5.4- |
| 98 | +
|
| 99 | + # Check that the ruleset doesn't throw unnecessary errors for the compat library itself. |
| 100 | + - name: Test running against the polyfills |
| 101 | + run: | |
| 102 | + vendor/bin/phpcs -ps ./vendor/ircmaxell/ --standard=PHPCompatibilityPasswordCompat --runtime-set testVersion 5.4- --ignore=/password-compat/test/* |
0 commit comments