-
Notifications
You must be signed in to change notification settings - Fork 1
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
chore: setup local development #3
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,60 @@ | ||
# -e says exit immediately when a command fails | ||
# -o sets pipefail, meaning if it exits with a failing command, the exit code should be of the failing command | ||
# -u fails a bash script immediately if a variable is unset | ||
ENVIRONMENT := test | ||
PGHOST := localhost | ||
PGPORT := 5432 | ||
PGUSER := myuser | ||
PGPASSWORD := mypassword | ||
SHELL = /bin/bash -eu -o pipefail | ||
|
||
define is_installed | ||
if ! command -v $(1) &> /dev/null; \ | ||
then \ | ||
echo "$(1) not installed, please install it. 'brew install $(1)'"; \ | ||
exit; \ | ||
fi; | ||
endef | ||
|
||
.PHONY : help | ||
help : # Display help | ||
@awk -F ':|##' \ | ||
'/^[^\t].+?:.*?##/ {\ | ||
printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \ | ||
}' $(MAKEFILE_LIST) | ||
|
||
.PHONY : ruby_installed | ||
ruby_installed: ## check if ruby is installed | ||
@$(call is_installed,ruby) | ||
|
||
.PHONY : bundle | ||
bundle: ruby_installed ## install gems | ||
@bundle install --gemfile spec/Gemfile && cd spec/dummy && bundle install | ||
|
||
.PHONY : setup_db | ||
setup_db: ruby_installed postgres ## setup database | ||
@echo "setting up database" | ||
@cd spec/dummy && bundle exec rake db:create db:migrate --trace RAILS_ENV=${ENVIRONMENT} | ||
|
||
.PHONY : initialize_profiling | ||
initialize_profiling: ruby_installed ## initialize rspec_profiling | ||
@echo "initializing rspec_profiling" | ||
@cd spec/dummy && bundle exec rake rspec_profiling:install RAILS_ENV=${ENVIRONMENT} | ||
|
||
.PHONY : spec | ||
spec : bundle setup_db initialize_profiling ## run specs | ||
@echo "running specs" | ||
@bundle exec --gemfile=spec/dummy/Gemfile rspec | ||
|
||
.PHONY : test | ||
test: spec ## run specs | ||
@echo "running specs" | ||
|
||
.PHONY : docker_installed | ||
docker_installed: ## check if docker and docker-compose are installed | ||
@$(call is_installed,docker) | ||
@$(call is_installed,docker-compose) | ||
|
||
.PHONY : postgres | ||
postgres: docker_installed ## start postgres in docker container | ||
@docker-compose up -d || true |
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,13 @@ | ||
version: '3.9' | ||
|
||
services: | ||
postgres: | ||
image: postgres:16-alpine | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- ~/apps/postgres:/var/lib/postgresql/data | ||
environment: | ||
- POSTGRES_HOST=localhost | ||
- POSTGRES_USER=myuser | ||
- POSTGRES_PASSWORD=mypassword |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, if this is a ruby gem, why do we need postgres?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for testing of storing the profiling information if the user chooses to do so. we also test sqlite in the specs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pg
gem is not in the gemspec. It is in the spec/Gemfile for testing only. README guides user to addpg
gem if needed in their own setup. (typically in their main application Gemfile)