diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 0000000..46e5d2f --- /dev/null +++ b/.github/workflows/api.yml @@ -0,0 +1,57 @@ +name: Elixir API CI + +on: + push: + paths: + - '.github/workflows/api.yml' + - 'api/*' + +jobs: + build: + runs-on: ubuntu-latest + + container: + image: elixir:1.9 + env: + MIX_ENV: test + DATABASE_HOST: postgresql + + services: + postgresql: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + working-directory: api/ + run: | + mix local.rebar --force + mix local.hex --force + mix deps.get + - name: Setup database + working-directory: api/ + run: | + mix ecto.create + mix ecto.migrate + - name: Run tests + working-directory: api/ + run: | + mix format --check-formatted + mix test + + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v1 + - name: Deploy to Gigalixir + # if: github.ref == 'refs/heads/master' + working-directory: api/ + run: ./scripts/deploy.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fb6a232..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: elixir -elixir: - - "1.9" -otp_release: - - "22.0" - -services: - - postgresql - -before_install: - - cd api - -before_script: - - mix ecto.create - -script: - - mix format --check-formatted - - mix test - -after_success: - - cd .. - -deploy: - provider: script - script: bash api/scripts/deploy.sh - on: - branch: master diff --git a/api/config/test.exs b/api/config/test.exs index 8e7f328..587eb8a 100644 --- a/api/config/test.exs +++ b/api/config/test.exs @@ -5,7 +5,7 @@ config :locationiser, Locationiser.Repo, username: "postgres", password: "postgres", database: "locationiser_test", - hostname: "localhost", + hostname: System.get_env("DATABASE_HOST") || "localhost", pool: Ecto.Adapters.SQL.Sandbox # We don't run a server during test. If one is required,