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

"tools": Composer cache not working when using specific Composer version #322

Closed
2 of 5 tasks
tyrann0us opened this issue Oct 30, 2020 · 3 comments
Closed
2 of 5 tasks
Assignees
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow

Comments

@tyrann0us
Copy link

tyrann0us commented Oct 30, 2020

Describe the bug
When using the tools input to specify a specific Composer version (e.g. tools: composer:v1), Composer won't use cache as described here and here.

Version

  • I have checked releases, and the bug exists in the latest patch version of v1 or v2.
  • v2
  • v1

Runners

  • GitHub Hosted
  • Self Hosted

Operating systems
ubuntu-latest (resolves to ubuntu-18.04, still)

PHP versions
7.4

To Reproduce

name: Deploy
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: composer-cache
        run: |
          echo "::set-output name=dir::$(composer config cache-files-dir)"
      - uses: shivammathur/setup-php@v2
        with:
          tools: composer:v1
      - uses: actions/cache@v1
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-
      - run: composer validate --ansi
      - run: composer install -vv --ansi --no-dev --prefer-dist

Note that unrelated parts of the workflow files have been removed.

Expected behavior
Composer to load packages from cache on subsequent runs.

Screenshots/Logs
screenshot-github com-2020 10 30-15_26_48
Note that the screenshot only shows the very first packages, the rest is redacted.

Additional context
We need to use the tools input to force Composer v1 because GitHub Actions started to use Composer v2 by default, see actions/runner-images#1924 and actions/runner-images@215647d.

Note that we haven't checked whether this issue also occurs with Composer v2.

Cache used to worked before.

What other information do you need from me to investigate?

@tyrann0us tyrann0us added the bug Something isn't working label Oct 30, 2020
@shivammathur
Copy link
Owner

@tyrann0us Can you move the step to get the composer's cache directory after setup-php step and see if the problem is still there.

-      - id: composer-cache
-        run: |
-          echo "::set-output name=dir::$(composer config cache-files-dir)"
       - uses: shivammathur/setup-php@v2
         with:
           tools: composer:v1
+      - id: composer-cache
+        run: |
+        echo "::set-output name=dir::$(composer config cache-files-dir)"

@tyrann0us
Copy link
Author

@shivammathur, thanks for your fast response. That did the trick indeed. I should have noticed this myself; sorry for wasting your time.

@shivammathur
Copy link
Owner

Its Alright 👍

@shivammathur shivammathur added workflow-edit Issue can be fixed by editing the GitHub Action workflow and removed bug Something isn't working labels Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow
Projects
None yet
Development

No branches or pull requests

2 participants