name: CI
on: [push, pull_request]
permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-18.04
    strategy:
      matrix:
        python-version: [2.7, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", pypy2, pypy3]

    steps:
    - uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@f38219332975fe8f9c04cca981d674bf22aea1d3 # v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install protobuf==3.17.3 pycodestyle
    - name: Lint
      run: make -C tools/python lint
    - name: Test
      run: |
        make -C tools/python metaclean
        make -C tools/python test
        # Check re-generation didn't change anything (except locale.py)
        git checkout --  python/phonenumbers/geodata/locale.py
        status=$(git status --porcelain ) || :
        if [[ -n ${status} ]]; then
         echo "Regenerated files differ from checked-in versions: ${status}"
         git status
         exit 1
        fi
