Skip to content

Commit 3aef146

Browse files
committed
[TASK] Update CI scripts
1 parent 41a60ee commit 3aef146

File tree

5 files changed

+58
-46
lines changed

5 files changed

+58
-46
lines changed
+27-21
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
# Based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
1+
# Copied from https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
2+
# See https://docs.github.com/en/enterprise-cloud@latest/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
23
name: dependabot-auto-merge
3-
on:
4-
pull_request_target:
5-
types: [opened, reopened]
4+
5+
# We're using pull_request_target instead of pull_request due to permission issues with the pull_request target:
6+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
7+
on: pull_request_target
68

79
permissions:
810
pull-requests: write
911
contents: write
1012

1113
jobs:
1214
dependabot:
15+
name: "Dependabot auto-merge"
1316
runs-on: ubuntu-latest
1417
timeout-minutes: 5
18+
1519
if: ${{ github.actor == 'dependabot[bot]' }}
1620

1721
steps:
1822
- name: "Dependabot metadata"
19-
id: dependabot-metadata
23+
# https://docs.github.com/en/enterprise-cloud@latest/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#fetch-metadata-about-a-pull-request
24+
id: metadata
2025
uses: dependabot/[email protected]
2126
with:
2227
github-token: "${{ secrets.GITHUB_TOKEN }}"
2328

24-
- name: "Output updated dependencies (JSON)"
25-
run: echo steps.dependabot-metadata.outputs.updated-dependencies-json
26-
env:
27-
PR_URL: ${{ github.event.pull_request.html_url }}
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
30-
- name: "Auto-merge Dependabot PRs for semver-minor updates"
31-
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
32-
run: gh pr merge --auto --squash "$PR_URL"
33-
env:
34-
PR_URL: ${{ github.event.pull_request.html_url }}
35-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
29+
# does not work, see https://github.com/dependabot/fetch-metadata/issues/499
30+
# - name: "Auto-merge Dependabot PRs for semver-minor updates"
31+
# if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
32+
# run: gh pr merge --auto --rebase "$PR_URL"
33+
# env:
34+
# PR_URL: "${{ github.event.pull_request.html_url }}"
35+
# github-token: "${{ secrets.GITHUB_TOKEN }}"
36+
#
37+
# - name: "Auto-merge Dependabot PRs for semver-patch updates"
38+
# if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
39+
# run: gh pr merge --auto --rebase "$PR_URL"
40+
# env:
41+
# PR_URL: "${{ github.event.pull_request.html_url }}"
42+
# github-token: "${{ secrets.GITHUB_TOKEN }}"
3643

37-
- name: "Auto-merge Dependabot PRs for semver-patch updates"
38-
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
39-
run: gh pr merge --auto --squash "$PR_URL"
44+
- name: "Enable auto-merge"
45+
if: ${{ steps.metadata.outputs.dependency-type == 'direct:development' }}
46+
run: gh pr merge -R "${{ github.repository }}" --squash --auto "${{ github.event.pull_request.number }}"
4047
env:
41-
PR_URL: ${{ github.event.pull_request.html_url }}
4248
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/rector.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: ramsey/composer-install@v3
2828

2929
- name: "Run Rector"
30-
run: vendor/bin/rector --ansi
30+
run: vendor/bin/rector process --config build/rector/rector.php --ansi
3131

3232
- name: "Run PHP CS Fixer"
3333
run: vendor/bin/php-cs-fixer fix --ansi

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.idea/
22
/.phpunit.cache/
3-
/build/
3+
/build/*
4+
!/build/rector/
45
/vendor/
56
/.php-cs-fixer.cache
67
/composer.lock

rector.php build/rector/rector.php

+26-21
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,40 @@
1212
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
1313
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector;
1414
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
15-
use Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector;
1615
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
1716
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
1817
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
1918
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
19+
use Rector\ValueObject\PhpVersion;
2020

21-
return RectorConfig::configure()
22-
->withPaths([
23-
__DIR__ . '/src',
24-
__DIR__ . '/tests',
25-
])
26-
// uncomment to reach your current PHP version
27-
//->withPhpSets()
28-
->withSets([
21+
return static function (RectorConfig $rectorConfig) {
22+
$rectorConfig->paths([
23+
__DIR__ . '/../../src',
24+
__DIR__ . '/../../tests',
25+
]);
26+
$rectorConfig->phpVersion(PhpVersion::PHP_74);
27+
$rectorConfig->sets([
2928
LevelSetList::UP_TO_PHP_74,
30-
])
31-
->withRules([
32-
AddVoidReturnTypeWhereNoReturnRector::class,
33-
TypedPropertyFromAssignsRector::class,
34-
TypedPropertyFromStrictConstructorRector::class,
35-
TypedPropertyFromStrictSetUpRector::class,
29+
]);
30+
$rectorConfig->rules([
31+
// Privatization
3632
PrivatizeFinalClassMethodRector::class,
37-
DeclareStrictTypesRector::class,
38-
ReturnTypeFromStrictTypedPropertyRector::class,
33+
34+
// TypeDeclaration
3935
AddMethodCallBasedStrictParamTypeRector::class,
4036
AddParamTypeFromPropertyTypeRector::class,
37+
AddVoidReturnTypeWhereNoReturnRector::class,
4138
ReturnTypeFromStrictNativeCallRector::class,
4239
ReturnTypeFromStrictScalarReturnExprRector::class,
43-
])
44-
//->withConfiguredRule(AddPropertyTypeDeclarationRector::class, [])
45-
->withConfiguredRule(AddParamTypeDeclarationRector::class, [])
46-
->withImportNames(true, true, false);
40+
ReturnTypeFromStrictTypedPropertyRector::class,
41+
42+
TypedPropertyFromAssignsRector::class,
43+
TypedPropertyFromStrictConstructorRector::class,
44+
TypedPropertyFromStrictSetUpRector::class,
45+
46+
DeclareStrictTypesRector::class,
47+
]);
48+
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, []);
49+
$rectorConfig->importNames();
50+
$rectorConfig->importShortClasses(false);
51+
};

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252
"scripts": {
5353
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
5454
"ci:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix -v --dry-run --diff",
55+
"ci:php:rector": "vendor/bin/rector process --dry-run",
5556
"ci:php:stan": "vendor/bin/phpstan analyse --no-progress",
56-
"ci:rector": "vendor/bin/rector process --dry-run",
5757
"ci:tests:acceptance": "vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
5858
"ci:tests:unit": "vendor/bin/phpunit --no-coverage --colors=never",
5959
"fix:composer:normalize": "@composer normalize --no-check-lock",
6060
"fix:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix",
61-
"fix:rector": "vendor/bin/rector process",
61+
"fix:php:rector": "vendor/bin/rector process",
6262
"local:clean": "rm -Rf build",
6363
"local:tests:acceptance": "vendor/bin/behat --colors --no-snippets",
6464
"local:tests:unit": "vendor/bin/phpunit --no-coverage",

0 commit comments

Comments
 (0)