jwt-auth icon indicating copy to clipboard operation
jwt-auth copied to clipboard

Internal: GHA "Fix Code Style" fails

Open mfn opened this issue 2 years ago • 5 comments

Subject of the issue

After https://github.com/PHP-Open-Source-Saver/jwt-auth/pull/141 was merged, on master https://github.com/PHP-Open-Source-Saver/jwt-auth/runs/6501560509?check_suite_focus=true was triggered and failed:

remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: error: At least 1 approving review is required by reviewers with write access. 

mfn avatar May 19 '22 06:05 mfn

Am I correct that this is caused by the branch protection of main? Wouldn't it be better to do the code style fixing directly on the pull request?

eschricker avatar Jun 01 '22 06:06 eschricker

Wouldn't it be better to do the code style fixing directly on the pull request?

Yes! I'm pretty sure I advocated for it but no idea what/when it happened anymore 😅

It would be possible to do on master with a token with appropriate permission.

Not sure if on PRs there can be other issues like PR creators not allowing push etc., would need to test this.

PS: unassigning me, seems I'm optimistic in doing stuff but not finding time currently.

mfn avatar Jun 01 '22 07:06 mfn

Am I correct that this is caused by the branch protection of the main? Wouldn't it be better to do the code style fixing directly on the pull request?

Yes, we can add this on workflow on PR closed/merged or when it opens since we don't need to wait until it goes to the main.

If I not wrong, there's are phpcs or something like that in the official PHP actions repository.

Messhias avatar Jun 01 '22 08:06 Messhias

@Messhias do you have time to check this out and change it?

eschricker avatar Jun 01 '22 08:06 eschricker

@Messhias do you have time to check this out and change it?

I don't have time right now since I'm doing the same configurations in my current company for our PHP project.

But I'll share my php.yml that's in the workflow where I believe that we can insert into this repository workflow:

name: PHP

on:
    pull_request:
        branches:
            - master
            - dev
            - 'features/**'
            - 'hotfix/**'
            - 'release/**'
            - 'fix/**'
    push:
        branches:
            - 'features/**'
            - 'fix/**'

    schedule:
        # Run Monday morning at 3 o'clock
        #       ┌───────────── minute (0 - 59)
        #       │ ┌───────────── hour (0 - 23)
        #       │ │ ┌───────────── day of the month (1 - 31)
        #       │ │ │ ┌───────────── month (1 - 12)
        #       │ │ │ │ ┌───────────── day of the week (0 - 6)
        #       │ │ │ │ │
        #       │ │ │ │ │
        #       │ │ │ │ │
        -   cron: 0 3 * * 1

jobs:
    phpstan-ci:
        runs-on: ubuntu-latest

        steps:
            -   uses: actions/checkout@v3

            -   name: Setup PHP
                uses: shivammathur/setup-php@v2
                with:
                    php-version: 8.1
                    extensions: dom, mbstring, zip
                    coverage: none
                    tools: cs2pr

            -   name: Get composer cache directory
                id: composercache
                run: echo "::set-output name=dir::$(composer config cache-files-dir)"

            -   name: Cache dependencies
                uses: actions/cache@v2
                with:
                    path: ${{ steps.composercache.outputs.dir }}
                    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
                    restore-keys: ${{ runner.os }}-composer-

            -   name: Installing Composer
                run: |
                    cp .env.ci .env
                    composer install --no-ansi --no-interaction --prefer-dist --no-progress

            -   name: PHPStan
                run: composer run phpstan:test -- --error-format=checkstyle | cs2pr

            -   name: PHP-CS-Fixer
                uses: docker://oskarstark/php-cs-fixer-ga

Of course,e it's not the whole file, I'm mentioning this specific line:

-   name: PHP-CS-Fixer
     uses: docker://oskarstark/php-cs-fixer-ga

Messhias avatar Jun 01 '22 09:06 Messhias

I propose we simply don't run it on main, arguments are laid out in https://github.com/PHP-Open-Source-Saver/jwt-auth/pull/234

mfn avatar Feb 21 '24 14:02 mfn

fixed with https://github.com/PHP-Open-Source-Saver/jwt-auth/pull/234 , yay 🎉

mfn avatar Feb 21 '24 15:02 mfn