Skip to content

Conversation

@alexislefebvre
Copy link
Contributor

@alexislefebvre alexislefebvre commented Dec 18, 2025

I’m currently testing Gitea Actions and the fastest way I found to run php-cs-fixer is to run it without dependencies. (the syntax of Gitea Actions is based on GitHub Actions so it may look familiar)

    php-cs-fixer:
        name: 🧹 PHP-CS-Fixer
        runs-on: ubuntu-latest

        steps:
            -   name: Checkout
                uses: https://github.com/actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

            -   name: ✅ PHP-CS-Fixer
                uses: docker://jakzal/phpqa:1.116.0-php8.4-alpine
                with:
                    args: php-cs-fixer --config=./.qa/.php-cs-fixer.dist.php --dry-run --diff --no-interaction --ansi --show-progress=none fix
                env:
                    CI: false

I rely on this line to skip composer install:

(test "\$GITHUB_ACTIONS" = "true" || test "\$CI" = "true") && test -f composer.json && composer install --no-scripts --no-progress --quiet

But I don’t like having to write GITHUB_ACTIONS since it’s a Gitea Actions (it may also be a GitLab CI job), and writing CI looks weird since this is still a CI job.

So I propose to add an env var to skip it with an explicit name.


Proof that php-cs-fixer works without dependencies

$ git clone git@github.com:liip/LiipTestFixturesBundle.git
$ cd LiipTestFixturesBundle/
$ docker run --rm -it --volume .:/app --workdir /app jakzal/phpqa:1.116.2-php8.4-alpine php-cs-fixer \
--config=./.qa/.php-cs-fixer.dist.php --dry-run --diff --no-interaction --ansi --show-progress=none fix
…

PHP CS Fixer 3.92.0 (7b15cb5) Exceptional Exception by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.4.15
Loaded config default from "./.qa/.php-cs-fixer.dist.php".
Running analysis on 1 core sequentially.
You can enable parallel runner and speed up the analysis! Please see usage docs for more information.
Using cache file ".php-cs-fixer.cache".

Found 0 of 64 files that can be fixed in 0.002 seconds, 11.34 MB memory used

php-cs-fixer:
stage: style
image: jakzal/phpqa:php8.2-alpine
variables:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven’t used GitLab CI for a long time but this should work: https://docs.gitlab.com/ci/variables/#define-a-cicd-variable-in-the-gitlab-ciyml-file

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

Successfully merging this pull request may close these issues.

1 participant