Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENSITECH-74 #13

Merged
merged 6 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git_hooks/post-checkout/01-install-dependencies.sh
1 change: 1 addition & 0 deletions .git_hooks/post-merge/01-install-dependencies.sh
17 changes: 0 additions & 17 deletions .git_hooks/post-merge/install-dependecies.sh

This file was deleted.

1 change: 1 addition & 0 deletions .git_hooks/pre-commit/01-lint-php.sh
1 change: 1 addition & 0 deletions .git_hooks/pre-commit/02-php-cs-fixer.sh
1 change: 1 addition & 0 deletions .git_hooks/pre-push/01-composer-validate.sh
1 change: 1 addition & 0 deletions .git_hooks/pre-push/02-phpstan.sh
1 change: 1 addition & 0 deletions .git_hooks/pre-push/03-test-code.sh
21 changes: 0 additions & 21 deletions .git_hooks/pre-push/var-dump-checker.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

# validate composer
# Validate composer.json before commit

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"0;31m"
COL_GREEN=$ESC_SEQ"0;32m"
COL_YELLOW=$ESC_SEQ"0;33m"

echo
echo
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"composer-validate\""

VALID=$(composer validate --strict --no-check-publish --no-check-all | grep "is valid")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# - 'composer update' if changed composer.json

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"0;31m"
Expand All @@ -9,9 +11,8 @@ COL_YELLOW=$ESC_SEQ"0;33m"
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"

check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
echo "$changed_files" | grep -q "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
}

check_run composer.lock "composer install"
check_run package-lock.json "npm install"

check_run composer.json "composer update"
exit 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# Lint all added php-files via 'php -l'

ROOT_DIR="$(pwd)/"
LIST=$(git diff-index --cached --name-only --diff-filter=ACMR HEAD)
ERRORS_BUFFER=""
Expand Down Expand Up @@ -31,13 +33,13 @@ do
fi
done
if [ "$ERRORS_BUFFER" != "" ]; then
echo
echo
echo "These errors were found in try-to-commit files: "
echo -e $ERRORS_BUFFER
echo
echo
printf "$COL_RED%s$COL_RESET\r\n\r\n" "Can't commit, fix errors first."
exit 1
else
echo "Okay"
exit 0
fi
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# Check code style via '.php-cs-fixer.php'

EXECUTABLE_NAME=php-cs-fixer
EXECUTABLE_COMMAND=fix
CONFIG_FILE=.php-cs-fixer.php
Expand Down
20 changes: 20 additions & 0 deletions .git_hooks/scripts/phpstan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Run composer phpstan

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"0;31m"
COL_GREEN=$ESC_SEQ"0;32m"
COL_YELLOW=$ESC_SEQ"0;33m"

echo
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"phpstan\""

if composer phpstan; then
echo "Okay"
exit 0
else
printf "$COL_RED%s$COL_RESET\r\n" "phpstan analysis failed."
exit 1
fi
20 changes: 20 additions & 0 deletions .git_hooks/scripts/test-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Run composer test

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"0;31m"
COL_GREEN=$ESC_SEQ"0;32m"
COL_YELLOW=$ESC_SEQ"0;33m"

echo
printf "$COL_YELLOW%s$COL_RESET\n" "Running pre-push hook: \"test-code\""

if composer test; then
echo "Okay"
exit 0
else
printf "$COL_RED%s$COL_RESET\r\n" "Tests failed."
exit 1
fi
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ If the project maintainer has any additional requirements, you will find them li

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Use hooks!** - You can make use of .git hooks if you install them using `npm i`

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ jobs:
matrix:
php: [8.1, 8.2, 8.3]
laravel: [9.*, 10.*, 11.*]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 11.*
php: 8.1
Expand All @@ -45,7 +38,14 @@ jobs:
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --prefer-stable --prefer-dist --no-interaction

- name: Composer Validate
run: ./.git_hooks/scripts/composer-validate.sh

- name: Execute tests
run: vendor/bin/phpunit
run: composer test-ci

- name: Execute phpstan
run: ./.git_hooks/scripts/phpstan.sh
89 changes: 84 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,85 @@
.idea
vendor
composer.lock
studio.json
.phpunit.*
# Project #
########################
.php_cs.cache
.php-cs-fixer.cache
.huskyrc
clients/*
!clients/.gitkeep
storage/ensi
generated
studio.json
build
/node_modules
/vendor
.phpunit.result.cache
composer.lock
composer.local.json
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

# IDEs #
###################
*.sublime-project
*.sublime-workspace
/.idea
/.vscode
*.komodoproject
.vscode

# Static content #
###################
*.csv
*.pdf
*.doc
*.docx
*.xls
*.xlsx
*.xml
!phpunit.xml
!psalm.xml
*.yml
*.txt
*.wav
*.mp3
*.avi

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.box

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.tgz
*.iso
*.jar
*.rar
*.tar
*.zip
*.phar

# OS generated files #
######################
.DS_Store
.DS_Store?
.nfs*
._*
.Spotlight-V100
.Trashes
.vagrant
ehthumbs.db
Thumbs.db
sftp-config.json
auth.json
4 changes: 3 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'concat_space' => ['spacing' => 'one'],
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
Expand All @@ -36,6 +39,5 @@
'single_trait_insert_per_statement' => true,
'no_whitespace_in_blank_line' => true,
'method_chaining_indentation' => true,

])
->setFinder($finder);
Loading
Loading