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@v4

      - name: cache pip
        uses: actions/cache@v4
        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@v4
        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@v5
        with:
          python-version: 3.x
      - name: install tox
        run: pip install tox
      - name: run tests
        run: |
          tox --verbose -e pep8
          tox --verbose -e lint
