diff --git a/.nerve.rc b/.nerve.rc index 0916e70..166b249 100644 --- a/.nerve.rc +++ b/.nerve.rc @@ -1,2 +1,2 @@ export DATA_BAG_DIR=/Users/martin/Dropbox/airbnb/src/chef/data_bags -export COOKBOOK_DIR=/Users/martin/Dropbox/airbnb/src/chef/cookbooks \ No newline at end of file +export COOKBOOK_DIR=/Users/martin/Dropbox/airbnb/src/chef/cookbooks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 027f5f9..49aa91f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ repos: hooks: - id: standardrb name: StandardRB - entry: bundle exec standardrb --fix + entry: rbenv exec bundle exec standardrb --fix language: system types: [ruby] pass_filenames: true diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 1da180b..4075406 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -53,10 +53,10 @@ make fix # Auto-fix violations Install pre-commit hooks to auto-format code on commit: ```bash -pre-commit install +make hooks ``` -See `.pre-commit-config.yaml` for the list of hooks. +This uses the repo's `.venv` for pre-commit. If you already have `pre-commit` on your PATH, `pre-commit install` also works. See `.pre-commit-config.yaml` for the list of hooks. ## Running Nerve Locally diff --git a/Makefile b/Makefile index 9177251..0f27ec8 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ endif DOCKER_IMAGE := $(DOCKER_REGISTRY)nerve-dev RUBY_VERSION := 3.2 VENV := .venv +BUNDLE := rbenv exec bundle .PHONY: help help: ## Show this help @@ -27,17 +28,21 @@ setup-docker: ## Build Docker development image .PHONY: setup-local setup-local: $(VENV) ## Install dependencies locally via bundler - bundle install - $(VENV)/bin/pre-commit install + $(BUNDLE) install + $(MAKE) hooks $(VENV): ## Create Python venv for pre-commit python3 -m venv $(VENV) $(VENV)/bin/pip install pre-commit +.PHONY: hooks +hooks: $(VENV) ## Install pre-commit hooks + $(VENV)/bin/pre-commit install + .PHONY: test test: ## Run test suite - @if [ -f Gemfile.lock ] && bundle check >/dev/null 2>&1; then \ - bundle exec rspec; \ + @if [ -f Gemfile.lock ] && $(BUNDLE) check >/dev/null 2>&1; then \ + $(BUNDLE) exec rspec; \ else \ $(MAKE) test-docker; \ fi @@ -48,16 +53,16 @@ test-docker: ## Run tests in Docker container .PHONY: lint lint: ## Check code style with StandardRB - bundle exec standardrb + $(BUNDLE) exec standardrb .PHONY: fix fix: ## Auto-fix code style issues - bundle exec standardrb --fix + $(BUNDLE) exec standardrb --fix .PHONY: console console: ## Start interactive Ruby console - @if bundle check >/dev/null 2>&1; then \ - bundle exec pry -r ./lib/nerve; \ + @if $(BUNDLE) check >/dev/null 2>&1; then \ + $(BUNDLE) exec pry -r ./lib/nerve; \ else \ docker run --rm -it $(DOCKER_IMAGE) bundle exec pry -r ./lib/nerve; \ fi