Skip to content

Commit

Permalink
Merge pull request #31 from rzane/compose
Browse files Browse the repository at this point in the history
Use docker compose for test services
  • Loading branch information
rzane authored Jan 30, 2022
2 parents b131576 + 39b31f1 commit 6b6f4cf
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 26 deletions.
53 changes: 36 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,90 @@ on: [push]
jobs:
# Lint should only run against the latest versions.
lint:
name: Lint
runs-on: ${{ matrix.os }}
env:
MIX_ENV: dev
name: Lint
strategy:
matrix:
os: ["ubuntu-20.04"]
elixir: ["1.13"]
otp: ["24"]
steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
- name: Checkout
uses: actions/checkout@v2

- name: Install Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- uses: actions/cache@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: deps
key: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_
- run: mix deps.get
- run: mix deps.compile
- run: mix format --check-formatted
- run: mix deps.unlock --check-unused

- name: Install depenencies
run: mix do deps.get, deps.compile

- name: Check formatting
run: mix format --check-formatted

- name: Check for unused dependencies
run: mix deps.unlock --check-unused

- name: Cache dialyzer
uses: actions/cache@v2
with:
path: priv/plts
key: plts-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}

- name: Dialyzer
run: mix dialyzer

- name: Credo
run: mix credo --all

# Build phase to check against multiple versions of OTP and elixir for as
# much compatibility as we can stand.
build:
name: Test Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, OS ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
MIX_ENV: test
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Test Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, OS ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04"]
elixir: ["1.13", "1.12", "1.11", "1.10"]
otp: ["24", "23", "22"]
services:
minio:
image: rzane/minio
ports: ["9000:9000"]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: erlef/setup-beam@v1

- name: Start services
run: docker compose up -d --wait

- name: Install Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- uses: actions/cache@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: deps
key: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ matrix.os }}-otp_${{ matrix.otp }}-elixir_${{ matrix.elixir }}-mix_
- name: Dependencies
run: mix deps.get --only test

- name: Install dependencies
run: mix deps.get --only test, deps.compile

- name: Compile
run: mix compile --force --warnings-as-errors
- name: Test
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,12 @@ iex> MyApp.Storage.read("foo")

## Contributing

In order to test the S3 adapter, we run Minio locally in a Docker container. To start the Minio
service, run the following script:
In order to run the test suite, you'll need [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/). Docker is used to run services like Minio locally, so that we can integration test the S3 adapter.

$ bin/start
To install dependencies and start services:

To run the test suite, run:
$ bin/setup

Run the test suite:

$ bin/test
13 changes: 13 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

say() {
printf "\e[33m$1\e[0m\n"
}

say "==>> Installing dependencies..."
mix deps.get

say "\n==>> Starting services..."
docker compose up -d --wait
5 changes: 0 additions & 5 deletions bin/start

This file was deleted.

10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
minio:
image: minio/minio:RELEASE.2020-10-18T21-54-12Z
command: ["server", "/data"]
ports: ["9000:9000"]
environment:
MINIO_ACCESS_KEY: development
MINIO_SECRET_KEY: development
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]

0 comments on commit 6b6f4cf

Please sign in to comment.