name: coverage
on: [push]
permissions:
  contents: read

jobs:
  coverage:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2
    - name: Set up latest Python 3
      uses: actions/setup-python@f38219332975fe8f9c04cca981d674bf22aea1d3 # v2
      with:
        python-version: 3
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install protobuf==3.17.3 pycodestyle coverage coveralls
    - name: Test with coverage
      run: |
        cd python
        COVERAGE_FILE=main.cov coverage run --source=phonenumbers ./testwrapper.py
        COVERAGE_FILE=pb2.cov coverage run --source=phonenumbers.pb2 ./testpb2.py
        coverage combine main.cov pb2.cov
    - name: Upload coverage
      env:
        COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      run: |
        cd python
        coveralls
