Skip to content

Commit 6383e6d

Browse files
committed
chore: setup ci
1 parent 1516381 commit 6383e6d

9 files changed

+228
-0
lines changed

.github/workflows/ci.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Continous integration
2+
on:
3+
pull_request:
4+
push:
5+
branches-ignore:
6+
- master
7+
jobs:
8+
code_checks:
9+
name: Check code
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.1'
17+
- name: Install dependencies
18+
run: composer install
19+
- name: Test code style
20+
run: vendor/bin/ecs
21+
- name: Static analysis
22+
run: vendor/bin/phpstan
23+
# - name: Tests
24+
# run: vendor/bin/phpunit --coverage-clover coverage.xml
25+
commitlint:
26+
name: commit-lint
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0
32+
- uses: wagoid/commitlint-github-action@v5
33+
with:
34+
configFile: ../../commitlint.config.js

.github/workflows/release.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Continuous integration
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
code_checks:
8+
name: Check code
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.1'
16+
- name: Install dependencies
17+
run: composer install
18+
- name: Test code style
19+
run: vendor/bin/ecs
20+
- name: Static analysis
21+
run: vendor/bin/phpstan
22+
# - name: Tests
23+
# run: vendor/bin/phpunit --coverage-clover coverage.xml
24+
release:
25+
name: Automated release
26+
needs: [ code_checks ]
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- uses: actions/setup-node@v1
31+
with:
32+
node-version: '16.x'
33+
- run: >
34+
npx
35+
-p "@semantic-release/commit-analyzer"
36+
-p "@semantic-release/release-notes-generator"
37+
-p conventional-changelog-conventionalcommits
38+
-p semantic-release
39+
-- semantic-release
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
- name: Set up PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: '8.1'
46+
tools: phpDocumentor

.releaserc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
["@semantic-release/commit-analyzer", {
5+
"preset": "conventionalcommits"
6+
}],
7+
"@semantic-release/github",
8+
"@semantic-release/release-notes-generator"]
9+
}

captainhook.json

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"commit-msg": {
3+
"enabled": true,
4+
"actions": [
5+
{
6+
"action": "\\Ramsey\\CaptainHook\\ValidateConventionalCommit"
7+
}
8+
]
9+
},
10+
"pre-push": {
11+
"enabled": false,
12+
"actions": []
13+
},
14+
"pre-commit": {
15+
"enabled": true,
16+
"actions": [
17+
{
18+
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting",
19+
"options": [],
20+
"conditions": []
21+
},
22+
{
23+
"action": "vendor/bin/phpstan",
24+
"options": [],
25+
"conditions": []
26+
},
27+
{
28+
"action": "vendor/bin/psalm",
29+
"options": [],
30+
"conditions": []
31+
},
32+
{
33+
"action": "vendor/bin/ecs",
34+
"options": [],
35+
"conditions": []
36+
}
37+
]
38+
},
39+
"prepare-commit-msg": {
40+
"enabled": false,
41+
"actions": []
42+
},
43+
"post-commit": {
44+
"enabled": false,
45+
"actions": []
46+
},
47+
"post-merge": {
48+
"enabled": false,
49+
"actions": []
50+
},
51+
"post-checkout": {
52+
"enabled": false,
53+
"actions": []
54+
},
55+
"post-rewrite": {
56+
"enabled": false,
57+
"actions": []
58+
},
59+
"post-change": {
60+
"enabled": false,
61+
"actions": []
62+
}
63+
}

commitlint.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const Configuration = {
2+
rules: {
3+
'subject-case': [2, 'never', ['pascal-case', 'upper-case']],
4+
}
5+
};
6+
7+
module.exports = Configuration;

composer.json

+12
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,17 @@
2020
"psr/http-factory": "^1.0",
2121
"symfony/http-client-contracts": "^2.4",
2222
"psr/http-client": "^1.0"
23+
},
24+
"require-dev": {
25+
"vimeo/psalm": "^4.27",
26+
"phpstan/phpstan": "^1.8",
27+
"symplify/easy-coding-standard": "^11.1",
28+
"captainhook/plugin-composer": "^5.3",
29+
"ramsey/conventional-commits": "^1.3"
30+
},
31+
"config": {
32+
"allow-plugins": {
33+
"captainhook/plugin-composer": true
34+
}
2335
}
2436
}

ecs.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// ecs.php
6+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
7+
use Symplify\EasyCodingStandard\Config\ECSConfig;
8+
use Symplify\EasyCodingStandard\ValueObject\Option;
9+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
10+
11+
return static function (ECSConfig $ecsConfig): void {
12+
$parameters = $ecsConfig->parameters();
13+
// Parallel
14+
$parameters->set(Option::PARALLEL, true);
15+
16+
// Paths
17+
$parameters->set(Option::PATHS, [
18+
__DIR__ . '/src',
19+
// __DIR__ . '/tests',
20+
__DIR__ . '/ecs.php'
21+
22+
23+
24+
]);
25+
// A. full sets
26+
$ecsConfig->import(SetList::PSR_12);
27+
28+
29+
// B. standalone rule
30+
$services = $ecsConfig->services();
31+
$services->set(ArraySyntaxFixer::class)
32+
->call('configure', [[
33+
'syntax' => 'short',
34+
]]);
35+
$services->set(\PhpCsFixer\Fixer\Import\NoUnusedImportsFixer::class);
36+
};

phpstan.neon

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 9
3+
paths:
4+
- src
5+
# - tests
6+
treatPhpDocTypesAsCertain: false

psalm.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="8"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
>
9+
<projectFiles>
10+
<directory name="src" />
11+
<ignoreFiles>
12+
<directory name="vendor" />
13+
</ignoreFiles>
14+
</projectFiles>
15+
</psalm>

0 commit comments

Comments
 (0)