diff --git a/.github/workflows/crystal.yml b/.github/workflows/crystal.yml new file mode 100644 index 0000000..a7afcb8 --- /dev/null +++ b/.github/workflows/crystal.yml @@ -0,0 +1,32 @@ +name: Crystal CI + +on: + - push + - pull_request + +jobs: + build: + + runs-on: ubuntu-latest + + container: + image: crystallang/crystal + + services: + redis: + image: redis/redis-stack-server + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v3 + - name: Install dependencies + run: shards install + - name: Run tests + run: crystal spec + env: + REDIS_URL: redis://redis/ diff --git a/src/connection.cr b/src/connection.cr index f40a8bc..e45577b 100644 --- a/src/connection.cr +++ b/src/connection.cr @@ -21,7 +21,7 @@ module Redis # SSL connections require specifying the `rediss://` scheme. # Password authentication uses the URI password. # DB selection uses the URI path. - def initialize(@uri = URI.parse("redis:///")) + def initialize(@uri = URI.parse(ENV.fetch("REDIS_URL", "redis:///"))) host = uri.host.presence || "localhost" port = uri.port || 6379 socket = TCPSocket.new(host, port)