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

Change CI to use matrix of 2.5 to 3.2 #106

Merged
merged 8 commits into from
Jan 10, 2024
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
64 changes: 57 additions & 7 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,67 @@ jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
strategy:
matrix:
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2']

services:
eventq_redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
rabbitmq:
image: rabbitmq:3.12.10
ports:
- 5672:5672
options: >-
--health-cmd "rabbitmq-diagnostics -q ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
localstack:
# changes to multi region support after this version break tests
image: localstack/localstack:0.12.16
env:
SERVICES: sqs,sns
HOSTNAME: localhost
HOSTNAME_EXTERNAL: localhost
ports:
- "8085:8080"
- "4566:4566"
options: >-
--health-cmd "curl http://localhost:4566/health?reload"
--health-interval 10s
--health-timeout 5s
--health-retries 10

steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Bundle
run: bundle install
- name: Run tests
run: |
cd script
docker-compose up -d
docker exec testrunner bash -c "cd src && bundle install && bundle exec rspec && exit"
run: "bundle exec rspec"
env:
AWS_ACCESS_KEY_ID: mock_id
AWS_SECRET_ACCESS_KEY: mock_password
AWS_REGION: eu-west-1
AWS_SQS_ENDPOINT: http://localhost:4566
AWS_SNS_ENDPOINT: http://localhost:4566
RABBITMQ_ENDPOINT: localhost
REDIS_ENDPOINT: redis://localhost:6379

- name: Code Coverage
uses: paambaati/codeclimate-action@v2.7.5
uses: paambaati/codeclimate-action@v5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ruby:3.2-alpine3.18

ENV APP_HOME /src
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME

RUN apk add --update ca-certificates bash && update-ca-certificates && rm -rf /var/cache/apk/*
RUN apk update && apk add --no-cache build-base libressl-dev

RUN set -ex \
&& apk add --no-cache --virtual .gem-builddeps \
ruby-dev build-base


COPY Gemfile $APP_HOME
COPY eventq.gemspec $APP_HOME
COPY EVENTQ_VERSION $APP_HOME

RUN bundle install --no-cache \
&& apk del .gem-builddeps
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in eventq.gemspec
gemspec


gem 'json', '~> 2'
gem 'redlock', '~> 1'

platforms :ruby do
gem 'oj', '3.6.10'
gem 'openssl', '2.1.2'
gem 'bunny'
gem 'oj', '3.12.3' # 3.13.0 breaks the specs
gem 'openssl'
gem 'rexml'
end
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

Run the setup script of eventq to build the environment. This will create the `eventq` image.

$ cd script
$ ./setup.sh
$ ./script/setup.sh

### Running the tests

Expand All @@ -347,13 +346,11 @@ You will also need to comment out the AWS_* environment variables in the `docker

Run the whole test suite:

$ cd script
$ ./test.sh
$ ./script/test.sh

You can run the specs that don't depend on an AWS account with:

$ cd script
$ ./test.sh --tag ~integration
$ ./script/test.sh --tag ~integration

## Contributing

Expand Down
34 changes: 27 additions & 7 deletions script/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,47 @@ services:
dockerfile: Dockerfile
image: eventq
container_name: testrunner
command: bash -c "./scripts/container_loop.sh"
command: bash -c "./script/container_loop.sh"
depends_on:
- redis
- rabbitmq
- localstack
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
localstack:
condition: service_healthy

volumes:
- ./container_loop.sh:/scripts/container_loop.sh
- ../:/src
- ./:/src
environment:
- AWS_ACCESS_KEY_ID=mock_id
- AWS_SECRET_ACCESS_KEY=mock_password
- AWS_REGION=eu-west-1
- AWS_SQS_ENDPOINT=http://localstack:4566
- AWS_SNS_ENDPOINT=http://localstack:4566
- RABBITMQ_ENDPOINT=rabbitmq
- REDIS_ENDPOINT=redis://redis:6379
# env_file:
# - ../.aws.env

rabbitmq:
image: rabbitmq:3.6.5
image: rabbitmq:3.12.10
container_name: rabbitmq
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 10s
timeout: 5s
retries: 10

redis:
image: redis:alpine
container_name: eventq_redis
ports:
- "6379:6379"
healthcheck:
test: redis-cli ping || exit 1
interval: 10s
timeout: 5s
retries: 10

localstack:
# changes to multi region support after this version break tests
Expand All @@ -45,3 +60,8 @@ services:
ports:
- "8085:8080"
- "4566:4566"
healthcheck:
test: if [ $$(curl -s -o /dev/null -w "%{http_code}" http://localhost:4566/health?reload) -ne 200 ]; then exit 1; fi
interval: 10s
timeout: 5s
retries: 10
5 changes: 2 additions & 3 deletions lib/eventq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'securerandom'
require 'redlock'
require 'class_kit'
Expand All @@ -22,6 +24,3 @@
require_relative 'eventq/eventq_base/signature_providers'
require_relative 'eventq/eventq_base/exceptions'
require_relative 'eventq/queue_worker'



13 changes: 0 additions & 13 deletions script/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion script/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
echo start rspec tests
docker-compose up -d

docker exec -it testrunner bash -c "cd src && bundle install && bundle exec rspec $*"
docker exec -it testrunner bash -c "bundle install && bundle exec rspec $*"
2 changes: 1 addition & 1 deletion spec/eventq_aws/integration/aws_queue_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def add_to_received_list(received_messages)
context 'NonceManager' do
context 'when a message has already been processed' do
before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
let(:queue_message) { EventQ::QueueMessage.new }
let(:event_type) { 'queue_worker_event_noncemanager' }
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_aws/integration/aws_queue_worker_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def add_to_received_list(received_messages)
context 'NonceManager' do
context 'when a message has already been processed' do
before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
let(:queue_message) { EventQ::QueueMessage.new }
let(:event_type) { "queue_worker_event_noncemanager_#{SecureRandom.hex(2)}" }
Expand Down
6 changes: 3 additions & 3 deletions spec/eventq_base/nonce_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end
context 'when a nonce has NOT been used' do
it 'should return true' do
Expand Down Expand Up @@ -77,7 +77,7 @@
let(:nonce) { SecureRandom.uuid }
context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
described_class.is_allowed?(nonce)
end
it 'should extend the expiry of the nonce key' do
Expand All @@ -102,7 +102,7 @@
let(:nonce) { SecureRandom.uuid }
context 'when NonceManager has been configured' do
before do
described_class.configure(server: 'redis://redis:6379')
described_class.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
described_class.is_allowed?(nonce)
end
it 'should extend the expiry of the nonce key' do
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_eventq_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::EventQClient do

let(:client) do
return EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
return EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

let(:subscription_manager) { EventQ::RabbitMq::SubscriptionManager.new({ client: client }) }
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_queue_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::QueueClient do

let(:client) do
return EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
return EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

let(:connection) { client.get_connection }
Expand Down
4 changes: 2 additions & 2 deletions spec/eventq_rabbitmq/rabbitmq_queue_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RSpec.describe EventQ::RabbitMq::QueueWorker do
let(:queue_worker) { EventQ::QueueWorker.new }

let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' }) }
let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') }) }

let(:connection) { client.get_connection }

Expand Down Expand Up @@ -109,7 +109,7 @@
let(:queue_message) { EventQ::QueueMessage.new }

before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end

it 'should NOT process the message more than once' do
Expand Down
4 changes: 2 additions & 2 deletions spec/eventq_rabbitmq/rabbitmq_queue_worker_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::QueueWorker do
let(:queue_worker) { EventQ::QueueWorker.new }

let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' }) }
let(:client) { EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') }) }

let(:connection) { client.get_connection }

Expand Down Expand Up @@ -92,7 +92,7 @@
let(:queue_message) { EventQ::QueueMessage.new }

before do
EventQ::NonceManager.configure(server: 'redis://redis:6379')
EventQ::NonceManager.configure(server: ENV.fetch('REDIS_ENDPOINT', 'redis://redis:6379'))
end

it 'should NOT process the message more than once' do
Expand Down
2 changes: 1 addition & 1 deletion spec/eventq_rabbitmq/rabbitmq_status_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
RSpec.describe EventQ::RabbitMq::StatusChecker do

let(:client) do
EventQ::RabbitMq::QueueClient.new({ endpoint: 'rabbitmq' })
EventQ::RabbitMq::QueueClient.new({ endpoint: ENV.fetch('RABBITMQ_ENDPOINT', 'rabbitmq') })
end

subject do
Expand Down