Skip to content

Commit 17796b0

Browse files
authored
refactor: Move tools from tools/ to root as there are now .phar packages for all of them (#7)
1 parent 2f8af6d commit 17796b0

File tree

13 files changed

+84
-2374
lines changed

13 files changed

+84
-2374
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Release
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["Tests"]
6+
types:
7+
- completed
58
branches:
69
- master
710
- next
@@ -13,6 +16,7 @@ jobs:
1316
release:
1417
name: Release
1518
runs-on: ubuntu-latest
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1620
steps:
1721
- name: Checkout
1822
uses: actions/checkout@v2
@@ -25,7 +29,6 @@ jobs:
2529
extra_plugins: |
2630
@semantic-release/changelog
2731
@semantic-release/git
28-
2932
env:
3033
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3134
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/tests.yml

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ on:
55
pull_request:
66

77
jobs:
8-
test:
9-
name: Tests & PHPStan on PHP ${{ matrix.php }}
8+
phpunit:
9+
name: PHPUnit on PHP v${{ matrix.php }}
1010

1111
runs-on: ubuntu-latest
1212

1313
strategy:
1414
fail-fast: true
1515
matrix:
16-
php: [ 7.4, 8.0, 8.1 ]
16+
php: [8.1]
1717

1818
steps:
1919
- name: Checkout code
@@ -41,22 +41,42 @@ jobs:
4141
- name: Install dependencies
4242
run: composer install --prefer-dist --no-progress
4343

44-
- name: Execute tests
44+
- name: Execute phpunit
4545
run: composer test -- --colors=always
4646

47-
# Those should usually be a separate job, but as GitHub Actions currently does not support any form of sharing
48-
# steps or an image between them, extracting those to a separate job would mean a full blown copy-paste of this one.
49-
- name: Install dependencies
50-
run: composer install --prefer-dist --no-progress --working-dir=tools/phpstan
47+
php-cs-fixer:
48+
name: php-cs-fixer
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v2
5153

52-
- name: Run phpstan
53-
run: composer phpstan
54+
- name: Setup PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: 8.1
58+
extensions: dom, curl, libxml, mbstring, zip
59+
tools: composer:v2
60+
coverage: none
61+
62+
- name: Cache Composer packages
63+
id: composer-cache
64+
uses: actions/cache@v2
65+
with:
66+
path: vendor
67+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
68+
restore-keys: |
69+
${{ runner.os }}-php-
5470
55-
code-style:
56-
name: Code style
71+
- name: Install dependencies
72+
run: composer install --prefer-dist --no-progress
5773

58-
runs-on: ubuntu-latest
74+
- name: Execute php-cs-fixer
75+
run: composer cs-fix -- --dry-run --diff --using-cache=no
5976

77+
phpstan:
78+
name: PHPStan
79+
runs-on: ubuntu-latest
6080
steps:
6181
- name: Checkout code
6282
uses: actions/checkout@v2
@@ -65,10 +85,12 @@ jobs:
6585
uses: shivammathur/setup-php@v2
6686
with:
6787
php-version: 8.1
68-
extensions: dom, curl, libxml, mbstring, zip
6988
tools: composer:v2
7089
coverage: none
7190

91+
- name: Validate composer.json and composer.lock
92+
run: composer validate
93+
7294
- name: Cache Composer packages
7395
id: composer-cache
7496
uses: actions/cache@v2
@@ -79,7 +101,7 @@ jobs:
79101
${{ runner.os }}-php-
80102
81103
- name: Install dependencies
82-
run: composer install --prefer-dist --no-progress --working-dir=tools/php-cs-fixer
104+
run: composer install --prefer-dist --no-progress
83105

84-
- name: Run php-cs-fixer
85-
run: composer cs-fix -- --dry-run --diff --using-cache=no
106+
- name: Execute phpstan
107+
run: composer phpstan

.php-cs-fixer.dist.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
3+
require __DIR__ . '/vendor/tenantcloud/php-cs-fixer-rule-sets/src/TenantCloud/PhpCsFixer/RuleSet/TenantCloudSet.php';
4+
5+
use PhpCsFixer\Config;
6+
use PhpCsFixer\Finder;
7+
use TenantCloud\PhpCsFixer\RuleSet\TenantCloudSet;
8+
9+
$finder = Finder::create()
410
->in('src')
511
->in('tests')
612
->name('*.php')
713
->notName('_*.php')
814
->ignoreVCS(true);
915

10-
return (new PhpCsFixer\Config())
16+
return (new Config())
1117
->setFinder($finder)
1218
->setRiskyAllowed(true)
1319
->setIndent("\t")
1420
->setRules([
15-
'@TenantCloud' => true,
21+
...(new TenantCloudSet())->rules(),
1622
]);

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Commands
2+
3+
Install dependencies:
4+
`docker run -it --rm -v $PWD:/app -w /app composer install`
5+
6+
Run tests:
7+
`docker run -it --rm -v $PWD:/app -w /app php:8.1-cli vendor/bin/pest`
8+
9+
Run php-cs-fixer on self:
10+
`docker run -it --rm -v $PWD:/app -w /app composer cs-fix`
11+
12+
Run phpstan on self:
13+
`docker run -it --rm -v $PWD:/app -w /app composer phpstan`

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
### Commands
2-
Install dependencies:
3-
`docker run -it --rm -v $PWD:/app -w /app composer install`
1+
# Package name
42

5-
Run tests:
6-
`docker run -it --rm -v $PWD:/app -w /app php:8.1-cli vendor/bin/pest`
7-
8-
Run php-cs-fixer on self:
9-
`docker run -it --rm -v $PWD:/app -w /app composer cs-fix`
10-
11-
Run phpstan on self:
12-
`docker run -it --rm -v $PWD:/app -w /app composer phpstan`
3+
Description

composer.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{
22
"name": "tenantcloud/composer-package",
33
"description": "A template for composer packages",
4-
"minimum-stability": "stable",
54
"license": "MIT",
65
"require": {
7-
"php": ">=7.4"
6+
"php": ">=8.1"
87
},
98
"require-dev": {
10-
"pestphp/pest": "^1.0"
9+
"pestphp/pest": "^1.0",
10+
"php-cs-fixer/shim": "~3.8.0",
11+
"tenantcloud/php-cs-fixer-rule-sets": "~2.0.0",
12+
"phpstan/phpstan": "^1.0",
13+
"phpstan/phpstan-phpunit": "^1.0",
14+
"phpstan/phpstan-webmozart-assert": "^1.0",
15+
"phpstan/phpstan-mockery": "^1.0"
1116
},
1217
"autoload": {
1318
"psr-0": {
@@ -21,9 +26,11 @@
2126
},
2227
"scripts": {
2328
"test": "./vendor/bin/pest",
24-
"cs-fix": "./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --show-progress=dots",
25-
"phpstan": "./tools/phpstan/vendor/bin/phpstan analyse"
29+
"cs-fix": "./vendor/bin/php-cs-fixer fix -v --show-progress=dots",
30+
"phpstan": "./vendor/bin/phpstan analyse"
2631
},
32+
"minimum-stability": "stable",
33+
"prefer-stable": true,
2734
"config": {
2835
"allow-plugins": {
2936
"pestphp/pest-plugin": true

phpstan.neon

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
includes:
2-
- tools/phpstan/vendor/phpstan/phpstan/conf/bleedingEdge.neon
3-
- tools/phpstan/vendor/phpstan/phpstan-phpunit/extension.neon
4-
- tools/phpstan/vendor/phpstan/phpstan-webmozart-assert/extension.neon
5-
- tools/phpstan/vendor/phpstan/phpstan-mockery/extension.neon
2+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
3+
- vendor/phpstan/phpstan-phpunit/extension.neon
4+
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
5+
- vendor/phpstan/phpstan-mockery/extension.neon
66

77
parameters:
88
level: max

tools/php-cs-fixer/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/php-cs-fixer/composer.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)