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

[Question] How to define PHP version for Github Action #181

Closed
mimmi20 opened this issue Feb 18, 2023 · 5 comments
Closed

[Question] How to define PHP version for Github Action #181

mimmi20 opened this issue Feb 18, 2023 · 5 comments

Comments

@mimmi20
Copy link

mimmi20 commented Feb 18, 2023

Summary

I am using phplint as a Github action, and the action version got updated by Renovate from version 6.1.0 to version 9.0.3.

Now the Github action uses PHP 8.0, but I need it to run on PHP 8.1.

How may I set up the required PHP version?

Expected behaviour

no error

Actual behaviour

image

@llaville
Copy link
Collaborator

Hello @mimmi20

I am using phplint as a Github action, and the action version got updated by Renovate from version 6.1.0 to version 9.0.3.

Now the Github action uses PHP 8.0, but I need it to run on PHP 8.1.

How may I set up the required PHP version?

Sorry, but it's not yet possible to choose what PHP runtime to use.
But If you just want to verify PHP 8 syntax (whatever feature version used 8.0, 8.1 or 8.2), please instead of

uses: "overtrue/phplint@9.0.3"

=> https://github.com/mimmi20/template/blob/master/.github/workflows/ci.yml#L243

use

uses: "overtrue/phplint@latest"

Digest sha256:fbd2816cea52f98ad38ff3d4ceb8e0054df84cc7c523f1031c4acc189a17dc3f

It now used the PHP 8.2 runtime !

@llaville
Copy link
Collaborator

BTW, there is an alternative to PHPLint GitHub Action, if you really want to use a specific PHP runtime.

Keep continue to setup PHP as you did at https://github.com/mimmi20/template/blob/master/.github/workflows/ci.yml#L230

And replace this step https://github.com/mimmi20/template/blob/master/.github/workflows/ci.yml#L242-L243
By a new one that will download the PHAR archive that will of course use the PHP runtime you've defined on shivammathur/setup-php

Something like :

curl -Ls https://github.com/overtrue/phplint/releases/download/9.0.3/phplint.phar -o /usr/local/bin/phplint \
&& chmod +x /usr/local/bin/phplint

@llaville
Copy link
Collaborator

My previous comment in images !!!

With PHP 8.2 runtime :

uses-setup-php-82

With PHP 8.1 runtime :

uses-setup-php-81

With PHP 8.0 runtime :

uses-setup-php-80

This is the limit to use PHAR built on release https://github.com/overtrue/phplint/releases/tag/9.0.3
Why: We use my project box-manifest to is the same as https://github.com/box-project/box v4 with a manifest (and BOX v4 min requirement is PHP 8.1)

If you want a PHAR that will run on PHP 8.0, we should compile it with BOX v3 (3.16.0)

@llaville
Copy link
Collaborator

@mimmi20 Finally, here is an operational GitHub Actions Workflow that works like a charm !!! (tested on my private repo)

On last line, you can use either a YAML config file or command options (like I did)

---
name: PHPLint

on:
  push:
  workflow_dispatch:

jobs:
  php-lint:
    name: "Linting with overtrue/phplint"

    runs-on: "${{ matrix.operating-system }}"

    strategy:
      fail-fast: false

      matrix:
        operating-system:
          - "ubuntu-20.04"
          - "ubuntu-22.04"

        php-version:
          - "8.1"
          - "8.2"

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          repository: overtrue/phplint

      - name: "Install PHP"
        uses: shivammathur/setup-php@v2
        with:
          php-version: "${{ matrix.php-version }}"
          coverage: "none"

      - name: "Lint PHP"
        run: |
          curl -Ls https://github.com/overtrue/phplint/releases/download/9.0.3/phplint.phar -o /usr/local/bin/phplint
          chmod +x /usr/local/bin/phplint
          /usr/local/bin/phplint -vvv --no-cache

@mimmi20
Copy link
Author

mimmi20 commented Feb 18, 2023

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants