Feature/test fly #120
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
name: Elixir CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
env: | |
MIX_ENV: 'test' | |
NETATMO_APP_ID: ${{ secrets.NETATMO_APP_ID }} | |
NETATMO_CLIENT_SECRET: ${{ secrets.NETATMO_CLIENT_SECRET }} | |
NETATMO_USER_EMAIL: ${{ secrets.NETATMO_USER_EMAIL }} | |
NETATMO_USER_PASSWORD: ${{ secrets.NETATMO_USER_PASSWORD }} | |
ALTERVISTA_USER: ${{ secrets.ALTERVISTA_USER }} | |
ALTERVISTA_PASSWORD: ${{ secrets.ALTERVISTA_PASSWORD }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.12.3' # Define the elixir version [required] | |
otp-version: '24.1.4' # Define the OTP version [required] | |
- name: Restore dependencies and build cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
- name: Install dependencies | |
run: mix deps.get | |
- name: Build | |
run: mix compile | |
test: | |
name: Test | |
runs-on: ubuntu-20.04 | |
needs: build | |
env: | |
MIX_ENV: 'test' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for coveralls | |
NETATMO_APP_ID: ${{ secrets.NETATMO_APP_ID }} | |
NETATMO_CLIENT_SECRET: ${{ secrets.NETATMO_CLIENT_SECRET }} | |
NETATMO_USER_EMAIL: ${{ secrets.NETATMO_USER_EMAIL }} | |
NETATMO_USER_PASSWORD: ${{ secrets.NETATMO_USER_PASSWORD }} | |
ALTERVISTA_USER: ${{ secrets.ALTERVISTA_USER }} | |
ALTERVISTA_PASSWORD: ${{ secrets.ALTERVISTA_PASSWORD }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: '1.12.3' # Define the elixir version [required] | |
otp-version: '24.1.4' # Define the OTP version [required] | |
experimental-otp: true | |
- name: Restore dependencies and build cache | |
uses: actions/cache@v2 | |
with: | |
path: | | |
deps | |
_build | |
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} | |
restore-keys: ${{ runner.os }}-mix- | |
- name: Start PostgreSQL | |
uses: harmon758/postgresql-action@v1 | |
with: | |
postgresql version: '14.4' | |
postgresql db: "webcam_fornolo_test" | |
postgresql user: "user" | |
postgresql password: "pass" | |
- name: Run DB migrations | |
run: mix ecto.setup | |
- name: Run tests | |
run: mix coveralls.github --trace | |
deploy: | |
name: Fly Deploy | |
runs-on: ubuntu-20.04 | |
needs: test | |
if: github.ref == 'refs/heads/master' | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up flyctl | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Deploy | |
run: flyctl deploy --remote-only |