From c69cc77682c29c679c986d97585ea2e10ee84941 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 22 Mar 2021 13:03:56 +0000 Subject: [PATCH] Added auto-annotation to both checks This works based on telling github how to understand the flake8 output # Conflicts: # .github/workflows/push-checks.yml --- .github/workflows/pr-annotate-with-flake8.yml | 80 ------------------- .github/workflows/pr-checks.yml | 13 +-- .github/workflows/push-checks.yml | 15 ++-- 3 files changed, 13 insertions(+), 95 deletions(-) delete mode 100644 .github/workflows/pr-annotate-with-flake8.yml diff --git a/.github/workflows/pr-annotate-with-flake8.yml b/.github/workflows/pr-annotate-with-flake8.yml deleted file mode 100644 index 93209cc8..00000000 --- a/.github/workflows/pr-annotate-with-flake8.yml +++ /dev/null @@ -1,80 +0,0 @@ -# This workflow will: -# -# 1. Store some github context in env vars. -# 2. Only checkout if base and head ref owners are the same. -# 3. Check if any *.py files are in the diff. -# 4. Only then install python and perform the annotation with flake8. -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: PR-annotate-flake8 - -on: - pull_request: - branches: [ develop ] - -jobs: - flake8_annotate: - runs-on: ubuntu-18.04 - - steps: - ################################################################## - # Check if the base and head repos are the same, if not we won't - # be able to add annotations. - ################################################################## - - name: Check head and base repo same - env: - BASE_REPO_OWNER: ${{github.event.pull_request.base.repo.owner.login}} - HEAD_REPO_OWNER: ${{github.event.pull_request.head.repo.owner.login}} - BASE_REF: ${{github.base_ref}} - run: | - # Just to be running something - env - ################################################################## - - ################################################################## - # Perform the checkout - ################################################################## - - name: Checkout - if: ${{ github.event.pull_request.base.repo.owner.login == github.event.pull_request.head.repo.owner.login }} - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ################################################################## - - ################################################################## - # flake8-your-pr 'fails' if no *.py files changed - # So we check if any were affected and store that in env - ################################################################## - - name: Check for PY files - if: ${{ github.event.pull_request.base.repo.owner.login == github.event.pull_request.head.repo.owner.login }} - run: | - # Checkout might not have happened. - if [ ! -d ".git" ]; then exit 0 ; fi - # Get a list of files ending with ".py", stuff in environment. - # We don't rely on exit status because Workflows run with - # "set -e" so any failure in a pipe is total failure. - PYFILES=$(git diff --name-only "refs/remotes/origin/${BASE_REF}" -- | egrep '.py$' || true) - # Use magic output to store in env for rest of workflow - echo "::set-env name=PYFILES::${PYFILES}" - ################################################################## - - ################################################################## - # Get Python set up - ################################################################## - - name: Set up Python 3.8 - if: ${{ env.PYFILES != '' }} - uses: actions/setup-python@v2 - with: - python-version: 3.8 - ################################################################## - - ################################################################## - # Perform the annotation - ################################################################## - - name: Annotate with Flake8 - # Only if at least one *.py file was affected - if: ${{ env.PYFILES != '' }} - uses: "tayfun/flake8-your-pr@master" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ################################################################## diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 055ee6a0..f7d8418f 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -52,18 +52,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 + pip wheel install flake8 if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; elif [ -f requirements.txt ]; then pip install -r requirements.txt ; fi #################################################################### - #################################################################### - # Show full github context to aid debugging. - #################################################################### - - name: Show github context - run: | - env - cat $GITHUB_EVENT_PATH - #################################################################### + # Have issues be annotated on run + - name: Setup flake8 annotations + uses: rbialon/flake8-annotations@v1 #################################################################### # Lint with flake8 diff --git a/.github/workflows/push-checks.yml b/.github/workflows/push-checks.yml index 2ab55d45..b976c8bb 100644 --- a/.github/workflows/push-checks.yml +++ b/.github/workflows/push-checks.yml @@ -9,8 +9,8 @@ name: Push-Checks on: push: - branches: [ main ] - + branches: [ develop ] + jobs: build: @@ -27,16 +27,19 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest wheel + pip install wheel flake8 pytest if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi + + - name: Setup flake8 annotations + uses: rbialon/flake8-annotations@v1 + - name: Lint with flake8 env: ROOT_SHA: ${{github.base_ref}} - run: | - DATA=$(jq --raw-output .before $GITHUB_EVENT_PATH) + DATA=$(jq .before $GITHUB_EVENT_PATH) # stop the build if there are Python syntax errors or undefined names, ignore existing git diff "$DATA" | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --diff # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - git diff "$DATA" | flake8 . --count --exit-zero --statistics --diff + git diff "$DATA" | flake8 . --count --statistics --diff