Skip to content

Commit 6130ab9

Browse files
authored
Added PHP code sniffer, upgraded infrastructure, enabled CI (#4)
* Added PHP code sniffer, upgraded infrastructure, enabled CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI
1 parent f1f2dd5 commit 6130ab9

File tree

24 files changed

+339
-184
lines changed

24 files changed

+339
-184
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "PHP_Composer"
2+
description: "Run PHP_Composer"
3+
4+
inputs:
5+
command:
6+
required: false
7+
default: "composer install --no-interaction --no-progress --prefer-dist"
8+
description: "Composer's installation command"
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
- name: "Get Composer cache directory"
15+
id: "php-composer-cache"
16+
shell: "bash"
17+
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
18+
19+
- name: "Cache Composer dependencies"
20+
uses: "actions/cache@v4"
21+
with:
22+
path: "${{ steps.php-composer-cache.outputs.dir }}"
23+
key: "ori-php-composer-${{ runner.os }}-${{ hashFiles('**/composer.json', '**/composer.lock') }}"
24+
restore-keys: "ori-php-composer-${{ runner.os }}-"
25+
26+
- name: "Install Composer dependencies"
27+
shell: "bash"
28+
run: "${{ inputs.command }}"

.github/workflows/ci.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "CI"
2+
3+
on:
4+
pull_request:
5+
types: [ "opened", "synchronize", "edited", "reopened" ]
6+
paths-ignore:
7+
- "docs/**"
8+
push:
9+
branches:
10+
- "**"
11+
paths-ignore:
12+
- "docs/**"
13+
schedule:
14+
- cron: "0 8 * * 1" # At 08:00 on Monday
15+
workflow_dispatch:
16+
inputs: {}
17+
18+
concurrency:
19+
group: "${{ github.workflow }}-${{ github.ref }}"
20+
cancel-in-progress: true
21+
22+
permissions:
23+
contents: "read"
24+
25+
jobs:
26+
ci-checks:
27+
name: "CI checks"
28+
runs-on: "${{ matrix.operating-system }}"
29+
30+
if: |
31+
github.event_name != 'pull_request'
32+
|| github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
33+
34+
strategy:
35+
matrix:
36+
operating-system: [ "ubuntu-latest" ]
37+
php-version: ["8.0", "8.1", "8.2", "8.3", "8.4"]
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
43+
- name: Set up PHP ${{ matrix.php-version }}
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php-version }}
47+
tools: "composer:v2"
48+
49+
- name: Verify PHP version
50+
run: php -v
51+
52+
- name: "Composer"
53+
uses: "./.github/actions/php-composer"
54+
55+
- name: Run parallel lint
56+
run: composer run lint
57+
58+
- name: Run PhpStan
59+
run: composer run phpstan
60+
61+
- name: Run tests
62+
run: composer run tests
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Dependency Review"
2+
3+
on:
4+
pull_request_target:
5+
types: [ "opened", "synchronize", "edited", "reopened" ]
6+
paths:
7+
- "*"
8+
- ".github/**"
9+
push:
10+
branches:
11+
- "**"
12+
paths:
13+
- "*"
14+
- ".github/**"
15+
16+
concurrency:
17+
group: "${{ github.workflow }}-${{ github.ref }}"
18+
cancel-in-progress: true
19+
20+
permissions:
21+
contents: "read"
22+
pull-requests: "write"
23+
24+
jobs:
25+
dependency-review:
26+
name: "Dependency Review"
27+
runs-on: "ubuntu-latest"
28+
29+
steps:
30+
- name: "Checkout"
31+
uses: "actions/checkout@v4"
32+
33+
- name: "Dependency Review"
34+
uses: "actions/dependency-review-action@v4"
35+
with:
36+
base-ref: "${{ github.event_name == 'push' && github.event.before || '' }}"
37+
head-ref: "${{ github.event_name == 'push' && github.sha || '' }}"
38+
comment-summary-in-pr: "always"
39+
fail-on-severity: "high"
40+
show-openssf-scorecard: false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.idea
2+
.composer
23
/vendor
4+
/temp
35
/composer.lock
46
/examples/log
57
/tests/log

.travis.yml

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

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
init:
2+
docker compose up -d
3+
4+
docker:
5+
docker compose exec -it php /bin/bash
6+
7+
rebuild:
8+
docker compose up -d --build
9+
10+
composer:
11+
docker compose exec -it php sh -c "composer update"
12+
13+
cs:
14+
docker compose exec -it php sh -c "composer run cs"
15+
16+
cs-fix:
17+
docker compose exec -it php sh -c "composer run cs-fix"
18+
19+
phpstan:
20+
docker compose exec -it php sh -c "composer run phpstan"
21+
22+
tests:
23+
docker compose exec -it php sh -c "composer run tests"

bin/check-cs

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

bin/check-stan

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

bin/check-tests

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

composer.json

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,61 @@
11
{
22
"name": "mesour/ip-addresses",
33
"description": "IP address normalizer and validator. For IPv4 and IPv6.",
4-
"license": ["MIT"],
5-
"keywords": ["IP address","validator","normalizer"],
6-
"authors": [{
4+
"license": [
5+
"MIT"
6+
],
7+
"keywords": [
8+
"IP address",
9+
"validator",
10+
"normalizer"
11+
],
12+
"authors": [
13+
{
714
"name": "Matouš Němec",
8-
"homepage": "http://mesour.com"
9-
}],
15+
"homepage": "https://mesour.com"
16+
}
17+
],
1018
"require": {
11-
"php": ">=8.0"
19+
"php": ">=8.0"
1220
},
1321
"require-dev": {
14-
"tracy/tracy": "~2.3.0",
15-
"phpstan/phpstan": "^1.8.5",
16-
"nette/robot-loader": "^2.4",
17-
"nette/tester": "^2.3",
18-
"php-parallel-lint/php-parallel-lint": "^1.3"
22+
"tracy/tracy": "^2.10",
23+
"phpstan/phpstan": "^2.1",
24+
"phpunit/phpunit": ">=9.0",
25+
"php-parallel-lint/php-parallel-lint": "^1.4",
26+
"squizlabs/php_codesniffer": "^3.11",
27+
"slevomat/coding-standard": "^8.16"
28+
},
29+
"scripts": {
30+
"cs": "mkdir -p temp/.php-codesniffer-cache && phpcs --standard=tools/ruleset.xml --extensions=php --tab-width=4 -sp src tests",
31+
"cs-fix": "mkdir -p temp/.php-codesniffer-cache && phpcbf --standard=tools/ruleset.xml --extensions=php --tab-width=4 -sp src tests",
32+
"lint": "parallel-lint src tests",
33+
"phpstan": "phpstan analyse -l 9 -c tools/phpstan.neon src tests",
34+
"tests": "phpunit tests --configuration tests/phpunit.xml"
1935
},
2036
"autoload": {
21-
"classmap": ["src/"]
37+
"psr-4": {
38+
"Mesour\\": "src/Mesour"
39+
}
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"MesourTests\\": "tests/MesourTests"
44+
}
45+
},
46+
"archive": {
47+
"exclude": [
48+
".github/",
49+
"tests/",
50+
"tools/",
51+
"docker-compose.yml",
52+
".gitignore",
53+
"Makefile"
54+
]
55+
},
56+
"config": {
57+
"allow-plugins": {
58+
"dealerdirect/phpcodesniffer-composer-installer": false
59+
}
2260
}
2361
}

0 commit comments

Comments
 (0)