Skip to content

Commit 360a574

Browse files
chore: update CONTRIBUTING.md and add Makefile for development workflow
* Add Docker-based development commands to CONTRIBUTING.md * Create Makefile with development, testing, and Docker-related targets * Include support for customizable Ruby version and Stream Chat URL * Add convenience commands for linting, testing, and type checking
1 parent 38a649d commit 360a574

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

CONTRIBUTING.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# :recycle: Contributing
32

43
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our [Contributor License Agreement (CLA)](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) first. See our license file for more details.
@@ -63,6 +62,34 @@ Recommended settings:
6362
}
6463
```
6564

65+
For Docker-based development, you can use:
66+
67+
```shell
68+
$ make lint_with_docker # Run linters in Docker
69+
$ make lint-fix_with_docker # Fix linting issues in Docker
70+
$ make test_with_docker # Run tests in Docker
71+
$ make check_with_docker # Run both linters and tests in Docker
72+
$ make sorbet_with_docker # Run Sorbet type checker in Docker
73+
```
74+
75+
You can customize the Ruby version used in Docker by setting the RUBY_VERSION variable:
76+
77+
```shell
78+
$ RUBY_VERSION=3.1 make test_with_docker
79+
```
80+
81+
By default, the API client connects to the production Stream Chat API. You can override this by setting the STREAM_CHAT_URL environment variable:
82+
83+
```shell
84+
$ STREAM_CHAT_URL=http://localhost:3030 make test
85+
```
86+
87+
When running tests in Docker, the `test_with_docker` command automatically sets up networking to allow the Docker container to access services running on your host machine via `host.docker.internal`. This is particularly useful for connecting to a local Stream Chat server:
88+
89+
```shell
90+
$ STREAM_CHAT_URL=http://host.docker.internal:3030 make test_with_docker
91+
```
92+
6693
### Commit message convention
6794

6895
This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.

Makefile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
STREAM_KEY ?= NOT_EXIST
2+
STREAM_SECRET ?= NOT_EXIST
3+
RUBY_VERSION ?= 3.0
4+
STREAM_CHAT_URL ?= https://chat.stream-io-api.com
5+
6+
# These targets are not files
7+
.PHONY: help check test lint lint-fix test_with_docker lint_with_docker lint-fix_with_docker
8+
9+
help: ## Display this help message
10+
@echo "Please use \`make <target>\` where <target> is one of"
11+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; \
12+
{printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}'
13+
14+
lint: ## Run linters
15+
bundle exec rubocop
16+
17+
lint-fix: ## Fix linting issues
18+
bundle exec rubocop -a
19+
20+
test: ## Run tests
21+
STREAM_KEY=$(STREAM_KEY) STREAM_SECRET=$(STREAM_SECRET) bundle exec rspec
22+
23+
check: lint test ## Run linters + tests
24+
25+
console: ## Start a console with the gem loaded
26+
bundle exec rake console
27+
28+
lint_with_docker: ## Run linters in Docker (set RUBY_VERSION to change Ruby version)
29+
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rubocop"
30+
31+
lint-fix_with_docker: ## Fix linting issues in Docker (set RUBY_VERSION to change Ruby version)
32+
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rubocop -a"
33+
34+
test_with_docker: ## Run tests in Docker (set RUBY_VERSION to change Ruby version)
35+
docker run -t -i -w /code -v $(PWD):/code --add-host=host.docker.internal:host-gateway -e STREAM_KEY=$(STREAM_KEY) -e STREAM_SECRET=$(STREAM_SECRET) -e "STREAM_CHAT_URL=http://host.docker.internal:3030" ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec rspec"
36+
37+
check_with_docker: lint_with_docker test_with_docker ## Run linters + tests in Docker (set RUBY_VERSION to change Ruby version)
38+
39+
sorbet: ## Run Sorbet type checker
40+
bundle exec srb tc
41+
42+
sorbet_with_docker: ## Run Sorbet type checker in Docker (set RUBY_VERSION to change Ruby version)
43+
docker run -t -i -w /code -v $(PWD):/code ruby:$(RUBY_VERSION) sh -c "gem install bundler && bundle install && bundle exec srb tc"
44+
45+
coverage: ## Generate test coverage report
46+
COVERAGE=true bundle exec rspec
47+
@echo "Coverage report available at ./coverage/index.html"
48+
49+
reviewdog: ## Run reviewdog for CI
50+
bundle exec rubocop --format json | reviewdog -f=rubocop -name=rubocop -reporter=github-pr-review

0 commit comments

Comments
 (0)