Skip to content

Commit 64d4c61

Browse files
authored
Merge pull request #42 from ToshY/feature/dev-tools-update
Update checkers and dev tools for easier contribution
2 parents d8d49f4 + 1da3e9c commit 64d4c61

File tree

13 files changed

+309
-55
lines changed

13 files changed

+309
-55
lines changed

.docker/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM php:8.1-cli
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update && apt-get install -y \
6+
git \
7+
unzip \
8+
libicu-dev \
9+
libzip-dev \
10+
&& docker-php-ext-install zip intl \
11+
&& apt-get clean \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY --from=composer:2.4 /usr/bin/composer /usr/bin/composer
15+
16+
COPY . .

.github/workflows/phpcs.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
name: "PHP_CodeSniffer"
2-
1+
name: PHPCS
32
on:
43
push:
54
branches:
65
- master
76
pull_request:
87
branches:
98
- master
10-
paths:
11-
- '**.php'
12-
- 'phpcs.xml'
13-
- '.github/workflows/phpcs.yml'
149

1510
jobs:
1611
phpcs:
12+
name: PHP CS Fixer
1713
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
php-versions: ['8.0', '8.1']
1817
steps:
1918
- name: Checkout
2019
uses: actions/checkout@v3
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-versions }}
25+
26+
- name: Install Composer dependencies
27+
uses: ramsey/composer-install@v2
2128
with:
22-
fetch-depth: 0
29+
composer-options: '--prefer-stable'
2330

24-
- name: Run PHPCS
25-
run: make phpcs-dry-run
31+
- name: PHP CS Fixer
32+
run: php vendor/bin/php-cs-fixer fix . --allow-risky=yes --dry-run

.github/workflows/phpmd.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PHPMD
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
7+
branches:
8+
- master
9+
10+
jobs:
11+
phpmd:
12+
name: PHPMD
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
php-versions: ['8.0', '8.1']
17+
composer-dependencies: ['lowest', 'highest']
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-versions }}
26+
27+
- name: Validate composer.json and composer.lock
28+
run: composer validate
29+
30+
- name: Install Composer dependencies
31+
uses: ramsey/composer-install@v2
32+
with:
33+
composer-options: '--prefer-stable'
34+
35+
- name: PHPMD
36+
run: php vendor/bin/phpmd --strict src/ text phpmd.xml

.github/workflows/security.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Security Check
2+
3+
on:
4+
schedule:
5+
- cron: '0 3 * * *'
6+
7+
jobs:
8+
build:
9+
name: Security check
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Check for vulnerabilities
17+
uses: symfonycorp/security-checker-action@v5
18+
with:
19+
disable-exit-code: 1
20+
id: security-check
21+
22+
- name: Display vulnerabilities as JSON
23+
run: echo ${{ steps.security-check.outputs.vulns }}

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/.idea
21
/vendor/
32
composer.lock
4-
*.cache
3+
.php-cs-fixer.cache

Makefile

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

README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
</a>
55

66
# BunnyNet API client for PHP
7-
![GitHub Repo stars](https://img.shields.io/github/stars/toshy/bunnynet-php?label=Github%20stars&style=flat-square)
8-
![Packagist Downloads](https://img.shields.io/packagist/dm/toshy/bunnynet-php?label=Packagist%20downloads&style=flat-square&color=007ec6)
9-
![Packagist License](https://img.shields.io/packagist/l/toshy/bunnynet-php?label=License&style=flat-square&color=007ec6)
10-
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/toshy/bunnynet-php?label=Tag&style=flat-square)
11-
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/toshy/bunnynet-php/phpcs.yml?branch=master&label=Codesniffer&style=flat-square)
127

8+
<div align="left">
9+
<img src="https://img.shields.io/packagist/v/toshy/bunnynet-php?label=Packagist" alt="Current bundle version" />
10+
<img src="https://img.shields.io/packagist/dt/toshy/bunnynet-php?label=Downloads" alt="Packagist Total Downloads" />
11+
<img src="https://img.shields.io/packagist/php-v/toshy/bunnynet-php?label=PHP" alt="PHP version requirement" />
12+
<img src="https://img.shields.io/github/actions/workflow/status/toshy/bunnynet-php/phpcs.yml?branch=master&label=PHPCS" alt="Code style">
13+
<img src="https://img.shields.io/github/actions/workflow/status/toshy/bunnynet-php/phpmd.yml?branch=master&label=PHPMD" alt="Mess detector">
14+
<img src="https://img.shields.io/github/actions/workflow/status/toshy/bunnynet-php/security.yml?branch=master&label=Security check" alt="Security check">
15+
</div>
1316

1417
<a href="https://bunny.net?ref=pji59zr7a4">Bunny.net<a/> is content delivery platform that truly hops: providing CDN,
1518
edge storage, video streaming and image optimizers.
@@ -67,6 +70,7 @@ $bunnyPricingCalculator = new PricingCalculator();
6770
```
6871

6972
## Documentation
73+
7074
Examples for each type of request can be found in the [docs](docs) directory.
7175

7276
* [Base](docs/BaseRequest.md)
@@ -79,13 +83,39 @@ Examples for each type of request can be found in the [docs](docs) directory.
7983

8084
## Reference
8185

82-
This library was created with the hand of the available [bunny.net API docs](https://docs.bunny.net/reference/bunnynet-api-overview). <br />
86+
This library was created with the hand of the
87+
available [bunny.net API docs](https://docs.bunny.net/reference/bunnynet-api-overview). <br />
8388
Special thanks to the bunny.net support team for answering my questions regarding the API.
8489

8590
## Notes
91+
8692
* Tried to keep the naming conventions as close as possible to the original API.
8793
* Tested the majority of the endpoints myself to validate if they are working correctly. If you happen to
88-
come across a bug, just submit an issue, and I'll take a look at it.
94+
come across a bug, just submit an issue, and I'll take a look at it.
95+
96+
## Contribute
97+
98+
### Prerequisites
99+
100+
* Docker Compose
101+
* See the Docker Compose [installation guide](https://docs.docker.com/compose/install/) to get started.
102+
* Task
103+
* See the Task [installation guide](https://taskfile.dev/installation/) to get started.
104+
105+
### Up service
106+
107+
```shell
108+
task up
109+
```
110+
111+
### Run checks
112+
113+
Run `phpcs` and `phpmd` checks.
114+
115+
```shell
116+
task contribute
117+
```
89118

90119
## Licence
120+
91121
The BunnyNet PHP library is licensed under [MIT](LICENSE).

Taskfile.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
version: '3'
2+
3+
env:
4+
UID:
5+
sh: id -u
6+
GID:
7+
sh: id -g
8+
TTY: ''
9+
10+
tasks:
11+
default:
12+
cmds:
13+
- task --list
14+
15+
# App
16+
up:
17+
desc: Up service
18+
cmds:
19+
- docker compose up -d --build --remove-orphans --force-recreate
20+
21+
down:
22+
desc: Down service
23+
cmds:
24+
- docker compose down --remove-orphans
25+
26+
contribute:
27+
desc: Contribute by running dev tools
28+
cmds:
29+
- task: phpcs:dry
30+
- task: phpmd:check
31+
32+
# Composer
33+
composer:install:
34+
desc: Composer install
35+
cmds:
36+
- docker compose run --rm $TTY php composer install {{.CLI_ARGS | default "--no-cache --no-interaction --prefer-dist"}}
37+
38+
composer:autoload:
39+
desc: Composer dump autoload
40+
cmds:
41+
- docker compose run --rm $TTY php composer dump-autoload {{.CLI_ARGS | default "--no-cache --no-interaction"}}
42+
43+
composer:require:
44+
desc: Composer require package
45+
summary: |
46+
task composer:require p="my/package"
47+
vars:
48+
PACKAGE: '{{.p}}'
49+
cmds:
50+
- docker compose run --rm $TTY php composer require {{.PACKAGE}} {{.CLI_ARGS | default "--no-cache"}}
51+
52+
composer:remove:
53+
desc: Composer remove package
54+
summary: |
55+
task composer:remove p="my/package"
56+
vars:
57+
PACKAGE: '{{.p}}'
58+
cmds:
59+
- docker compose run --rm $TTY php composer remove {{.PACKAGE}} {{.CLI_ARGS | default "--no-cache"}}
60+
61+
composer:update:
62+
desc: Composer update package
63+
summary: |
64+
task composer:update p="my/package"
65+
vars:
66+
PACKAGE: '{{.p}}'
67+
cmds:
68+
- docker compose run --rm $TTY php composer update {{.PACKAGE}} {{.CLI_ARGS | default "--no-cache"}}
69+
70+
# Tools
71+
phpcs:dry:
72+
desc: PHPCS dry run
73+
cmds:
74+
- docker compose run --rm $TTY php vendor/bin/php-cs-fixer fix . --allow-risky=yes --dry-run
75+
76+
phpcs:fix:
77+
desc: PHPCS fix
78+
cmds:
79+
- docker compose run --rm $TTY php vendor/bin/php-cs-fixer fix . --allow-risky=yes
80+
81+
phpmd:check:
82+
desc: PHPMD run
83+
cmds:
84+
- docker compose run --rm $TTY php vendor/bin/phpmd src/ text phpmd.xml
85+
86+
phpmd:check:strict:
87+
desc: PHPMD run with strict argument
88+
cmds:
89+
- docker compose run --rm $TTY php vendor/bin/phpmd --strict src/ text phpmd.xml
90+
91+
phpmd:generate:baseline:
92+
desc: PHPMD generate baseline
93+
cmds:
94+
- docker compose run --rm $TTY php vendor/bin/phpmd --generate-baseline src/ text phpmd.xml
95+
96+
rector:dry:
97+
desc: Rector dry run
98+
cmds:
99+
- docker compose run --rm $TTY php vendor/bin/rector --dry-run
100+
101+
rector:fix:
102+
desc: Rector fix
103+
cmds:
104+
- docker compose run --rm $TTY php vendor/bin/rector

composer.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@
1111
"homepage": "https://github.com/ToshY"
1212
}
1313
],
14-
"require": {
15-
"php": "^7.4|^8.0",
16-
"symfony/http-client": "^4.4|^5.0|^6.0",
17-
"ext-json": "*"
18-
},
1914
"autoload": {
2015
"psr-4": {
2116
"ToshY\\BunnyNet\\": "src/"
2217
}
18+
},
19+
"require": {
20+
"php": "^7.4|^8.0",
21+
"ext-json": "*",
22+
"symfony/http-client": "^4.4|^5.0|^6.0"
23+
},
24+
"require-dev": {
25+
"rector/rector": "^0.15.1",
26+
"phpmd/phpmd": "^2.13",
27+
"friendsofphp/php-cs-fixer": "^3.13"
2328
}
2429
}

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: '3.9'
2+
3+
services:
4+
php:
5+
build:
6+
context: .docker
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ./:/app
10+

0 commit comments

Comments
 (0)