|
| 1 | +name: Testing |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + unit: #----------------------------------------------------------------------- |
| 8 | + name: Unit test / PHP ${{ matrix.php }} |
| 9 | + strategy: |
| 10 | + fail-fast: false |
| 11 | + matrix: |
| 12 | + php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] |
| 13 | + runs-on: ubuntu-20.04 |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Check out source code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: Check existence of composer.json file |
| 20 | + id: check_files |
| 21 | + uses: andstor/file-existence-action@v1 |
| 22 | + with: |
| 23 | + files: "composer.json, phpunit.xml.dist" |
| 24 | + |
| 25 | + - name: Set up PHP environment |
| 26 | + if: steps.check_files.outputs.files_exists == 'true' |
| 27 | + uses: shivammathur/setup-php@v2 |
| 28 | + with: |
| 29 | + php-version: '${{ matrix.php }}' |
| 30 | + coverage: none |
| 31 | + tools: composer,cs2pr |
| 32 | + |
| 33 | + - name: Get Composer cache Directory |
| 34 | + if: steps.check_files.outputs.files_exists == 'true' |
| 35 | + id: composer-cache |
| 36 | + run: | |
| 37 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 38 | +
|
| 39 | + - name: Use Composer cache |
| 40 | + if: steps.check_files.outputs.files_exists == 'true' |
| 41 | + uses: actions/cache@master |
| 42 | + with: |
| 43 | + path: ${{ steps['composer-cache'].outputs.dir }} |
| 44 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-composer- |
| 47 | +
|
| 48 | + - name: Install dependencies |
| 49 | + if: steps.check_files.outputs.files_exists == 'true' |
| 50 | + run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest |
| 51 | + |
| 52 | + - name: Setup problem matcher to provide annotations for PHPUnit |
| 53 | + if: steps.check_files.outputs.files_exists == 'true' |
| 54 | + run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" |
| 55 | + |
| 56 | + - name: Run PHPUnit |
| 57 | + if: steps.check_files.outputs.files_exists == 'true' |
| 58 | + run: composer phpunit |
| 59 | + |
| 60 | + functional: #---------------------------------------------------------------------- |
| 61 | + name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }} |
| 62 | + strategy: |
| 63 | + fail-fast: false |
| 64 | + matrix: |
| 65 | + php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] |
| 66 | + wp: ['latest'] |
| 67 | + mysql: ['8.0'] |
| 68 | + test: ["composer behat || composer behat-rerun"] |
| 69 | + include: |
| 70 | + - php: '5.6' |
| 71 | + wp: 'trunk' |
| 72 | + mysql: '8.0' |
| 73 | + test: "composer behat || composer behat-rerun" |
| 74 | + - php: '5.6' |
| 75 | + wp: 'trunk' |
| 76 | + mysql: '5.7' |
| 77 | + test: "composer behat || composer behat-rerun" |
| 78 | + - php: '5.6' |
| 79 | + wp: 'trunk' |
| 80 | + mysql: '5.6' |
| 81 | + test: "composer behat || composer behat-rerun" |
| 82 | + - php: '7.4' |
| 83 | + wp: 'trunk' |
| 84 | + mysql: '8.0' |
| 85 | + test: "composer behat || composer behat-rerun" |
| 86 | + - php: '8.0' |
| 87 | + wp: 'trunk' |
| 88 | + mysql: '8.0' |
| 89 | + test: "composer behat || composer behat-rerun" |
| 90 | + - php: '8.0' |
| 91 | + wp: 'trunk' |
| 92 | + mysql: '5.7' |
| 93 | + test: "composer behat || composer behat-rerun" |
| 94 | + - php: '8.0' |
| 95 | + wp: 'trunk' |
| 96 | + mysql: '5.6' |
| 97 | + test: "composer behat || composer behat-rerun" |
| 98 | + - php: '5.6' |
| 99 | + wp: '3.7' |
| 100 | + mysql: '5.6' |
| 101 | + test: "composer behat || composer behat-rerun" |
| 102 | + runs-on: ubuntu-20.04 |
| 103 | + |
| 104 | + services: |
| 105 | + mysql: |
| 106 | + image: mysql:${{ matrix.mysql }} |
| 107 | + ports: |
| 108 | + - 3306 |
| 109 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: Check out source code |
| 113 | + uses: actions/checkout@v2 |
| 114 | + |
| 115 | + - name: Check existence of composer.json & behat.yml files |
| 116 | + id: check_files |
| 117 | + uses: andstor/file-existence-action@v1 |
| 118 | + with: |
| 119 | + files: "composer.json, behat.yml" |
| 120 | + |
| 121 | + - name: Set up PHP envirnoment |
| 122 | + if: steps.check_files.outputs.files_exists == 'true' |
| 123 | + uses: shivammathur/setup-php@v2 |
| 124 | + with: |
| 125 | + php-version: '${{ matrix.php }}' |
| 126 | + extensions: mysql, zip |
| 127 | + coverage: none |
| 128 | + tools: composer |
| 129 | + |
| 130 | + - name: Get Composer cache Directory |
| 131 | + if: steps.check_files.outputs.files_exists == 'true' |
| 132 | + id: composer-cache |
| 133 | + run: | |
| 134 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 135 | +
|
| 136 | + - name: Use Composer cache |
| 137 | + if: steps.check_files.outputs.files_exists == 'true' |
| 138 | + uses: actions/cache@master |
| 139 | + with: |
| 140 | + path: ${{ steps['composer-cache'].outputs.dir }} |
| 141 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 142 | + restore-keys: | |
| 143 | + ${{ runner.os }}-composer- |
| 144 | +
|
| 145 | + - name: Install dependencies |
| 146 | + if: steps.check_files.outputs.files_exists == 'true' |
| 147 | + run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest |
| 148 | + |
| 149 | + - name: Start MySQL server |
| 150 | + if: steps.check_files.outputs.files_exists == 'true' |
| 151 | + run: sudo systemctl start mysql |
| 152 | + |
| 153 | + - name: Configure DB environment |
| 154 | + if: steps.check_files.outputs.files_exists == 'true' |
| 155 | + run: | |
| 156 | + echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV |
| 157 | + echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV |
| 158 | + echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV |
| 159 | + echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV |
| 160 | + echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV |
| 161 | + echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV |
| 162 | + echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV |
| 163 | +
|
| 164 | + - name: Prepare test database |
| 165 | + if: steps.check_files.outputs.files_exists == 'true' |
| 166 | + run: composer prepare-tests |
| 167 | + |
| 168 | + - name: Run Behat |
| 169 | + if: steps.check_files.outputs.files_exists == 'true' |
| 170 | + env: |
| 171 | + WP_VERSION: '${{ matrix.wp }}' |
| 172 | + run: ${{ matrix.test }} |
0 commit comments