Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Travis] Created the local dependency directory on host for Composer command to pass #648

Merged
merged 1 commit into from
Feb 24, 2021

Conversation

mnocon
Copy link
Member

@mnocon mnocon commented Feb 24, 2021

We have builds failing with errors like:

Switched to a new branch 'tmp_76f9e4b'
/home/travis/build/ezplatform
> Make composer use tested dependency local checkout tmp_76f9e4b of ezplatform-workflow
> Require ezsystems/ezplatform-workflow:dev-tmp_76f9e4b as 1.1.x-dev
  [RuntimeException]                                                           
  Failed to read package information from /var/www/ezplatform-workflow as the  
   path does not exist   

Link: https://travis-ci.com/github/ezsystems/ezplatform-admin-ui/builds/218066131

Root cause:
The issue is caused by these lines: https://github.com/ezsystems/ezplatform/blob/master/bin/.travis/trusty/setup_ezplatform.sh#L56-L80

We move the directory containg tested package to another location:
Code:

    # move dependency to directory available for docker volume
    BASE_PACKAGE_NAME=`basename ${DEPENDENCY_PACKAGE_NAME}`
    echo "> Move ${DEPENDENCY_PACKAGE_DIR} to ${EZPLATFORM_BUILD_DIR}/${BASE_PACKAGE_NAME}"
    mv ${DEPENDENCY_PACKAGE_DIR} ${EZPLATFORM_BUILD_DIR}/${BASE_PACKAGE_NAME}
    cd ${EZPLATFORM_BUILD_DIR}/${BASE_PACKAGE_NAME}

Output:

> Move /home/travis/build/ezsystems/ezplatform-workflow to /home/travis/build/ezplatform/ezplatform-workflow

And then try to configure Composer to use that dependency:

    # use local checkout path relative to docker volume
    echo "> Make composer use tested dependency local checkout ${TMP_TRAVIS_BRANCH} of ${BASE_PACKAGE_NAME}"
    composer config repositories.localDependency git /var/www/${BASE_PACKAGE_NAME}

    echo "> Require ${DEPENDENCY_PACKAGE_NAME}:dev-${TMP_TRAVIS_BRANCH} as ${BRANCH_ALIAS}"
    if ! composer require --no-update "${DEPENDENCY_PACKAGE_NAME}:dev-${TMP_TRAVIS_BRANCH} as ${BRANCH_ALIAS}"; then
        echo 'Failed requiring dependency' >&2
        exit 3
    fi

Please note the comment: local checkout path relative to docker volume. We've moved the dependency to /home/travis/build/ezplatform/ezplatform-workflow, but tell Composer to look for it in /var/www/${BASE_PACKAGE_NAME}.

Our Docker containers have the following volumes specified: https://github.com/ezsystems/ezplatform/blob/master/doc/docker/base-dev.yml#L8 (and ${COMPOSE_DIR} evaluates to /home/travis/build/ezplatform/, meaning that /home/travis/build/ezplatform/ezplatform-workflow from host is mapped to /var/www/ezplatform-workflow inside Docker container.

But the next lines:

    if ! composer require --no-update "${DEPENDENCY_PACKAGE_NAME}:dev-${TMP_TRAVIS_BRANCH} as ${BRANCH_ALIAS}"; then
        echo 'Failed requiring dependency' >&2
        exit 3
    fi

So far, we have set Composer up to use a repository which does not exist on host (this is what the error message is saying to us:

  Failed to read package information from /var/www/ezplatform-workflow as the  
   path does not exist   

), it exists only in Docker container.

But the composer require --no-update "${DEPENDENCY_PACKAGE_NAME}:dev-${TMP_TRAVIS_BRANCH} as ${BRANCH_ALIAS} is not invoked in the container, it is run on the host.

Before Composer 2.0.10 it did not make a difference - most likely because --no-update is used Composer did not care that one of the repositories points to a non-existant directory.

On Composer 2.0.10 the behaviour changed - Composer validates the repositories and complains that one of them has invalid configuration.

Solutions I've considered:

Also changed the repository type - path is the correct one when Composer should use local dependencies:
https://getcomposer.org/doc/05-repositories.md#path

Companion PR to test the solution:
ezsystems/ezplatform-admin-ui#1712

@mnocon mnocon changed the title [Travis] Created the local dependency directory on host for Composer … [Travis] Created the local dependency directory on host for Composer command to pass Feb 24, 2021
@mnocon mnocon force-pushed the fix-missing-repository-dir branch 2 times, most recently from 9ce17c1 to bdd04b6 Compare February 24, 2021 10:40
@mnocon mnocon force-pushed the fix-missing-repository-dir branch from bdd04b6 to 6b0628b Compare February 24, 2021 11:07
@mnocon mnocon marked this pull request as ready for review February 24, 2021 11:43
@micszo micszo merged commit 203ecc7 into 2.5 Feb 24, 2021
@micszo micszo deleted the fix-missing-repository-dir branch February 24, 2021 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants