-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from dxw/chore/add-scripts-to-rule-them-all
Chore/add scripts to rule them all
- Loading branch information
Showing
9 changed files
with
127 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/sh | ||
|
||
trap "exit 1" USR1 | ||
PROC="$$" | ||
|
||
fatal(){ | ||
echo "$@" >&2 | ||
kill -10 $PROC | ||
} | ||
|
||
# Exclude bin/ here because it contains PHP scripts. However, we check bin/ | ||
# in the block below just in case it has anything with a #!/bin/sh shebang. | ||
# Although this isn't a perfect check, the likelihood of a shell script with | ||
# the "wrong" shebang being placed in bin/ is very small. | ||
grep -rl '\(^#!\/bin\/.\+sh\)\|\(^#!\/usr\/bin\)' . --exclude=vendor.phar --exclude-dir=bin --exclude-dir=vendor --exclude-dir=node_modules --exclude-dir=local --exclude-dir=.git | while IFS= read -r file | ||
do | ||
fatal "Error in ${file}: please only use #!/bin/sh shebang" | ||
done | ||
|
||
grep -rl '^#!\/bin\/sh' . --exclude-dir=vendor --exclude-dir=node_modules --exclude-dir=local --exclude-dir=.git | while IFS= read -r file | ||
do | ||
echo "Checking ${file}" | ||
if ! shellcheck "$file"; then | ||
fatal "Shellcheck error in ${file}" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
brew "php@7.4" | ||
brew "composer" | ||
brew "shellcheck" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
# script/bootstrap: Resolve all dependencies that the application requires to | ||
# run. | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
if [ -z "$CI" ]; then | ||
if [ -f Brewfile ] && [ "$(uname -s)" = "Darwin" ]; then | ||
if ! brew bundle check >/dev/null 2>&1; then | ||
echo "==> Installing Homebrew dependencies..." | ||
brew bundle install --verbose | ||
fi | ||
fi | ||
fi | ||
|
||
if [ -f composer.json ]; then | ||
echo "==> Installing PHP dependencies using Composer..." | ||
composer install | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
# script/setup: Set up the application for the first time after cloning, or set | ||
# it back to the initial unused state. | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
if [ -f Gemfile ] && [ -d vendor ]; then | ||
echo "==> Cleaning installed PHP dependencies..." | ||
git clean -x --force -- vendor | ||
fi | ||
|
||
echo "==> Bootstrapping..." | ||
script/bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
# script/test: Run the test suite for the application. Optionally pass in a path | ||
# to an individual test file to run a single test. | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
if [ -n "$DEBUG" ]; then | ||
set -x | ||
fi | ||
|
||
echo "==> Updating..." | ||
script/update | ||
|
||
TEST_FILE=$1 | ||
|
||
if [ -n "$TEST_FILE" ]; then | ||
echo "==> Running the tests matching '$TEST_FILE'..." | ||
./vendor/bin/phpunit "$TEST_FILE" | ||
else | ||
echo "==> Running ShellCheck..." | ||
./.shellcheck.sh | ||
|
||
echo "==> Running php-cs-fixer..." | ||
./vendor/bin/php-cs-fixer fix --dry-run -v --diff | ||
|
||
echo "==> Running the tests..." | ||
./vendor/bin/phpunit | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
# script/update: Update the application to run for its current checkout. | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")/.." | ||
|
||
echo "==> Bootstrapping..." | ||
script/bootstrap |