name: Resolwe CI

on:
  push:
    branches:
      - master
    tags:
      - "[0-9]+.[0-9]+.[0-9]+"
  pull_request:
  schedule:
    - cron: "30 2 * * *"

jobs:
  test:
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false
      matrix:
        tox-env: [py36, py37, py38, linters, packaging, migrations]
        include:
          - tox-env: py36
            python-version: 3.6
          - tox-env: py37
            python-version: 3.7
          - tox-env: py38
            python-version: 3.8
          - tox-env: linters
            python-version: 3.6
          - tox-env: packaging
            python-version: 3.6
          - tox-env: migrations
            python-version: 3.6

    services:
      postgres: 
        image: postgres:alpine
        env:
          POSTGRES_USER: resolwe
          POSTGRES_DB: resolwe
          POSTGRES_PASSWORD: resolwe
        ports: 
          - 5432/tcp
      
      redis:
        image: redis:alpine
        ports: 
          - 6379/tcp

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Dependencies
        run: |
          python -m pip install --upgrade pip tox
      - name: Run Tests
        run: >
          RESOLWE_DOCKER_DISABLE_SECCOMP=1
          tox -e ${{ matrix.tox-env }}
          --skip-missing-interpreters false
          --recreate
        env:
          RESOLWE_REDIS_PORT: ${{ job.services.redis.ports[6379] }}
          RESOLWE_POSTGRESQL_HOST: localhost
          RESOLWE_POSTGRESQL_NAME: resolwe
          RESOLWE_POSTGRESQL_USER: resolwe
          RESOLWE_POSTGRESQL_PASS: resolwe
          RESOLWE_POSTGRESQL_PORT: ${{ job.services.postgres.ports[5432] }}
      - name: Upload coverage to Codecov
        if: matrix.tox-env == 'py36' || matrix.tox-env == 'py37' || matrix.tox-env == 'py38'
        uses: codecov/codecov-action@v1
        with:
          file: .coverage
      
  build:
    runs-on: ubuntu-20.04

    needs: test
    
    if: "startsWith(github.ref, 'refs/tags')"

    steps:
      - uses: actions/checkout@v1
      - name: Set up Python 3.8
        uses: actions/setup-python@v1
        with:
          python-version: 3.8
      - name: Install pep517
        run: python -m pip install --user pep517
      - name: Build a binary wheel and a source tarball
        run: python -m pep517.build --source --binary --out-dir dist/ .
      - name: Publish distribution to PyPI
        uses: pypa/gh-action-pypi-publish@master
        with:
          password: ${{ secrets.pypi_password }}

Add github actions workflow file
Add github actions workflow file
