name: Distribution

on:
  push:
    branches-ignore:
    - dependabot/**
    - deepsource**
  pull_request:

jobs:
  setup:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        submodules: recursive
    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        python-version: 3.7
        cache: pip
        cache-dependency-path: requirements/*.txt
    - name: Install apt dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y libgettextpo-dev
    - name: Update pip
      run: pip install --upgrade pip wheel
    - name: Install pip dependencies
      run: |
        pip install -r requirements/dev.txt
    - name: Build sdist
      run: make build
    - name: Twine check
      run: twine check dist/*
    - name: Install test
      run: |
        virtualenv test-ttk-release
        . ./test-ttk-release/bin/activate
        pip install dist/translate-toolkit-*.tar.gz
        moz2po --help
    - name: Run build
      run: coverage run ./setup.py build
    - name: Run setup
      run: coverage run --append ./setup.py sdist
    - name: Coverage
      run: coverage xml
    - uses: codecov/codecov-action@v2.1.0
      with:
        name: setup
