Skip to content

Commit

Permalink
Merge pull request #35 from soedirgo/feature/ci
Browse files Browse the repository at this point in the history
Automate tests, build, & release
  • Loading branch information
soedirgo committed May 20, 2020
2 parents 1d7cf11 + 4ced580 commit a3e6dbd
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI
on:
pull_request:
push:
branches:
- master

jobs:
test:
name: OTP ${{ matrix.otp }} / Elixir ${{ matrix.elixir }}

defaults:
run:
working-directory: ./server

strategy:
matrix:
platform: [ubuntu-latest]
otp: [21.x, 22.x]
elixir: [1.9.x, 1.10.x]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Postgres
run: docker-compose -f ../docker-compose.db.yml up -d

- name: Set up Elixir
uses: actions/setup-elixir@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Cache Mix
uses: actions/cache@v1
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get

# - name: Compile with warnings
# run: mix compile --warnings-as-errors

# - name: Run formatter
# run: mix format --check-formatted

# - name: Run Credo
# run: mix credo

- name: Run tests
run: mix test
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
push:
tags:
- '*'

jobs:
release:
defaults:
run:
working-directory: ./server

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Elixir
uses: actions/setup-elixir@v1
with:
elixir-version: 1.10.x
otp-version: 22.x

- name: Prepare release
run: |
mix deps.get
mix compile
mix release
tar -czvf realtime-ubuntu-latest.tar.gz -C ./_build/prod/rel/realtime/bin realtime
env:
MIX_ENV: prod

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false

- name: Upload release assets
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./server/realtime-ubuntu-latest.tar.gz
asset_name: realtime-ubuntu-latest.tar.gz
asset_content_type: application/gzip

- name: Upload build to Docker Hub
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: supabase/realtime
tag_with_ref: true

0 comments on commit a3e6dbd

Please sign in to comment.