php-actions / composer

Use the Composer CLI in your Github Actions.
177 stars 56 forks source link

the composer version cannot be defined more precisely than the "major" version #87

Closed Un1matr1x closed 2 years ago

Un1matr1x commented 2 years ago

I tried to define the composer version as described here in the readme file.

If I only define the major-version the workflow file looks like this

name: Validate

on: [push]

jobs:
  build-test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3.0.2

      - name: Validate dependencies
        uses: php-actions/composer@v6.0.0
        with:
          command: validate
          php_version: "8.0.1"
          version: 2

and the workflow passes

if I change the version to 2.2, 2.x or "2.2" they all fail.

The failed workflows can be seen below and the debug logs are also preserved in a private gist

Version | Workflow | Logs 2.2 | failed | log 2.x | failed | log "2.2" | failed | log

What am I doing wrong?

g105b commented 2 years ago

Hi, it looks like the original php-actions/composer install script uses a URL scheme that isn't supported for those version numbers, so will need updating to match the URL pattern used at getcomposer.org.

The script in question downloads the phar file:

https://github.com/php-actions/composer/blob/master/composer-action.bash#L7-L15

It seems the URL scheme should actually look like this:

I'll update this functionality in the week, unless somebody supplies a PR earlier.

Un1matr1x commented 2 years ago

Hi,

thanks for taking a look into it. Since I'm unsure how to change the bash-code in a nice way (without many ugly elseifs) I'm not going to write a patch for this.

If you change the code, you might also want to support more/all options from https://getcomposer.org/download/ ?

g105b commented 2 years ago

Good idea, I'll definitely mention this in the docs.

Un1matr1x commented 2 years ago

any updates on this topic?

g105b commented 2 years ago

Hey @Un1matr1x, sorry it's been so long but I've finally got around to this issue.

Please see https://github.com/php-actions/example-composer/runs/8196183608 for the current WIP tests. You can click through the various workflow steps that each request a different version using the version parameter, and if you open up the output of each workflow, you'll see the precise version is properly getting loaded.

I think running so many tests at once from the same IP has timed something out, so I'll look into that next, but it's looking positive so far. it just needed a few minutes to run completely :)

g105b commented 2 years ago

So, thank you @Un1matr1x - your bash skills have worked first time.

Seeing as the issue has been open for a while now, is there anything else you think would help?

If not, I will merge this in. Thank you so much for your contribution!

Un1matr1x commented 2 years ago

lgtm & I have no further ideas