Skip to content

Commit b23c7c8

Browse files
committed
ci(ci): Update action references and enhance CI configurations
- Change issues-translate-action reference to dromara/issues-translate-action - Set COMPOSER_NO_SECURITY_BLOCKING environment variable in multiple CI files - Add php-cs-fixer, phpstan, and rector steps for dry-run and error format outputs - Upload phpstan analysis results in SARIF format to GitHub Signed-off-by: guanguans <[email protected]>
1 parent 0887d3c commit b23c7c8

File tree

8 files changed

+126
-7
lines changed

8 files changed

+126
-7
lines changed

.github/workflows/issues-translate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
build:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: usthe/[email protected]
14+
- uses: dromara/[email protected]
1515
with:
1616
IS_MODIFY_TITLE: true

.github/workflows/php-cs-fixer.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
push:
66
pull_request:
77

8+
env:
9+
COMPOSER_NO_SECURITY_BLOCKING: 1
10+
811
jobs:
912
php-cs-fixer:
1013
name: php-cs-fixer
@@ -37,5 +40,9 @@ jobs:
3740
- name: Run composer install
3841
run: composer install --no-interaction --ansi -v
3942

43+
- name: Run php-cs-fixer with annotate-pull-request format
44+
continue-on-error: true
45+
run: composer php-cs-fixer:fix-dry-run-format-annotate-pull-request
46+
4047
- name: Run php-cs-fixer
4148
run: composer php-cs-fixer:fix-dry-run

.github/workflows/phpstan.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ on:
55
push:
66
pull_request:
77

8+
env:
9+
COMPOSER_NO_SECURITY_BLOCKING: 1
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
815
jobs:
916
phpstan:
1017
name: phpstan
@@ -37,5 +44,19 @@ jobs:
3744
- name: Run composer install
3845
run: composer install --no-interaction --ansi -v
3946

47+
- name: Run phpstan with sarif error format
48+
continue-on-error: true
49+
run: composer phpstan:analyse-error-format-sarif
50+
51+
- name: Upload the analysis results of sarif to GitHub
52+
uses: github/codeql-action/upload-sarif@v4
53+
with:
54+
sarif_file: .build/phpstan/results.sarif
55+
wait-for-processing: true
56+
57+
- name: Run phpstan with annotate-pull-request error format
58+
continue-on-error: true
59+
run: composer phpstan:analyse-error-format-annotate-pull-request
60+
4061
- name: Run phpstan
4162
run: composer phpstan:analyse

.github/workflows/rector.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
push:
66
pull_request:
77

8+
env:
9+
COMPOSER_NO_SECURITY_BLOCKING: 1
10+
811
jobs:
912
rector:
1013
name: rector
@@ -37,5 +40,9 @@ jobs:
3740
- name: Run composer install
3841
run: composer install --no-interaction --ansi -v
3942

43+
- name: Run rector with github output format
44+
continue-on-error: true
45+
run: composer rector:process-dry-run-output-format-github
46+
4047
- name: Run rector
4148
run: composer rector:process-dry-run

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
push:
66
pull_request:
77

8+
env:
9+
COMPOSER_NO_SECURITY_BLOCKING: 1
10+
811
jobs:
912
test:
1013
runs-on: ${{ matrix.os }}

.typos.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
2+
# https://github.com/crate-ci/typos/wiki
3+
# https://github.com/GitoxideLabs/gitoxide/blob/main/_typos.toml
4+
# https://github.com/letsencrypt/boulder/blob/main/.typos.toml
5+
# https://github.com/nushell/nushell/blob/main/typos.toml
6+
[files]
7+
ignore-hidden = false
8+
extend-exclude = [
9+
".git/",
10+
"CHANGELOG.md",
11+
]
12+
13+
[default]
14+
extend-ignore-re = [
15+
# https://github.com/sirwart/ripsecrets/blob/main/src/lib.rs
16+
'\b[0-9A-Za-z+/_-]{36,}\b', # Anything base64 or base64url longer than 36 chars is probably encoded.
17+
"at_[0-9a-zA-Z-]+", # 忽略以 at_ 开头的令牌字符串
18+
"[0-9A-Z]{16}", # 忽略评分 ID
19+
]
20+
extend-ignore-identifiers-re = [
21+
"[0-9a-f]{7,}", # Git commit hash
22+
]
23+
extend-ignore-words-re = [
24+
# "Symplify",
25+
]
26+
27+
[default.extend-words]
28+
"Symplify" = "Symplify"
29+
"reguard" = "reguard"
30+
"responsable" = "responsable"
31+
"STATMENT" = "STATMENT"
32+
33+
[default.extend-identifiers]
34+
# "Symplify" = "Symplify"

composer.json

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"guanguans/php-cs-fixer-custom-fixers": "^1.2",
5757
"guanguans/rector-rules": "^1.7",
5858
"illuminate/support": "^10.49 || ^11.0 || ^12.0 || ^13.0",
59+
"jbelien/phpstan-sarif-formatter": "^1.2",
5960
"mockery/mockery": "^1.6",
6061
"nette/utils": "^4.0",
6162
"pestphp/pest": "^2.36 || ^3.0 || ^4.0",
@@ -162,6 +163,8 @@
162163
"@composer:normalize"
163164
],
164165
"actionlint": "actionlint -ignore=SC2035 -ignore=SC2086 -color -oneline -verbose",
166+
"argtyper": "@php vendor/bin/argtyper --ansi -vv",
167+
"argtyper:add-types": "@argtyper add-types .",
165168
"blade-formatter": "blade-formatter resources/views/*.blade.php resources/views/**/*.blade.php --ignore-path= --php-version=8.1 --progress",
166169
"blade-formatter:check-formatted": "@blade-formatter --check-formatted",
167170
"blade-formatter:write": "@blade-formatter --write",
@@ -176,6 +179,7 @@
176179
],
177180
"checks:optional": [
178181
"@putenv:xdebug-off",
182+
"@composer:unlink",
179183
"@class-leak:check",
180184
"@composer-dependency-analyser",
181185
"@composer:normalize-dry-run",
@@ -205,6 +209,7 @@
205209
"@php-cs-fixer:custom-fix-dry-run",
206210
"@php-cs-fixer:custom-ln-config",
207211
"@rule-doc-generator:generate",
212+
"@typos",
208213
"@zhlint"
209214
],
210215
"checks:required": [
@@ -242,6 +247,7 @@
242247
"composer:diff": "@composer diff --with-platform --ansi -vv",
243248
"composer:normalize": "@composer normalize --diff --ansi -vv",
244249
"composer:normalize-dry-run": "@composer:normalize --dry-run",
250+
"composer:unlink": "@php -r \"@unlink('vendor/bin/composer');\"",
245251
"composer:validate": "@composer validate --check-lock --strict --ansi -vv",
246252
"detect-collisions": "@php vendor/bin/detect-collisions examples/ src/",
247253
"facade:lint": "@facade:update --lint",
@@ -307,6 +313,7 @@
307313
"@putenv:xdebug-off"
308314
],
309315
"pest:coverage": "@pest --coverage-html=.build/phpunit/ --coverage-clover=.build/phpunit/clover.xml",
316+
"pest:generate-baseline": "@pest --generate-baseline=phpunit-baseline.xml",
310317
"pest:highest": [
311318
"@putenv:php",
312319
"@putenv:xdebug-on",
@@ -333,6 +340,7 @@
333340
],
334341
"php-cs-fixer:fix": "@php-cs-fixer fix --show-progress=dots --diff",
335342
"php-cs-fixer:fix-dry-run": "@php-cs-fixer:fix --dry-run",
343+
"php-cs-fixer:fix-dry-run-format-annotate-pull-request": "@php vendor/bin/php-cs-fixer --ansi -vv 'fix' '--show-progress=dots' '--diff' '--dry-run' --format=checkstyle | vendor/bin/cs2pr --notices-as-warnings --colorize",
336344
"php-cs-fixer:list-files": "@php-cs-fixer list-files",
337345
"php-cs-fixer:list-sets": "@php-cs-fixer list-sets --ansi -vv",
338346
"php-lint": [
@@ -344,6 +352,14 @@
344352
"phpmnd": "@php vendor/bin/phpmnd src/ --exclude-path=Support/helpers.phpp --ignore-numbers=2,-1 --hint --progress --ansi -vv",
345353
"phpstan": "@php vendor/bin/phpstan --ansi -vv",
346354
"phpstan:analyse": "@phpstan analyse",
355+
"phpstan:analyse-error-format-annotate-pull-request": "@php vendor/bin/phpstan --ansi -vv 'analyse' --error-format=checkstyle | vendor/bin/cs2pr --notices-as-warnings --colorize",
356+
"phpstan:analyse-error-format-checkstyle": "@phpstan:analyse --error-format=checkstyle",
357+
"phpstan:analyse-error-format-github": "@phpstan:analyse --error-format=github",
358+
"phpstan:analyse-error-format-llm": "@phpstan:analyse --error-format=llm",
359+
"phpstan:analyse-error-format-sarif": [
360+
"[ -d .build/phpstan/ ] || mkdir -p .build/phpstan/",
361+
"@php vendor/bin/phpstan --ansi -vv 'analyse' --error-format=sarif > .build/phpstan/results.sarif"
362+
],
347363
"phpstan:analyse-generate-baseline": "@phpstan:analyse --generate-baseline --allow-empty-baseline",
348364
"phpstan:analyse-split-baseline": [
349365
"@phpstan:analyse --generate-baseline=baselines/loader.neon --allow-empty-baseline",
@@ -357,6 +373,10 @@
357373
"@php vendor/bin/pint --ansi -vv"
358374
],
359375
"pint:test": "@pint --test",
376+
"pint:test-format-annotate-pull-request": [
377+
"@putenv:xdebug-off",
378+
"@php vendor/bin/pint --ansi -vv '--test' --format=checkstyle | vendor/bin/cs2pr --notices-as-warnings --colorize"
379+
],
360380
"putenv:composer-memory-unlimited": "@putenv COMPOSER_MEMORY_LIMIT=-1",
361381
"putenv:php": [
362382
"@putenv PHP74=/opt/homebrew/opt/[email protected]/bin/php",
@@ -375,14 +395,20 @@
375395
"rector": "@php vendor/bin/rector",
376396
"rector:custom-rule": "@rector custom-rule",
377397
"rector:list-rules": "@rector list-rules",
378-
"rector:process": "@rector process",
398+
"rector:process": "@rector process --ansi",
379399
"rector:process-clear-cache": "@rector:process --clear-cache",
380400
"rector:process-clear-cache-dry-run": "@rector:process-clear-cache --dry-run",
381401
"rector:process-dry-run": "@rector:process --dry-run",
402+
"rector:process-dry-run-output-format-github": "@rector:process-dry-run --output-format=github",
382403
"rector:process-only": "@rector:process-clear-cache --only=Guanguans\\SoarPHP\\Support\\Rectors\\AddHasOptionsDocCommentRector",
383404
"rector:process-only-dry-run": "@rector:process-only --dry-run",
384405
"rector:process-options": "@rector:process-clear-cache --config=rector-options.php",
385406
"rector:process-options-dry-run": "@rector:process-options --dry-run",
407+
"roave-backward-compatibility-check": [
408+
"@putenv:php",
409+
"$PHP82 vendor/bin/roave-backward-compatibility-check --install-development-dependencies --ansi -vv"
410+
],
411+
"roave-backward-compatibility-check:format-github-actions": "@roave-backward-compatibility-check --format=github-actions",
386412
"rule-doc-generator": [
387413
"@putenv:php",
388414
"$PHP82 rule-doc-generator --ansi -vv"
@@ -398,7 +424,12 @@
398424
"sk:finalize-classes-dry-run": "@sk:finalize-classes --dry-run",
399425
"sk:find-multi-classes": "@sk find-multi-classes examples/ src/",
400426
"sk:generate-symfony-config-builders": "@sk generate-symfony-config-builders --help",
401-
"sk:namespace-to-psr-4": "@sk namespace-to-psr-4 src/ --namespace-root=Guanguans\\SoarPHP\\",
427+
"sk:namespace-to-psr-4": [
428+
"@sk:namespace-to-psr-4-src",
429+
"@sk:namespace-to-psr-4-tests"
430+
],
431+
"sk:namespace-to-psr-4-src": "@sk namespace-to-psr-4 src/ --namespace-root=Guanguans\\SoarPHP\\",
432+
"sk:namespace-to-psr-4-tests": "@sk namespace-to-psr-4 tests/ --namespace-root=Guanguans\\SoarPHPTests\\",
402433
"sk:pretty-json": "@sk pretty-json .lintmdrc",
403434
"sk:pretty-json-dry-run": "@sk:pretty-json --dry-run",
404435
"sk:privatize-constants": "@sk privatize-constants examples/ src/",
@@ -448,6 +479,8 @@
448479
],
449480
"todo-lint": "! git --no-pager grep --extended-regexp --ignore-case 'todo|fixme' -- '*.php' ':!*.blade.php' ':(exclude)resources/'",
450481
"trufflehog": "trufflehog git https://github.com/guanguans/soar-php --only-verified",
482+
"typos": "typos --color=always --sort --verbose",
483+
"typos:write-changes": "@typos --write-changes",
451484
"var-dump-server:cli": "@php vendor/bin/var-dump-server --ansi -vv",
452485
"var-dump-server:html": [
453486
"@composer-config:disable-process-timeout",

phpstan.neon.dist

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ includes:
2727
# - vendor/symplify/phpstan-rules/config/rector-rules.neon
2828
# - vendor/symplify/phpstan-rules/config/symfony-rules.neon
2929

30+
services:
31+
# https://github.com/guanguans/notify/security/code-scanning
32+
# https://github.com/jbelien/phpstan-sarif-formatter
33+
errorFormatter.sarif:
34+
class: PHPStanSarifErrorFormatter\SarifErrorFormatter
35+
arguments:
36+
relativePathHelper: @simpleRelativePathHelper
37+
currentWorkingDirectory: %currentWorkingDirectory%
38+
pretty: true
39+
# errorFormatter.checkstyle:
40+
# class: NickSdot\PhpStanPhpStormErrorIdentifiers\CheckstyleErrorFormatterPhpStorm
41+
# errorFormatter.llm:
42+
# class: NickSdot\PhpStanPhpStormErrorIdentifiers\LlmErrorFormatter
43+
3044
parameters:
3145
paths:
3246
- src/
@@ -58,10 +72,10 @@ parameters:
5872
# - Rector\Contract\Rector\RectorInterface
5973
type_coverage:
6074
declare: 100
61-
param_type: 100
62-
return_type: 100
63-
constant_type: 100
64-
property_type: 100
75+
param: 100
76+
return: 100
77+
constant: 100
78+
property: 100
6579
type_perfect:
6680
narrow_param: true
6781
narrow_return: true

0 commit comments

Comments
 (0)