name: style
on:
  push:
  pull_request:
jobs:
  style:
    runs-on: ubuntu-latest
    # https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/5
    if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'eventlet/eventlet'
    timeout-minutes: 5

    steps:
      - uses: actions/checkout@v2

      - name: cache pip
        uses: actions/cache@v2
        with:
          path: ~/.cache/pip
          key: ${{ runner.os }}-pip-${{ hashFiles('.github/workflows/style.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pip-
            ${{ runner.os }}-
      - name: cache tox
        uses: actions/cache@v2
        with:
          path: .tox
          key: ${{ runner.os }}-tox-style-${{ hashFiles('tox.ini') }}
          restore-keys: |
            ${{ runner.os }}-tox-style-
            ${{ runner.os }}-tox-
            ${{ runner.os }}-

      - name: setup python
        uses: actions/setup-python@v2
        with:
          python-version: 3.x
      - name: install tox
        run: pip install tox
      - name: run tests
        run: tox --verbose -e pep8
