Ppeter279kResolves #1331
bead6d6c创建于 2023年11月27日历史提交
name: Tests

on:
    push:
        branches: [ main, master ]
    pull_request:
    release:
        types: [ created ]

jobs:
    unit-tests:
        runs-on: ${{ matrix.operating-system }}
        strategy:
            matrix:
                operating-system: [ ubuntu-latest ]
                php-versions:
                    - '7.2'
                    - '7.3'
                    - '7.4'
                    - '8.0'
                    - '8.1'
                    - '8.2'
                    - '8.3'
        name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

        steps:
            -   name: Checkout
                uses: actions/checkout@v3

            -   name: Setup PHP
                uses: shivammathur/setup-php@v2
                with:
                    php-version: ${{ matrix.php-versions }}
                    extensions: mbstring, intl, zip, xml
                    coverage: none

            -   name: Install dependencies
                uses: ramsey/composer-install@v2

            -   name: Update PHPUnit
                run: composer update phpunit/phpunit --with-dependencies

            -   name: Run test suite
                run: vendor/bin/phpunit --exclude-group mayignore --coverage-clover build/logs/clover.xml


    # This is a "trick", a meta task which does not change, and we can use in
    # the protected branch rules as opposed to the tests one above which
    # may change regularly.
    validate-tests:
        name: Tests status
        runs-on: ubuntu-latest
        needs:
            - unit-tests
        if: always()
        steps:
            - name: Successful run
              if: ${{ !(contains(needs.*.result, 'failure')) }}
              run: exit 0

            - name: Failing run
              if: ${{ contains(needs.*.result, 'failure') }}
              run: exit 1