-
-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from soedirgo/feature/ci
Automate tests, build, & release
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |