Skip to content
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

Replace Docker and use Bundler cache #144

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true

- name: Install latest bundler
run: |
Expand All @@ -51,6 +52,10 @@ jobs:
bundle config set without development
bundle install --jobs 4 --retry 3

- name: Wait for Kafka
run: |
bundle exec bin/wait_for_kafka

- name: Run all tests
env:
GITHUB_COVERAGE: ${{matrix.coverage}}
Expand Down
24 changes: 24 additions & 0 deletions bin/wait_for_kafka
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby

# Waits for Kafka to be ready
# Useful in CI where Kafka needs to be fully started before we run any tests

require 'karafka'

Karafka::App.setup do |config|
config.kafka[:'bootstrap.servers'] = '127.0.0.1:9092'
end

60.times do
begin
# Stop if we can connect to the cluster and get info
exit if Karafka::Admin.cluster_info
rescue Rdkafka::RdkafkaError
puts "Kafka not available, retrying..."
sleep(1)
end
end

puts 'Kafka not available!'

exit 1
30 changes: 16 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
version: '2'

services:
zookeeper:
container_name: karafka_web_21_zookeeper
image: wurstmeister/zookeeper
restart: on-failure
ports:
- '2181:2181'
container_name: karafka_web_zookeeper
image: confluentinc/cp-zookeeper:7.5.0
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 100

kafka:
container_name: karafka_web_21_kafka
image: wurstmeister/kafka
container_name: karafka_web_kafka
image: confluentinc/cp-kafka:7.5.0
depends_on:
- zookeeper
ports:
- '9092:9092'
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: on-failure
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1