<commit_before>name: Tests

on: [push, pull_request]

jobs:
  tests:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        include:
          #- {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39}
          #- {name: Windows, python: '3.9', os: windows-latest, tox: py39}
          #- {name: Mac, python: '3.9', os: macos-latest, tox: py39}
          - { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 }
          - { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 }
          - { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }
          - { name: "3.7", python: "3.7", os: ubuntu-latest, tox: py37 }
          - { name: "3.6", python: "3.6", os: ubuntu-latest, tox: py36 }

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
      - name: Update pip
        run: |
          pip install -U wheel
          pip install -U setuptools
          python -m pip install -U pip
      - name: Get pip cache dir
        id: pip-cache
        run: echo "::set-output name=dir::$(pip cache dir)"
      - uses: actions/cache@v2
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}
      - name: set full Python version in PY env var
        # See https://pre-commit.com/#github-actions-example
        run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
      - run: pip install tox codecov
      - run: tox -e ${{ matrix.tox }}

  verify_docker_build:
    name: Always - Docker verify, push to tag 'master' if on master
    runs-on: ubuntu-latest
    if: github.event_name != 'pull_request' # PR build doesnt get proper version, so dont try to build it
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: docker/login-action@v1
        if: github.repository_owner == 'locustio'
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'locustio' }}
          tags: locustio/locust:master

  docker_tagged:
    name: Tagged - Docker push to tag based on git tag. Also push 'latest' if on master
    needs: tests
    runs-on: ubuntu-latest
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - run: echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - run: echo "BRANCH=$(git branch -a --contains ${{ env.TAG }} | grep -v HEAD | cut -d '/' -f3)" | tee -a $GITHUB_ENV
      - uses: docker/login-action@v1
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: true
          tags: locustio/locust:${{ env.TAG }}${{ ( env.BRANCH == 'master' && ',locustio/locust:latest') || '' }}

  publish:
    name: PyPI - Publish if this is a tagged commit
    needs: [verify_docker_build, tests]
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel
      - name: Build + set TAG env var for later use
        run: |
          python setup.py sdist bdist_wheel
          echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - name: Publish tagged version to PyPI
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true
      - name: Tweet on release
        uses: infraway/tweet-action@v1.0.1
        with:
          status: "New release: ${{ env.TAG }} https://github.com/locustio/locust/releases/tag/${{ env.TAG }}"
          api_key: ${{ secrets.TWITTER_API_CONSUMER_KEY }}
          api_key_secret: ${{ secrets.TWITTER_API_CONSUMER_SECRET }}
          access_token: ${{ secrets.TWITTER_API_ACCESS_TOKEN_KEY }}
          access_token_secret: ${{ secrets.TWITTER_API_ACCESS_TOKEN_SECRET }}

  publish_prerelease:
    name: PyPI - Publish prerelease on merge commit on master
    needs: tests
    if: github.ref == 'refs/heads/master' && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.x"
      - run: git rev-parse HEAD^2 2>/dev/null >/dev/null || echo NOT_MERGE_COMMIT=1 | tee -a $GITHUB_ENV
      - name: Install dependencies
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel
      - name: Build
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python setup.py sdist bdist_wheel
      - name: Publish prerelease version to PyPI
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true
<commit_msg>Run the linters in GitHub Actions<commit_after>name: Tests

on: [push, pull_request]

jobs:
  tests:
    name: ${{ matrix.name }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        include:
          #- {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39}
          #- {name: Windows, python: '3.9', os: windows-latest, tox: py39}
          #- {name: Mac, python: '3.9', os: macos-latest, tox: py39}
          - { name: "flake8", python: "3.10", os: ubuntu-latest, tox: "flake8" }
          - { name: "black", python: "3.10", os: ubuntu-latest, tox: "black" }
          - { name: "mypy", python: "3.10", os: ubuntu-latest, tox: "mypy" }
          - { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 }
          - { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 }
          - { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }
          - { name: "3.7", python: "3.7", os: ubuntu-latest, tox: py37 }
          - { name: "3.6", python: "3.6", os: ubuntu-latest, tox: py36 }

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python }}
      - name: Update pip
        run: |
          pip install -U wheel
          pip install -U setuptools
          python -m pip install -U pip
      - name: Get pip cache dir
        id: pip-cache
        run: echo "::set-output name=dir::$(pip cache dir)"
      - uses: actions/cache@v2
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}
      - name: set full Python version in PY env var
        # See https://pre-commit.com/#github-actions-example
        run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
      - run: pip install tox codecov
      - run: tox -e ${{ matrix.tox }}

  verify_docker_build:
    name: Always - Docker verify, push to tag 'master' if on master
    runs-on: ubuntu-latest
    if: github.event_name != 'pull_request' # PR build doesnt get proper version, so dont try to build it
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: docker/login-action@v1
        if: github.repository_owner == 'locustio'
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'locustio' }}
          tags: locustio/locust:master

  docker_tagged:
    name: Tagged - Docker push to tag based on git tag. Also push 'latest' if on master
    needs: tests
    runs-on: ubuntu-latest
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - run: echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - run: echo "BRANCH=$(git branch -a --contains ${{ env.TAG }} | grep -v HEAD | cut -d '/' -f3)" | tee -a $GITHUB_ENV
      - uses: docker/login-action@v1
        with:
          username: locustbuild
          password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: build and publish image
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          build-args: |
            BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
          context: .
          file: ./Dockerfile
          platforms: linux/amd64,linux/arm64
          push: true
          tags: locustio/locust:${{ env.TAG }}${{ ( env.BRANCH == 'master' && ',locustio/locust:latest') || '' }}

  publish:
    name: PyPI - Publish if this is a tagged commit
    needs: [verify_docker_build, tests]
    if: startsWith(github.event.ref, 'refs/tags') && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel
      - name: Build + set TAG env var for later use
        run: |
          python setup.py sdist bdist_wheel
          echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
      - name: Publish tagged version to PyPI
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true
      - name: Tweet on release
        uses: infraway/tweet-action@v1.0.1
        with:
          status: "New release: ${{ env.TAG }} https://github.com/locustio/locust/releases/tag/${{ env.TAG }}"
          api_key: ${{ secrets.TWITTER_API_CONSUMER_KEY }}
          api_key_secret: ${{ secrets.TWITTER_API_CONSUMER_SECRET }}
          access_token: ${{ secrets.TWITTER_API_ACCESS_TOKEN_KEY }}
          access_token_secret: ${{ secrets.TWITTER_API_ACCESS_TOKEN_SECRET }}

  publish_prerelease:
    name: PyPI - Publish prerelease on merge commit on master
    needs: tests
    if: github.ref == 'refs/heads/master' && github.repository_owner == 'locustio'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: "3.x"
      - run: git rev-parse HEAD^2 2>/dev/null >/dev/null || echo NOT_MERGE_COMMIT=1 | tee -a $GITHUB_ENV
      - name: Install dependencies
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python -m pip install --upgrade pip
          pip install setuptools wheel
      - name: Build
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        run: |
          python setup.py sdist bdist_wheel
      - name: Publish prerelease version to PyPI
        if: ${{ env.NOT_MERGE_COMMIT == '' }}
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
          skip_existing: true

{'fraction_non_alphanumeric': 0.12921904761904762, 'fraction_numerical': 0.0144, 'mean_word_length': 2.0216390423572745, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4091676', 'n_tokens_mistral': 4525, 'n_tokens_neox': 4242, 'n_words': 1089}