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

Failing to install Composer does not result in a failed build step #548

Closed
2 of 5 tasks
asgrim opened this issue Dec 27, 2021 · 3 comments
Closed
2 of 5 tasks

Failing to install Composer does not result in a failed build step #548

asgrim opened this issue Dec 27, 2021 · 3 comments
Assignees
Labels
workflow-edit Issue can be fixed by editing the GitHub Action workflow

Comments

@asgrim
Copy link

asgrim commented Dec 27, 2021

Describe the bug
Due to some GitHub Actions issues today, I noticed that if Composer fails to install (✗ composer Could not setup composer is shown in the Action's step output), setup-php does not actually fail the step. Subsequently, when a future action tries to use composer, it receives an error:

Run composer update --prefer-lowest --prefer-dist --no-interaction --no-progress
/usr/local/bin/composer: line 1: syntax error near unexpected token `newline'
/usr/local/bin/composer: line 1: `<!DOCTYPE html>'
Error: Process completed with exit code 2.

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 20.04

PHP versions
Any

To Reproduce
NOTE: This configuration is normally valid, but due to GH actions being unstable currently, that makes the issue "visible"

      - name: "Install PHP"
        uses: shivammathur/setup-php@v2
        with:
          coverage: "none"
          php-version: "${{ matrix.php-version }}"
          tools: pecl, composer:v2.1
          extensions: "curl, ${{ matrix.extensions }}"

Expected behavior

When ✗ composer Could not setup composer is observed when running shivammathur/setup-php@v2, I would expect that build step (Install PHP in my case) to fail at that point.

Screenshots/Logs

Screenshot from 2021-12-27 11-17-17

The failing step ✗ composer Could not setup composer can be observed, yet the step passes and continues, despite Composer not having successfully been installed.

@asgrim asgrim added the bug Something isn't working label Dec 27, 2021
@shivammathur
Copy link
Owner

Please set fail-fast as true to make sure it exits on any errors.
This is documented in tools support section in the last point.
https://github.com/shivammathur/setup-php#wrench-tools-support

- name: Setup PHP with fail-fast
  uses: shivammathur/setup-php@v2
  with:
    php-version: '7.1'
  env:
    fail-fast: true

In the next release, this will fail by default for composer, but to fail for other tools and extensions you will still need to set fail-fast to true.

@shivammathur shivammathur added workflow-edit Issue can be fixed by editing the GitHub Action workflow and removed bug Something isn't working labels Dec 27, 2021
@asgrim
Copy link
Author

asgrim commented Dec 27, 2021

Ah, thank you, I had missed that. IMO it should be the default for any failures to fail fast, as it is odd for something to fail but not show failure. Thank you though, I'll make sure to use that always going forward.

@shivammathur
Copy link
Owner

This is done as some extensions and tools are specific to one OS and they leave graceful errors in the logs by default when they fail to set up. This makes it easier to create multi-OS workflows.

asgrim added a commit to scoutapp/scout-apm-php that referenced this issue Dec 28, 2021
asgrim added a commit to scoutapp/scout-apm-php that referenced this issue Jan 3, 2022
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