-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Github workflows and add a "lint" badge to README.
Github workflows will now only run on pull requests and on master. Pushes to other branches will no longer trigger the running of Github actions.
- Loading branch information
Showing
4 changed files
with
43 additions
and
4 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
name: Test | ||
|
||
on: [ push, pull_request ] | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
|
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,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
RESET_COLOR='\033[0m' | ||
HIGHLIGHT_COLOR='\033[0;35m' | ||
SUCCESS_COLOR='\033[0;32m' | ||
ERROR_COLOR='\033[0;31m' | ||
|
||
clear | ||
|
||
# linter configuration paths | ||
RUBOCOP_CONFIG=.rubocop.yml | ||
|
||
# Checking for existence of configuration files... | ||
test -e ${RUBOCOP_CONFIG} || { echo -e "${ERROR_COLOR}"ERROR: ${RUBOCOP_CONFIG} not found."${RESET_COLOR}"; exit 1; } | ||
|
||
# Running linters | ||
echo -e "${HIGHLIGHT_COLOR}"Linting Ruby on Rails using RuboCop..."${RESET_COLOR}" | ||
if [[ "$1" == "--no-fix" ]]; then | ||
bundle exec rubocop || { valid=false; } | ||
else | ||
bundle exec rubocop --autocorrect-all || { valid=false; } | ||
fi | ||
|
||
# Printing summary | ||
if [[ "$valid" == false ]]; then | ||
echo -e "${ERROR_COLOR}"ERROR: Lint errors have been found in your code."${RESET_COLOR}" | ||
exit 1 | ||
else | ||
echo -e "${SUCCESS_COLOR}"SUCCESS: All lints have completed without errors."${RESET_COLOR}" | ||
fi |