mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 16:27:13 +03:00
Added auto-annotation to both checks
This works based on telling github how to understand the flake8 output # Conflicts: # .github/workflows/push-checks.yml
This commit is contained in:
parent
7e094df6c4
commit
c69cc77682
80
.github/workflows/pr-annotate-with-flake8.yml
vendored
80
.github/workflows/pr-annotate-with-flake8.yml
vendored
@ -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 }}
|
||||
##################################################################
|
13
.github/workflows/pr-checks.yml
vendored
13
.github/workflows/pr-checks.yml
vendored
@ -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
|
||||
|
15
.github/workflows/push-checks.yml
vendored
15
.github/workflows/push-checks.yml
vendored
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user