Skip to content

Commit

Permalink
Merge pull request #26 from sparkfabrik/update_tools
Browse files Browse the repository at this point in the history
refs #2619: update tools
  • Loading branch information
grota authored Dec 19, 2023
2 parents 33df251 + 2bfd3c2 commit ed44e0f
Show file tree
Hide file tree
Showing 15 changed files with 1,147 additions and 908 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,14 @@ jobs:

- name: Build image
run: |
docker build . --tag ${IMAGE_NAME}:${IMAGE_TAG}
make build_image CUSTOM_PHP_IMAGE=${IMAGE_NAME}:${IMAGE_TAG}
- name: Install testing deps
run: cd tests && composer install --no-interaction --prefer-dist --no-progress --ignore-platform-reqs && cd -
run: composer install --working-dir=tests --no-interaction --prefer-dist --no-progress --ignore-platform-reqs

- name: Execute phpqa
- name: Execute tests
run: |
docker run --rm -v ${PWD}/tests:/app/drupal -v ${PWD}/reports:/app/reports ${IMAGE_NAME}:${IMAGE_TAG} phpqa --analyzedDirs "drupal/web/modules" --tools "phpcpd:0,phpcs:0,phpmd:0,phpmetrics,phploc,pdepend,parallel-lint:0,phpstan:0,security-checker:0" --buildDir "/app/reports" || true
- name: diff phpcs
run: diff tests/expected_reports/checkstyle.xml reports/checkstyle.xml

- name: diff phpcpd
run: diff tests/expected_reports/phpcpd.xml reports/phpcpd.xml

- name: diff phpmd
run: diff -I '\<pmd version=.*timestamp=.*\>' tests/expected_reports/phpmd.xml reports/phpmd.xml

- name: diff phpstan
run: diff tests/expected_reports/phpstan.xml reports/phpstan.xml

- name: diff security-checker
run: diff tests/expected_reports/security-checker.html reports/security-checker.html
make tests CUSTOM_PHP_IMAGE=${IMAGE_NAME}:${IMAGE_TAG}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
Expand Down
10 changes: 8 additions & 2 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<config name="drupal_core_version" value="9"/>

<!-- Coder rules. -->
<rule ref="../vendor/drupal/coder/coder_sniffer/Drupal"/>
<rule ref="../vendor/drupal/coder/coder_sniffer/DrupalPractice"/>
<rule ref="/app/vendor/drupal/coder/coder_sniffer/Drupal"/>
<rule ref="/app/vendor/drupal/coder/coder_sniffer/DrupalPractice"/>

<!-- No need for @file comments. -->
<rule ref="Drupal.Commenting.FileComment.Missing">
Expand All @@ -22,4 +22,10 @@
<rule ref="DrupalPractice.General.ClassName.ClassPrefix">
<severity>0</severity>
</rule>

<!-- All constants defined by a module must be prefixed with the module's name. -->
<rule ref="Drupal.Semantics.ConstantName.ConstConstantStart">
<severity>0</severity>
</rule>

</ruleset>
9 changes: 7 additions & 2 deletions .phpqa.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
phpcs:
standard: Drupal
# Reference the correct custom ruleset which includes both Drupal and DrupalPractice.
standard: /app/.phpcs.xml
# Since now we also have DrupalPractice and its rules are many and all warnings, treat them as non fatal to ease projects' upgrade path.
ignoreWarnings: true

phpmd:
standard: phpmd.xml

# Php file extensions to parse.
phpqa:
report: true
verbose: true
Expand All @@ -24,3 +26,6 @@ phpcpd:
phpstan:
level: 5
standard: phpstan.neon

security-checker:
composerLock: drupal/composer.lock
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.4.0] - 2023-12-19

### Changed

- Relevant dependency upgrades:

```
- Upgrading squizlabs/php_codesniffer (3.7.1 => 3.8.0)
- Upgrading drupal/coder (8.3.15 => 8.3.22)
- Upgrading sebastian/phpcpd (5.0.2 => 6.0.3)
- Upgrading phpmetrics/phpmetrics (v2.8.1 => v2.8.2)
- Upgrading pdepend/pdepend (2.10.3 => 2.16.2)
- Upgrading phpmd/phpmd (2.12.0 => 2.15.0)
- Upgrading edgedesign/phpqa (v1.26.1 => dev-master a3038f1)
- Upgrading phpstan/phpstan (1.10.15 => 1.10.50)
- Upgrading phpstan/phpstan-deprecation-rules (1.1.3 => 1.1.4)
- Upgrading mglaman/phpstan-drupal (1.1.34 => 1.2.4)
- Upgrading vimeo/psalm (4.23.0 => 4.30.0)
```

Users might find useful to upgrade their own `mglaman/phpstan-drupal` dependency to `1.2.4` if they are not already using that version to avoid conflicts.

Upgrade of `drupal/coder` means more `phpcs` errors, most can be auto-fixed via `phpcbf --standard=Drupal`.

PHPCS tool now uses correct custom ruleset file which was previously being ignored, now `DrupalPractice` is correctly included along with our rule overrides.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ RUN apk add --no-cache \
build-base libxslt-dev libxml2-dev libgcrypt-dev git unzip wget curl libpng-dev py3-pip && \
docker-php-ext-install xml xsl gd

WORKDIR /app
COPY metrics.sh /usr/local/bin/phpqa
RUN pip install djlint --root-user-action=ignore

COPY composer* ./
RUN composer install --ignore-platform-reqs -v --no-interaction --prefer-dist --no-progress
RUN composer install --no-interaction --prefer-dist --no-progress

COPY . ./
COPY metrics.sh /usr/local/bin/phpqa

RUN pip install djlint --root-user-action=ignore
WORKDIR /app
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@ CUSTOM_PHP_IMAGE := local-drupal-qa
all: build_image tests

build_image:
docker build -t $(CUSTOM_PHP_IMAGE) .
docker build --tag $(CUSTOM_PHP_IMAGE) .

tests:
docker run --rm -v ${PWD}/tests:/app/drupal -v ${PWD}/reports:/app/reports $(CUSTOM_PHP_IMAGE) phpqa --analyzedDirs "drupal/web/modules" --tools "phpcpd:0,phpcs:0,phpmd:0,phpmetrics,phploc,pdepend,parallel-lint:0,phpstan:0,security-checker:0" --buildDir "/app/reports" || true
make check-diffs

check-diffs:
check-diffs: check-phpcs check-phpcpd check-phpmd check-phpstan check-security-checker

check-phpcs:
diff tests/expected_reports/checkstyle.xml reports/checkstyle.xml

check-phpcpd:
diff tests/expected_reports/phpcpd.xml reports/phpcpd.xml

check-phpmd:
diff -I '\<pmd version=.*timestamp=.*\>' tests/expected_reports/phpmd.xml reports/phpmd.xml

check-phpstan:
diff tests/expected_reports/phpstan.xml reports/phpstan.xml
diff tests/expected_reports/security-checker.html reports/security-checker.html

check-security-checker:
grep -q '8 packages have known vulnerabilities' reports/security-checker.html
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"require": {
"cweagans/composer-patches": "^1.6",
"drupal/coder": "^8.3",
"edgedesign/phpqa": "^1.26",
"edgedesign/phpqa": "dev-master#a3038f1e488fd11d660c47b2fd71cad2773e23b3",
"enlightn/security-checker": "^1.9",
"mglaman/phpstan-drupal": "^1.1",
"nette/neon": "^3.3",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-deprecation-rules": "^1.0",
"sebastian/phpcpd": "^5",
"vimeo/psalm": "^4.13",
"webflo/drupal-finder": "^1.2",
"jangregor/phpstan-prophecy": "^1.0"
"jangregor/phpstan-prophecy": "^1.0",
"sebastian/phpcpd": "^6"
},
"extra": {
"patches": {
Expand Down
Loading

0 comments on commit ed44e0f

Please sign in to comment.