|
| 1 | +name: "Run Codeception Tests" |
| 2 | +description: "Sets up environment and runs Codeception test suites" |
| 3 | +inputs: |
| 4 | + working-directory: |
| 5 | + description: "Plugin directory to run tests in" |
| 6 | + required: true |
| 7 | + php: |
| 8 | + description: "PHP version" |
| 9 | + required: true |
| 10 | + extensions: |
| 11 | + description: "PHP extensions" |
| 12 | + required: true |
| 13 | + wordpress: |
| 14 | + description: "WordPress version" |
| 15 | + required: true |
| 16 | + composer-options: |
| 17 | + description: "Additional composer options" |
| 18 | + required: false |
| 19 | + default: "--no-progress" |
| 20 | +runs: |
| 21 | + using: "composite" |
| 22 | + steps: |
| 23 | + - name: Setup PHP with Cached Composer |
| 24 | + uses: ./.github/actions/setup-php-composer |
| 25 | + with: |
| 26 | + php-version: ${{ inputs.php }} |
| 27 | + working-directory: ${{ inputs.working-directory }} |
| 28 | + composer-options: ${{ inputs.composer-options }} |
| 29 | + |
| 30 | + - name: Setup environment |
| 31 | + run: | |
| 32 | + cp ${{ inputs.working-directory }}/.docker/.env.ci ${{ inputs.working-directory }}/.env |
| 33 | + cd ${{ inputs.working-directory }} |
| 34 | + echo "INCLUDE_EXTENSIONS=${{ inputs.extensions }}" >> .env |
| 35 | + echo "WP_VERSION=${{ inputs.wordpress }}" >> .env |
| 36 | + echo "PHP_VERSION=${{ inputs.php }}" >> .env |
| 37 | + shell: bash |
| 38 | + |
| 39 | + - name: Build test environment |
| 40 | + uses: nick-invision/retry@v2 |
| 41 | + with: |
| 42 | + timeout_minutes: 10 |
| 43 | + max_attempts: 3 |
| 44 | + retry_on: error |
| 45 | + shell: bash |
| 46 | + command: | |
| 47 | + cd ${{ inputs.working-directory }} |
| 48 | + composer run docker:build |
| 49 | + env: |
| 50 | + WP_VERSION: ${{ inputs.wordpress }} |
| 51 | + PHP_VERSION: ${{ inputs.php }} |
| 52 | + |
| 53 | + - name: Start test environment |
| 54 | + working-directory: ${{ inputs.working-directory }} |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + docker compose --env-file .env up --detach |
| 58 | +
|
| 59 | + CONTAINER_ID=$(docker compose ps -q wordpress) |
| 60 | + if [ -n "$CONTAINER_ID" ]; then |
| 61 | + docker exec $CONTAINER_ID init-docker.sh |
| 62 | + else |
| 63 | + echo "Error: WordPress container not found." |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + env: |
| 67 | + WP_VERSION: ${{ inputs.wordpress }} |
| 68 | + PHP_VERSION: ${{ inputs.php }} |
| 69 | + |
| 70 | + - name: Run Acceptance Tests w/ Docker |
| 71 | + working-directory: ${{ inputs.working-directory }} |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + docker exec \ |
| 75 | + --env DEBUG=${{ env.DEBUG }} \ |
| 76 | + --env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \ |
| 77 | + --env SUITES=acceptance \ |
| 78 | + $(docker compose ps -q wordpress) \ |
| 79 | + bash -c "cd wp-content/plugins/$(basename $(echo ${{ inputs.working-directory }} | sed 's:/*$::')) && bin/run-codeception.sh" |
| 80 | + env: |
| 81 | + DEBUG: ${{ env.ACTIONS_STEP_DEBUG }} |
| 82 | + SKIP_TESTS_CLEANUP: "true" |
| 83 | + continue-on-error: true |
| 84 | + |
| 85 | + - name: Run Functional Tests w/ Docker |
| 86 | + working-directory: ${{ inputs.working-directory }} |
| 87 | + shell: bash |
| 88 | + run: | |
| 89 | + docker exec \ |
| 90 | + --env DEBUG=${{ env.DEBUG }} \ |
| 91 | + --env SKIP_TESTS_CLEANUP=${{ env.SKIP_TESTS_CLEANUP }} \ |
| 92 | + --env SUITES=functional \ |
| 93 | + $(docker compose ps -q wordpress) \ |
| 94 | + bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh" |
| 95 | + env: |
| 96 | + DEBUG: ${{ env.ACTIONS_STEP_DEBUG }} |
| 97 | + SKIP_TESTS_CLEANUP: "true" |
| 98 | + continue-on-error: true |
| 99 | + |
| 100 | + - name: Run WPUnit Tests w/ Docker |
| 101 | + working-directory: ${{ inputs.working-directory }} |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + docker exec \ |
| 105 | + --env COVERAGE=${{ inputs.coverage }} \ |
| 106 | + --env USING_XDEBUG=${{ inputs.coverage }} \ |
| 107 | + --env DEBUG=${{ env.DEBUG }} \ |
| 108 | + --env SUITES=wpunit \ |
| 109 | + $(docker compose ps -q wordpress) \ |
| 110 | + bash -c "cd wp-content/plugins/$(basename ${{ inputs.working-directory }}) && bin/run-codeception.sh" |
| 111 | + env: |
| 112 | + DEBUG: ${{ env.ACTIONS_STEP_DEBUG }} |
0 commit comments