-
Notifications
You must be signed in to change notification settings - Fork 2
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 #466 from epimorphics/hotfix/reduce-log-noise
Feature: Improved Logging
- Loading branch information
Showing
30 changed files
with
478 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
# caveat: this script assumes all modifications to a file were staged in the commit | ||
# beware if you are in the habit of committing only partial modifications to a file: | ||
# THIS HOOK WILL ADD ALL MODIFICATIONS TO A FILE TO THE COMMIT IF ANY FILE WAS CHANGED BY LINTING | ||
|
||
list="issue spike task" | ||
|
||
listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/" | ||
|
||
BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //') | ||
|
||
printf '\n\033[0;105mChecking "%s"... \033[0m\n' "$BRANCH_NAME" | ||
|
||
if echo "$BRANCH_NAME" | grep -q '^(rebase)|(production)*$'; then | ||
printf '\n\033[0;32mNo checks necessary on "%s", pushing now... 🎉\033[0m\n' "$BRANCH_NAME" | ||
exit 0 | ||
fi | ||
|
||
RUBY_FILES="$(git diff --diff-filter=d --name-only --cached | grep -E '(Gemfile|Rakefile|\.(rb|rake|ru))$')" | ||
PRE_STATUS="$(git status | wc -l)" | ||
|
||
WORK_DONE=0 | ||
|
||
if [ -z "$RUBY_FILES" ]; then | ||
printf '\n\033[0;31mThere are currently no updated files in "%s". 🤨\033[0m\n' "$BRANCH_NAME" | ||
fi | ||
|
||
if [ -n "$RUBY_FILES" ]; then | ||
printf '\n\033[0;33mRunning Rubocop...\033[0m\n' | ||
for file in $RUBY_FILES; do | ||
git show :"$file" | bundle exec rubocop -A --stdin "$file" | ||
done | ||
RUBOCOP_EXIT_CODE=$? | ||
WORK_DONE=1 | ||
else | ||
printf '\n\033[0;32mContinuing as there are no changes to check... 🎉\033[0m\n' | ||
RUBOCOP_EXIT_CODE=0 | ||
fi | ||
|
||
POST_STATUS="$(git status | wc -l)" | ||
|
||
if [ ! $RUBOCOP_EXIT_CODE -eq 0 ]; then | ||
git reset HEAD | ||
printf '\n\033[0;31mLinting has uncorrectable errors; please fix and restage your commit. 😖\033[0m\n' | ||
exit 1 | ||
fi | ||
|
||
if [ "$PRE_STATUS" != "$POST_STATUS" ]; then | ||
git add "$RUBY_FILES" | ||
fi | ||
|
||
if [ $WORK_DONE -eq 1 ]; then | ||
printf '\n\033[0;32mLinting completed successfully! 🎉\033[0m\n' | ||
fi | ||
|
||
exit 0 |
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,57 @@ | ||
#!/bin/bash | ||
|
||
list="issue spike task" | ||
|
||
listRE="^($(printf '%s\n' "$list" | tr ' ' '|'))/" | ||
|
||
BRANCH_NAME=$(git branch --show-current | grep -E "$listRE" | sed 's/* //') | ||
|
||
printf '\n\033[0;105mChecking "%s"... \033[0m\n' "$BRANCH_NAME" | ||
|
||
if echo "$BRANCH_NAME" | grep -q '^(rebase)|(production)*$'; then | ||
printf '\n\033[0;32mNo checks necessary on "%s", pushing now... 🎉\033[0m\n' "$BRANCH_NAME" | ||
exit 0 | ||
fi | ||
|
||
# Check for existence of "new or modified" test files | ||
TEST_FILES="$(git diff --diff-filter=ACDM --name-only --cached | grep -E '(./test/*)$')" | ||
RUBY_FILES="$(git diff --diff-filter=ACDM --name-only --cached | grep -E '(_test\.rb)$')" | ||
PRE_STATUS="$(git status | wc -l)" | ||
|
||
WORK_DONE=0 | ||
|
||
if [ -z "$TEST_FILES" ]; then | ||
printf '\n\033[0;31mThere are currently no new tests found in "%s". 🤨\033[0m\n' "$BRANCH_NAME" | ||
printf '\n\033[0;31mContinuing without new tests... 😖\033[0m\n' | ||
fi | ||
|
||
|
||
if [ -n "$RUBY_FILES" ]; then | ||
printf '\nRunning Rails Tests...' | ||
bundle exec rails test | ||
RUBY_TEST_EXIT_CODE=$? | ||
WORK_DONE=1 | ||
else | ||
RUBY_TEST_EXIT_CODE=0 | ||
fi | ||
|
||
if [ -n "$RUBY_FILES" ]; then | ||
printf '\nRunning System Tests...' | ||
bundle exec rails test:system | ||
RUBY_SYSTEM_EXIT_CODE=$? | ||
WORK_DONE=1 | ||
else | ||
RUBY_SYSTEM_EXIT_CODE=0 | ||
fi | ||
|
||
|
||
if [ ! $RUBY_TEST_EXIT_CODE -eq 0 ] || [ ! $RUBY_SYSTEM_EXIT_CODE -eq 0 ]; then | ||
printf '\n\033[0;31mCannot push, tests are failing. Use --no-verify to force push. 😖\033[0m\n' | ||
exit 1 | ||
fi | ||
|
||
if [ $WORK_DONE = 1 ]; then | ||
printf '\n\033[0;32mAll tests are green, pushing... 🎉\033[0m\n' | ||
fi | ||
|
||
exit 0 |
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
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
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 |
---|---|---|
|
@@ -49,13 +49,19 @@ if (i18n.locale === 'cy') { | |
} | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
// Sentry.io logging | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/251669', | ||
debug: process.env.NODE_ENV === 'development', | ||
environment: process.env.NODE_ENV, | ||
integrations: [ | ||
new Integrations.Vue({ Vue, attachProps: true }) | ||
], | ||
release: window.ukhpi.version || '1.0.0', | ||
ignoreErrors: ['Non-Error promise rejection captured'] | ||
}) | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
// Sentry.io logging | ||
Sentry.init({ | ||
dsn: 'https://[email protected]/251669', | ||
integrations: [new Integrations.Vue({ Vue, attachProps: true })], | ||
release: window.ukhpi.version || 'unknown-version' | ||
}) | ||
Sentry.configureScope(scope => { | ||
scope.setTag('app', 'ukhpi-js') | ||
}) | ||
|
Oops, something went wrong.