Giter Site home page Giter Site logo

Comments (14)

theofidry avatar theofidry commented on May 25, 2024

As far as I can tell the example depends on cache-files-dir and the composer.lock files found, so it should work out of the box already.

Even if there is additional vendors, the downloaded files are cached in the same directory: be it from a global dependency, your project one or a composer-bin-plugin one

from composer-bin-plugin.

staabm avatar staabm commented on May 25, 2024

hmm I guess you are right, since the composer-bin-plugin does only change the working directory and composer.json but not the cache-files-dir

from composer-bin-plugin.

staabm avatar staabm commented on May 25, 2024

after a few more tests I can see that it is not enough to configure the regular caching.

e.g. for php-cs-fixer you need something like

    - name: Cache php-cs-fixer big dependency tree	
      uses: actions/cache@v1	
      with:	
        path: vendor-bin/php-cs-fixer/vendor/	
        key: ${{ runner.os }}-php-cs-fixer-${{ hashFiles('**/composer.lock') }}-${{ hashFiles('vendor-bin/php-cs-fixer/composer.json') }}	
        restore-keys: ${{ runner.os }}-php-cs-fixer-

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

why is the nested composer.json necessary if you capture the lock one?

from composer-bin-plugin.

clxmstaab avatar clxmstaab commented on May 25, 2024

because I dont have a composer.lock committed within vendor-bin/

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

oh then yes, you need at least the json then :)

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

If you think that helps I'll welcome a PR to the doc to clarify that point :)

from composer-bin-plugin.

staabm avatar staabm commented on May 25, 2024

the main point is, that we need a lot more caching then just caching the regular composer vendor/.

you also need to cache the vendor-bin/$my-tool/vendor

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

It depends by what you want to cache. Traditionally, at least that is what I was doing in Travis and GitLab CI, I cache the Composer downloaded artefacts, not the vendor itself. In this sense it doesn't matter which vendor (be it a bin one or not) it is. The hash keys also matters less: I don't need to invalidate that cache (although I still can), Composer handles that for me.

If you cache the vendor directories then it's another story entirely. But IMO it's making things more complicated than necessary

from composer-bin-plugin.

clxmstaab avatar clxmstaab commented on May 25, 2024

let me be more precise:

composer bin php-cs-fixer install --no-progress within a github actions triggers

  - Installing symfony/polyfill-php70 (v1.15.0): Downloading (100%)
  - Installing symfony/options-resolver (v3.4.38): Downloading (100%)
  - Installing symfony/finder (v3.4.38): Downloading (100%)
  - Installing symfony/polyfill-ctype (v1.15.0): Downloading (100%)
  - Installing symfony/filesystem (v3.4.38): Downloading (100%)
  - Installing symfony/event-dispatcher (v3.4.38): Downloading (100%)
  - Installing symfony/polyfill-mbstring (v1.15.0): Downloading (100%)
  - Installing psr/log (1.1.3): Downloading (100%)
  - Installing symfony/debug (v3.4.38): Downloading (100%)
  - Installing symfony/console (v3.4.38): Downloading (100%)
  - Installing php-cs-fixer/diff (v1.3.0): Downloading (100%)
  - Installing doctrine/lexer (1.0.2): Downloading (100%)
  - Installing doctrine/annotations (v1.4.0): Downloading (100%)
  - Installing composer/xdebug-handler (1.4.1): Downloading (100%)
  - Installing composer/semver (1.5.1): Downloading (100%)
  - Installing friendsofphp/php-cs-fixer (v2.16.1): Downloading (100%)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/event-dispatcher suggests installing symfony/http-kernel
symfony/console suggests installing symfony/lock
friendsofphp/php-cs-fixer suggests installing php-cs-fixer/phpunit-constraint-isidenticalstring (For IsIdenticalString constraint.)
friendsofphp/php-cs-fixer suggests installing php-cs-fixer/phpunit-constraint-xmlmatchesxsd (For XmlMatchesXsd constraint.)
Writing lock file

when only using the regular composer caching like described in https://github.com/shivammathur/setup-php#cache-composer-dependencies

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

Can you double check the value of composer config cache-files-dir? Because locally it points to $HOME/.composer/cache/files and it's the same on Travis. If it points to a directory local to the project though, it might be that the bin one is using a different directory as well

from composer-bin-plugin.

staabm avatar staabm commented on May 25, 2024

I dont thinks thats relevant, because the example from shivammathur/setup-php uses a variable for that path:

    - name: Get composer cache directory
      id: composer-cache
      run: echo "::set-output name=dir::$(composer config cache-files-dir)"

    - name: Cache dependencies
      uses: actions/cache@v1
      with:
        path: ${{ steps.composer-cache.outputs.dir }}
        key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
        restore-keys: ${{ runner.os }}-composer-

however, the value is /home/runner/.composer/cache/files in a github action

from composer-bin-plugin.

staabm avatar staabm commented on May 25, 2024

just to be sure we are on the same page.

regular project dependencies get installed into
/home/runner/.composer/cache/files
when using composer-bin-plugin with a tool called php-cs-fixer, the vendors of it will be installed into
/home/runner/work/my-github-org/my-project/vendor-bin/php-cs-fixer/vendor

from composer-bin-plugin.

theofidry avatar theofidry commented on May 25, 2024

@staabm the vendors should be installed in /home/runner/work/my-github-org/my-project/vendor-bin/php-cs-fixer/vendor but stored in /home/runner/.composer/cache/files, so unless something has been updated in-between or that the resolved version is different, the files to download should already be there.

Also just in case: I remember on Travis it needed to land on the master branch first before seeing the effects in the PR. Might be the same here

from composer-bin-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.