|
| 1 | +name: Manual Test Runner |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + wp-version: |
| 7 | + description: 'WordPress Version to be tested: `latest` or a specific version number.' |
| 8 | + type: string |
| 9 | + default: 'latest' |
| 10 | + wc-version: |
| 11 | + description: 'WooCommerce Version to be tested: `latest`, `nightly` or a specific version number.' |
| 12 | + type: string |
| 13 | + default: 'latest' |
| 14 | + php-version: |
| 15 | + description: | |
| 16 | + PHP version. Default is `8.4`. |
| 17 | + type: string |
| 18 | + default: '8.4' |
| 19 | + extension-tests: |
| 20 | + description: 'Extension Tests' |
| 21 | + type: choice |
| 22 | + default: 'All' |
| 23 | + options: |
| 24 | + # - 'E2E Tests' // enable this once we have E2E tests |
| 25 | + - 'Unit Tests' |
| 26 | + - 'All' |
| 27 | + - 'None' |
| 28 | + - 'E2E' |
| 29 | + qit-tests: |
| 30 | + description: 'QIT Tests' |
| 31 | + type: choice |
| 32 | + options: |
| 33 | + - 'WooCommerce Pre-Release Tests (includes Activation, WooCommerce E2E and API tests)' |
| 34 | + - 'Code Quality Checks (includes Security, Validation, Malware, PHPStan, and PHP Compatibility tests)' |
| 35 | + - 'Activation' |
| 36 | + - 'Security' |
| 37 | + - 'Validation' |
| 38 | + - 'Malware' |
| 39 | + - 'PHPStan' |
| 40 | + - 'PHP Compatibility' |
| 41 | + - 'WooCommerce E2E and API tests' |
| 42 | + - 'Plugin Checks (for dotOrg metadata)' |
| 43 | + - 'None' |
| 44 | + qit-wait: |
| 45 | + description: 'Wait for QIT? Requires additional time for the QIT tests to complete within GHA.' |
| 46 | + type: boolean |
| 47 | + default: true |
| 48 | + options: |
| 49 | + description: 'QIT Additional options for `qit` command, like `--optional_features=hpos`.' |
| 50 | + type: string |
| 51 | + default: '' |
| 52 | + |
| 53 | +run-name: Tests with WP-${{ inputs.wp-version }} - WC-${{ inputs.wc-version }} - PHP ${{ inputs.php-version }} - Tests ${{ inputs.extension-tests }} - QIT ${{ inputs.qit-tests }} |
| 54 | + |
| 55 | +jobs: |
| 56 | + find_latest_versions: |
| 57 | + name: Get supported WP & WC versions |
| 58 | + runs-on: ubuntu-latest |
| 59 | + outputs: |
| 60 | + wc_versions: ${{ steps.get_wc_versions_for_matrix.outputs.wc_versions }} |
| 61 | + wp_versions: ${{ steps.get_wp_versions_for_matrix.outputs.wp_versions }} |
| 62 | + wc_rc_version: ${{ steps.get_wc_rc_versions_for_matrix.outputs.wc_rc_version }} |
| 63 | + steps: |
| 64 | + - name: Checkout WooCommerce Shipping |
| 65 | + uses: actions/checkout@v4 |
| 66 | + - name: Get current branch |
| 67 | + id: get_branch |
| 68 | + run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT |
| 69 | + - name: Get WordPress versions |
| 70 | + id: get_wp_versions_for_matrix |
| 71 | + run: | |
| 72 | + if [ "${{ steps.get_branch.outputs.branch }}" == "trunk" ]; then |
| 73 | + echo "wp_versions=$(git ls-remote --tags --refs https://github.com/WordPress/WordPress.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 3)" >> $GITHUB_OUTPUT |
| 74 | + else |
| 75 | + echo "wp_versions=$(git ls-remote --tags --refs https://github.com/WordPress/WordPress.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 1)" >> $GITHUB_OUTPUT |
| 76 | + fi |
| 77 | + - name: Get WooCommerce versions |
| 78 | + id: get_wc_versions_for_matrix |
| 79 | + run: | |
| 80 | + if [ "${{ steps.get_branch.outputs.branch }}" == "trunk" ]; then |
| 81 | + echo "wc_versions=$(git ls-remote --tags --refs https://github.com/woocommerce/woocommerce.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 3)" >> $GITHUB_OUTPUT |
| 82 | + else |
| 83 | + echo "wc_versions=$(git ls-remote --tags --refs https://github.com/woocommerce/woocommerce.git | sed 's/.*refs\/tags\///' | php ./bin/get-latest-version.php 1)" >> $GITHUB_OUTPUT |
| 84 | + fi |
| 85 | + - name: Get WooCommerce RC versions |
| 86 | + id: get_wc_rc_versions_for_matrix |
| 87 | + run: | |
| 88 | + echo "wc_rc_version=$(curl -s https://api.github.com/repos/woocommerce/woocommerce/releases | jq -r '[.[] | select(.tag_name | ascii_downcase | contains("rc"))] | sort_by(.published_at) | reverse | .[0].tag_name')" >> $GITHUB_OUTPUT |
| 89 | +
|
| 90 | + js-tests: |
| 91 | + if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'Unit') |
| 92 | + name: JS ESLint Tests |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + with: |
| 97 | + submodules: recursive |
| 98 | + - uses: actions/setup-node@v3 |
| 99 | + with: |
| 100 | + node-version-file: '.nvmrc' |
| 101 | + - run: git config --global url.https://github.com/.insteadOf git://github.com/ |
| 102 | + - run: npm ci |
| 103 | + - run: npm run eslint |
| 104 | + - run: npm run test |
| 105 | + |
| 106 | + php-tests: |
| 107 | + if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'Unit') |
| 108 | + name: PHP Tests |
| 109 | + needs: find_latest_versions |
| 110 | + uses: ./.github/workflows/unit_test_runner.yml |
| 111 | + with: |
| 112 | + wp_version: ${{ inputs.wp-version == 'latest' && fromJSON(needs.find_latest_versions.outputs.wp_versions)[0] || inputs.wp-version }} |
| 113 | + wc_version: ${{ inputs.wc-version == 'latest' && fromJSON(needs.find_latest_versions.outputs.wc_versions)[0] || inputs.wc-version == 'rc' && needs.find_latest_versions.outputs.wc_rc_version || inputs.wc-version }} |
| 114 | + php_version: ${{ inputs.php-version }} |
| 115 | + |
| 116 | + build_project: |
| 117 | + name: Package |
| 118 | + uses: ./.github/workflows/build.yml |
| 119 | + with: |
| 120 | + plugin_name: woocommerce-services |
| 121 | + |
| 122 | + qit-tests: |
| 123 | + name: QIT |
| 124 | + needs: build_project |
| 125 | + uses: ./.github/workflows/qit_runner.yml |
| 126 | + with: |
| 127 | + extension: ${{ needs.build_project.outputs.plugin_name }} |
| 128 | + artifact: ${{ needs.build_project.outputs.plugin_name }} |
| 129 | + wp-version: ${{ inputs.wp-version == 'latest' && 'stable' || inputs.wp-version }} |
| 130 | + wc-version: ${{ inputs.wc-version == 'latest' && 'stable' || contains( inputs.wc-version, 'rc' ) && 'rc' || inputs.wc-version }} |
| 131 | + php-version: ${{ inputs.php-version }} |
| 132 | + test-activation: ${{ contains(inputs.qit-tests, 'Activation') && true || false }} |
| 133 | + test-security: ${{ contains(inputs.qit-tests, 'Security') && true || false }} |
| 134 | + test-phpcompatibility: ${{ contains(inputs.qit-tests, 'Compatibility') && true || false }} |
| 135 | + test-phpstan: ${{ contains(inputs.qit-tests, 'PHPStan') && true || false }} |
| 136 | + test-woo-api: ${{ contains(inputs.qit-tests, 'API') && true || false }} |
| 137 | + test-woo-e2e: ${{ contains(inputs.qit-tests, 'WooCommerce E2E') && true || false }} |
| 138 | + test-malware: ${{ contains(inputs.qit-tests, 'Malware') && true || false }} |
| 139 | + test-validation: ${{ contains(inputs.qit-tests, 'Validation') && true || false }} |
| 140 | + test-plugin-check: ${{ contains(inputs.qit-tests, 'dotOrg') && true || false }} |
| 141 | + options: ${{ inputs.options }} |
| 142 | + wait: ${{ inputs.qit-wait }} |
| 143 | + secrets: inherit |
| 144 | + |
| 145 | + e2e-tests: |
| 146 | + if: contains(inputs.extension-tests, 'All') || contains(inputs.extension-tests, 'E2E') |
| 147 | + name: E2E tests |
| 148 | + needs: build_project |
| 149 | + uses: ./.github/workflows/e2e_runner.yml |
| 150 | + with: |
| 151 | + php_version: ${{ inputs.php-version }} |
| 152 | + secrets: inherit |
| 153 | + |
| 154 | + handle-success: |
| 155 | + if: | |
| 156 | + always() && |
| 157 | + (needs.qit-tests.result == 'success' || needs.qit-tests.result == 'skipped') && |
| 158 | + (needs.php-tests.result == 'success' || needs.php-tests.result == 'skipped') && |
| 159 | + (needs.js-tests.result == 'success' || needs.js-tests.result == 'skipped') && |
| 160 | + (needs.e2e-tests.result == 'success' || needs.e2e-tests.result == 'skipped') |
| 161 | + needs: [qit-tests, php-tests, js-tests, e2e-tests] |
| 162 | + name: Handle success |
| 163 | + runs-on: ubuntu-latest |
| 164 | + env: |
| 165 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 166 | + steps: |
| 167 | + - uses: act10ns/slack@v2 |
| 168 | + with: |
| 169 | + status: success |
| 170 | + message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> passed.' |
| 171 | + |
| 172 | + handle-cancelled: |
| 173 | + if: cancelled() |
| 174 | + needs: [qit-tests, php-tests, js-tests, e2e-tests] |
| 175 | + name: Handle cancellation |
| 176 | + runs-on: ubuntu-latest |
| 177 | + env: |
| 178 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 179 | + steps: |
| 180 | + - uses: act10ns/slack@v2 |
| 181 | + with: |
| 182 | + status: cancelled |
| 183 | + message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> cancelled.' |
| 184 | + |
| 185 | + handle-error: |
| 186 | + if: failure() |
| 187 | + needs: [qit-tests, php-tests, js-tests, e2e-tests] |
| 188 | + name: Handle failure |
| 189 | + runs-on: ubuntu-latest |
| 190 | + env: |
| 191 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 192 | + steps: |
| 193 | + - uses: act10ns/slack@v2 |
| 194 | + with: |
| 195 | + status: failure |
| 196 | + message: 'Test Runner Workflow <{{workflowUrl}}|{{workflow}}> with run ID <{{workflowRunUrl}}|{{runId}}> failed.' |
0 commit comments