coopdevs/lazona_connector

View on GitHub
.github/workflows/build.yml

Summary

Maintainability
Test Coverage
name: Build

on: [workflow_dispatch, push, pull_request]

jobs:
  test:

    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres
        ports: ["5432:5432"]
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        env:
          POSTGRES_DB: lazona_connector
          POSTGRES_USER: lazona_connector
          POSTGRES_PASSWORD: secret

    env:
      SECRET_KEY: 'secret_key'
      DATABASE_URL: postgres://lazona_connector:secret@localhost:5432/lazona_connector
      DATABASE_DISABLE_SSL: 'true'

    steps:
      - uses: actions/checkout@v2

      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
          restore-keys: |
            ${{ runner.os }}-pip-

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.8.3'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Run tests and coverage
        run: coverage run --source='.' manage.py test

      - name: Lint with flake8
        run: flake8 . --count --show-source --statistics

      - name: Upload Coverage to Codecov
        uses: codecov/codecov-action@v1