Skip to content

Commit

Permalink
Merge pull request #2420 from zephir-lang/phpcs-changes
Browse files Browse the repository at this point in the history
PSR-12 and PHPCS
  • Loading branch information
Jeckerson authored Dec 4, 2023
2 parents 1838e03 + 5b8de90 commit fc61db5
Show file tree
Hide file tree
Showing 358 changed files with 58,054 additions and 19,096 deletions.
4 changes: 2 additions & 2 deletions .docker/8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
4 changes: 2 additions & 2 deletions .docker/8.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
4 changes: 2 additions & 2 deletions .docker/8.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ RUN apt update -y && apt install -y \
libicu-dev \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
pecl install psr xdebug zephir_parser

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
2 changes: 2 additions & 0 deletions .docker/8.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ RUN apt update -y && apt install -y \
libgmp-dev \
libzip-dev && \
pecl install psr zephir_parser
# pecl install psr zephir_parser xdebug

RUN docker-php-ext-install zip gmp intl mysqli && \
docker-php-ext-enable psr zephir_parser
# docker-php-ext-enable psr zephir_parser xdebug

COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Bash script with helper aliases
Expand Down
71 changes: 62 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ jobs:
phpcs --version
phpcs --runtime-set ignore_warnings_on_exit true
- name: Run PHP CS Fixer
if: always()
run: |
php-cs-fixer fix --diff --dry-run -v --using-cache=no
# Disabling for now until I figure out the rules
# - name: Run PHP CS Fixer
# if: always()
# run: |
# php-cs-fixer fix --diff --dry-run -v --using-cache=no

- name: Run Shell Check
if: always()
Expand Down Expand Up @@ -175,28 +176,80 @@ jobs:
shell: pwsh
run: |
php vendor/bin/phpunit -c phpunit.ext.xml
env:
XDEBUG_MODE: coverage

- name: Unit Tests (Zephir)
if: always()
run: php vendor/bin/phpunit --testsuite Zephir
run: php vendor/bin/phpunit --testsuite Zephir --coverage-php ./tests/output/clover.xml
env:
XDEBUG_MODE: coverage

- name: "Upload coverage file artifact"
uses: "actions/upload-artifact@v3"
with:
name: "unit-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.name }}.coverage"
path: "tests/output/clover.xml"

- name: Black-box Testing
if: always() && runner.os != 'Windows'
shell: bash
working-directory: tests/sharness
run: |
make -j$(getconf _NPROCESSORS_ONLN)
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v3
upload-coverage:
permissions:
contents: read

name: "Upload coverage"
runs-on: "ubuntu-22.04"
needs:
- "build-and-test"

steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
fetch-depth: 2

- name: 'Qodana Scan'
uses: JetBrains/[email protected]
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
with:
args: --baseline,qodana.sarif.json

- name: "Create download folder"
run: |
mkdir -p reports
- name: "Download coverage files"
uses: "actions/download-artifact@v3"
with:
path: "reports"

- name: "Display structure of downloaded files"
run: ls -R
working-directory: reports

- name: "Upload to Codecov"
uses: "codecov/codecov-action@v3"
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tests/output/clover.xml
flags: unittests,${{ runner.os }},php-${{ matrix.php }}
directory: reports
fail_ci_if_error: true
verbose: true
name: codecov-umbrella

- name: "Upload to Qodana"
run: |
docker run \
-v $(pwd):/data/project/ \
-v ./reports/:/data/coverage \
-e QODANA_TOKEN="${{ secrets.QODANA_TOKEN }}" \
jetbrains/qodana-php
- name: Upload build artifacts after Failure
if: failure()
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit48Migration:risky' => true,
'@PSR2' => true,
'@PSR12' => true,
'php_unit_no_expectation_annotation' => false,
'array_syntax' => ['syntax' => 'short'],
'fopen_flags' => false,
Expand Down
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"ext-pdo_sqlite": "*",
"ext-zip": "*",
"phpunit/phpunit": "9.5.28",
"psr/log": "1.1.*"
"psr/log": "1.1.*",
"squizlabs/php_codesniffer": "^3.7"
},
"config": {
"optimize-autoloader": true,
Expand Down Expand Up @@ -71,5 +72,19 @@
"source": "https://github.com/zephir-lang/zephir",
"irc": "irc://irc.freenode.net/zephir",
"docs": "https://docs.zephir-lang.com"
}
},
"scripts": {
"cs": "./vendor/bin/phpcs --standard=phpcs.xml.dist",
"cs-fix": "./vendor/bin/phpcbf --standard=phpcs.xml.dist",
"test": "./vendor/bin/phpunit --testsuite Zephir",
"test-coverage": "./vendor/bin/phpunit --testsuite Zephir --coverage-php ./tests/output/coverage/coverage.xml",
"test-coverage-html": "./vendor/bin/phpunit --testsuite Zephir --coverage-html ./tests/output/coverage"
},
"scripts-descriptions": {
"cs": "Run PHPCS",
"cs-fix": "Run PHPCBF",
"test": "Run all tests",
"test-coverage": "Run all tests with coverage (clover)",
"test-coverage-html": "Run all tests with coverage (HTML)"
}
}
7 changes: 4 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
<!-- Show sniff codes in all reports -->
<arg value="s"/>

<!-- Use PSR-2 as a base -->
<rule ref="PSR2"/>
<!-- Use PSR-12 as a base -->
<rule ref="PSR12"/>

<!-- Uncomment to use colors in progress or report -->
<arg name="colors" />

<!-- Show progress of the run -->
<arg value="p"/>

<rule ref="PSR2">
<rule ref="PSR12">
<exclude name="Generic.Files.LineLength.TooLong"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
<exclude name="PSR2.Classes.PropertyDeclaration.SpacingAfterType"/>
</rule>

<!--
Expand Down
Loading

0 comments on commit fc61db5

Please sign in to comment.