Skip to content

Commit f91bbdb

Browse files
authored
chore/code style (#9)
* add cs * add things for pcov * add new targets * update dockerfile * cs fixes * fix cs
1 parent 7849a30 commit f91bbdb

19 files changed

+182
-19
lines changed

.circleci/config.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2.1
2+
3+
orbs:
4+
ci-caching: jobcloud/ci-caching@3.0
5+
ci-php: jobcloud/ci-php@2.0
6+
7+
workflows:
8+
test-avsc-json-converter:
9+
jobs:
10+
- ci-caching/build-docker-images:
11+
dockerComposeFile: "./docker/docker-compose.yml"
12+
- ci-php/install-dependencies:
13+
dockerComposeFile: "./docker/docker-compose.yml"
14+
dependencyCheckSumFile: "./composer.json"
15+
requires:
16+
- ci-caching/build-docker-images
17+
- ci-php/code-style:
18+
dockerComposeFile: "./docker/docker-compose.yml"
19+
dependencyCheckSumFile: "./composer.json"
20+
requires:
21+
- ci-php/install-dependencies

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [nick-zh]

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY: clean code-style pcov-enable pcov-disable
2+
.DEFAULT_GOAL := code-style
3+
4+
PHPCS = ./vendor/bin/phpcs --extensions=php
5+
6+
clean:
7+
rm -rf ./build ./vendor
8+
9+
code-style: pcov-disable
10+
mkdir -p build/logs/phpcs
11+
${PHPCS}
12+
13+
update-dependencies:
14+
composer update
15+
16+
install-dependencies:
17+
composer install
18+
19+
install-dependencies-lowest:
20+
composer install --prefer-lowest
21+
22+
pcov-enable:
23+
sudo php-ext-enable pcov
24+
25+
pcov-disable:
26+
sudo php-ext-disable pcov
27+
28+
help:
29+
# Usage:
30+
# make <target> [OPTION=value]
31+
#
32+
# Targets:
33+
# clean Cleans the coverage and the vendor directory
34+
# code-style Check codestyle using phpcs
35+
# help You're looking at it!
36+
# pcov-enable Enable pcov
37+
# pcov-disable Disable pcov

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"symfony/console": "^5.3",
3131
"pimple/pimple": "^3.5"
3232
},
33+
"require-dev": {
34+
"squizlabs/php_codesniffer": "^3.6"
35+
},
3336
"bin": [
3437
"bin/avsc-to-json"
3538
],

docker/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
COMPOSE_PROJECT_NAME=avsc-json-converter

docker/dev/php/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM php:7.4-cli-alpine3.14
2+
3+
ARG HOST_USER_ID
4+
ARG HOST_USER
5+
6+
# PHP: Copy configuration files & remove dist files
7+
RUN mkdir /phpIni
8+
COPY files/bin/ /usr/local/bin/
9+
COPY files/php/ /phpIni
10+
11+
# Install required packages
12+
RUN apk --no-cache upgrade && \
13+
apk --no-cache add bash git sudo autoconf gcc g++ make
14+
15+
RUN adduser -u $HOST_USER_ID -D -H $HOST_USER && \
16+
echo "ALL ALL=NOPASSWD: ALL" >> /etc/sudoers && \
17+
addgroup $HOST_USER www-data
18+
19+
# COMPOSER: install binary
20+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
21+
22+
# PHP: Install php extensions
23+
RUN pecl channel-update pecl.php.net && \
24+
pecl install pcov && \
25+
php-ext-enable pcov
26+
27+
USER $HOST_USER
28+
29+
WORKDIR /var/www/html
30+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
if [ $# -eq 0 ]
3+
then
4+
echo "Please pass a php module name"
5+
exit
6+
fi
7+
8+
for phpmod in "$@"
9+
do
10+
rm -f /usr/local/etc/php/conf.d/*$phpmod*.ini
11+
done
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [[ ${#} -eq 0 ]] ; then
4+
echo -e "\\nPHP module name required!\\n"
5+
exit 1
6+
fi
7+
8+
for phpmod in "${@}" ; do
9+
10+
files=($(find /phpIni -type f -iname "*${phpmod}*.ini" -exec ls -1 '{}' +))
11+
12+
for i in "${files[@]}" ; do
13+
ln -s "${i}" /usr/local/etc/php/conf.d
14+
done
15+
16+
if [[ ${#files[@]} -eq 0 ]] ; then
17+
docker-php-ext-enable "${phpmod}"
18+
fi
19+
20+
done

docker/dev/php/files/php/20-pcov.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extension=pcov.so

docker/docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3.2'
2+
services:
3+
php:
4+
build:
5+
context: ./dev/php
6+
args:
7+
HOST_USER: ${USER}
8+
HOST_USER_ID: ${USER_ID}
9+
container_name: avsc-json-converter
10+
hostname: avsc-json-converter
11+
tty: true
12+
volumes:
13+
- ../:/var/www/html

0 commit comments

Comments
 (0)