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

Move phpcs from Travis to GitHub Actions #3979

Merged
merged 5 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,66 @@ on:

jobs:
static-analysis-psalm:
name: Static Analysis with Psalm
runs-on: ubuntu-latest
name: "Static Analysis with Psalm"
Copy link
Member

Choose a reason for hiding this comment

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

Are changes like this really needed? I'd rather keep it simple and only add quotes where required (e.g. strings with special characters, numeric strings that must remain strings, etc.).

This file will be maintained by humans who will not see the need to add quotes everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is trying to maintain consistency across repos
https://github.com/doctrine/orm/pull/8116/files

Copy link
Member

Choose a reason for hiding this comment

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

So what's the reason why we want to have all strings quoted in all repositories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just coding style, and that repo enforces it:
https://github.com/ergebnis/php-library-template/blob/master/.yamllint.yaml

I personally don't like everything quoted, as you point out it's not necessary all the time. but being consistent is the main thing i guess.

cc @localheinz

Choose a reason for hiding this comment

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

@morozov

I am using ibiqlik/action-yamllint to lint YAML files using yamllint, and for consistency, I quote YAML strings.

As @bendavies pointed out, it's a matter of taste and consistency. I have to admit that I dislike having to escape a bunch of characters when quoting.

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.4"

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: "Checkout code"
uses: "actions/checkout@v2"

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

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "composer-${{ hashFiles('composer.lock') }}"
restore-keys: "composer-"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
Copy link
Member

Choose a reason for hiding this comment

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

This looks like an unnecessary complication. What's the scenario where we're going to run the code style check using different PHP versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has already been discussed. It is trying to maintain consistency across repos
https://github.com/doctrine/orm/pull/8116/files

Copy link
Member

Choose a reason for hiding this comment

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

Could you point me to the thread, please? I could find the discussion regarding the build matrix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@bendavies bendavies May 6, 2020

Choose a reason for hiding this comment

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

sorry, let me elaborate, because that link doesn't help you.

I think, even if the matrix has a single php version, it enables us to use the same key everywhere, which helps cache hits. rather than using

key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"

where a matrix is used and

key: "php-7.4-composer-locked-${{ hashFiles('composer.lock') }}"

where a matrix is not used.

Copy link
Member

Choose a reason for hiding this comment

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

So, by “everywhere” you mean that if named consistently, the same cache entry can be shared between multiple actions? Makes sense in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Multiple action in the same repo yes. Thanks for phrasing it better!

restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"
bendavies marked this conversation as resolved.
Show resolved Hide resolved

- name: Psalm
- name: "Psalm"
run: "vendor/bin/psalm"

coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-latest"

strategy:
matrix:
Copy link
Member

Choose a reason for hiding this comment

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

I believe the whole point of static analysis is that it's static and doesn't depend on the runtime environment. Having a matrix here looks like overkill to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is trying to maintain consistency across repos
https://github.com/doctrine/orm/pull/8116/files

php-version:
- "7.4"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

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

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"

- name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ jobs:
env: PHPStan
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpstan analyse
- stage: Smoke Testing
php: 7.3
env: PHP_CodeSniffer
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpcs

- stage: Test
php: 7.2
Expand Down