• Hi everyone,

    I’m running into an issue when using @wordpress/env (wp-env) in a GitLab CI/CD pipeline to run PHPUnit tests.

    The test runner inside the tests-wordpress container fails with the following error:

    Could not find /wordpress-phpunit/includes/functions.php, have you run install-wp-tests.sh ?

    gitlab-ci.yml

    stages:
    - test

    .parallel:
    parallel:
    matrix:
    - PHP_VERSION: ['8.2']
    WP_VERSION: ['6.6']

    .installApkDependencies: &installApkDependencies |
    apk add --no-cache \
    shadow \
    nodejs \
    npm \
    unzip \
    git \
    su-exec \
    curl \
    php${PHP_VERSION/./} \
    php${PHP_VERSION/./}-curl \
    php${PHP_VERSION/./}-phar \
    php${PHP_VERSION/./}-mbstring \
    php${PHP_VERSION/./}-iconv \
    php${PHP_VERSION/./}-openssl \
    php${PHP_VERSION/./}-dom \
    php${PHP_VERSION/./}-xml \
    php${PHP_VERSION/./}-xmlwriter \
    php${PHP_VERSION/./}-tokenizer \
    php${PHP_VERSION/./}-json \
    php${PHP_VERSION/./}-fileinfo \
    php${PHP_VERSION/./}-simplexml \
    php${PHP_VERSION/./}-xmlreader \
    php${PHP_VERSION/./}-zip \
    unzip \
    php${PHP_VERSION/./}-ctype \
    php${PHP_VERSION/./}-zlib


    .installcomposer: &installcomposer |
    curl -sS https://getcomposer.org/installer -o composer-setup.php
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    rm -rf composer-setup.php

    test:
    stage: test
    image: docker:28.0.4
    services:
    - name: docker:28.0.4-dind
    variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
    before_script:
    - *installApkDependencies

    - "[ -f /usr/bin/php ] || ln -s /usr/bin/php${PHP_VERSION/./} /usr/bin/php"

    - *installcomposer

    - adduser -D -u 1000 wpuser
    - chown -R wpuser:wpuser .

    - su-exec wpuser composer install
    - su-exec wpuser npm ci

    script:
    - echo "🚀 Testing PHP ${PHP_VERSION} on WP ${WP_VERSION}"
    - su-exec wpuser sh -c "WP_ENV_CORE=\"WordPress/WordPress#${WP_VERSION}\" npm run env:start-ci"
    - su-exec wpuser sh -c "npm run env:path"
    - su-exec wpuser sh -c "npm run env run tests-wordpress composer update -- -W --working-dir=wp-content/plugins/plugin-test-ci/"
    - su-exec wpuser sh -c "npm run env run tests-wordpress composer update -- --dev yoast/phpunit-polyfills -W --working-dir=wp-content/plugins/plugin-test-ci/"
    - su-exec wpuser sh -c "npm run test:php"


    after_script:
    - echo "AFTER SCRIPT"
    - su-exec wpuser npm run env:stop || true
    - echo "y" | su-exec wpuser npm run env:destroy || true
    parallel: !reference [.parallel,parallel]
    resource_group: parallel

    Questions:

    1. Is this a known issue with wp-env?

    2. Is there a recommended way to run wp-env PHP tests inside CI/CD pipelines (other than GitHub Actions)?

    3. Any example .gitlab-ci.yml setups available for wp-env + PHPUnit?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘wp-env does not properly mount /wordpress-phpunit in GitLab CI (tests-wordpress)’ is closed to new replies.