Skip to content

Commit

Permalink
[TASK] Update CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed May 7, 2024
1 parent 41a60ee commit 3aef146
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 46 deletions.
48 changes: 27 additions & 21 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
# Based on https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
# Copied from https://github.com/spatie/package-skeleton-laravel/blob/main/.github/workflows/dependabot-auto-merge.yml
# 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
name: dependabot-auto-merge
on:
pull_request_target:
types: [opened, reopened]

# We're using pull_request_target instead of pull_request due to permission issues with the pull_request target:
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
name: "Dependabot auto-merge"
runs-on: ubuntu-latest
timeout-minutes: 5

if: ${{ github.actor == 'dependabot[bot]' }}

steps:
- name: "Dependabot metadata"
id: dependabot-metadata
# 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
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: "Output updated dependencies (JSON)"
run: echo steps.dependabot-metadata.outputs.updated-dependencies-json
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Auto-merge Dependabot PRs for semver-minor updates"
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# does not work, see https://github.com/dependabot/fetch-metadata/issues/499
# - name: "Auto-merge Dependabot PRs for semver-minor updates"
# if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }}
# run: gh pr merge --auto --rebase "$PR_URL"
# env:
# PR_URL: "${{ github.event.pull_request.html_url }}"
# github-token: "${{ secrets.GITHUB_TOKEN }}"
#
# - name: "Auto-merge Dependabot PRs for semver-patch updates"
# if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
# run: gh pr merge --auto --rebase "$PR_URL"
# env:
# PR_URL: "${{ github.event.pull_request.html_url }}"
# github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: "Auto-merge Dependabot PRs for semver-patch updates"
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --squash "$PR_URL"
- name: "Enable auto-merge"
if: ${{ steps.metadata.outputs.dependency-type == 'direct:development' }}
run: gh pr merge -R "${{ github.repository }}" --squash --auto "${{ github.event.pull_request.number }}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/rector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: ramsey/composer-install@v3

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

- name: "Run PHP CS Fixer"
run: vendor/bin/php-cs-fixer fix --ansi
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.idea/
/.phpunit.cache/
/build/
/build/*
!/build/rector/
/vendor/
/.php-cs-fixer.cache
/composer.lock
Expand Down
47 changes: 26 additions & 21 deletions rector.php → build/rector/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,40 @@
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Property\AddPropertyTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
use Rector\ValueObject\PhpVersion;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
//->withPhpSets()
->withSets([
return static function (RectorConfig $rectorConfig) {
$rectorConfig->paths([
__DIR__ . '/../../src',
__DIR__ . '/../../tests',
]);
$rectorConfig->phpVersion(PhpVersion::PHP_74);
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
])
->withRules([
AddVoidReturnTypeWhereNoReturnRector::class,
TypedPropertyFromAssignsRector::class,
TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictSetUpRector::class,
]);
$rectorConfig->rules([
// Privatization
PrivatizeFinalClassMethodRector::class,
DeclareStrictTypesRector::class,
ReturnTypeFromStrictTypedPropertyRector::class,

// TypeDeclaration
AddMethodCallBasedStrictParamTypeRector::class,
AddParamTypeFromPropertyTypeRector::class,
AddVoidReturnTypeWhereNoReturnRector::class,
ReturnTypeFromStrictNativeCallRector::class,
ReturnTypeFromStrictScalarReturnExprRector::class,
])
//->withConfiguredRule(AddPropertyTypeDeclarationRector::class, [])
->withConfiguredRule(AddParamTypeDeclarationRector::class, [])
->withImportNames(true, true, false);
ReturnTypeFromStrictTypedPropertyRector::class,

TypedPropertyFromAssignsRector::class,
TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictSetUpRector::class,

DeclareStrictTypesRector::class,
]);
$rectorConfig->ruleWithConfiguration(AddParamTypeDeclarationRector::class, []);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
};
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"scripts": {
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
"ci:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix -v --dry-run --diff",
"ci:php:rector": "vendor/bin/rector process --dry-run",
"ci:php:stan": "vendor/bin/phpstan analyse --no-progress",
"ci:rector": "vendor/bin/rector process --dry-run",
"ci:tests:acceptance": "vendor/bin/behat --no-colors --no-snippets --format junit --out reports",
"ci:tests:unit": "vendor/bin/phpunit --no-coverage --colors=never",
"fix:composer:normalize": "@composer normalize --no-check-lock",
"fix:php:php-cs-fixer": "vendor/bin/php-cs-fixer fix",
"fix:rector": "vendor/bin/rector process",
"fix:php:rector": "vendor/bin/rector process",
"local:clean": "rm -Rf build",
"local:tests:acceptance": "vendor/bin/behat --colors --no-snippets",
"local:tests:unit": "vendor/bin/phpunit --no-coverage",
Expand Down

0 comments on commit 3aef146

Please sign in to comment.