mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
Merge pull request #654 from Athanasius/fix/638-annotate-flake8-checks
flake8-your-pr annotations fail for any fork branch
This commit is contained in:
commit
46e9f4253d
44
.github/workflows/pr-annotate-with-flake8.yml
vendored
44
.github/workflows/pr-annotate-with-flake8.yml
vendored
@ -1,7 +1,9 @@
|
||||
# This workflow will:
|
||||
#
|
||||
# install Python dependencies
|
||||
# Run flake8 to add annotations to the PR
|
||||
# 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
|
||||
@ -15,15 +17,36 @@ jobs:
|
||||
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.actor == 'Athanasius' }}
|
||||
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
|
||||
env:
|
||||
BASE_REF: ${{github.base_ref}}
|
||||
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
|
||||
@ -31,16 +54,27 @@ jobs:
|
||||
# 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.7
|
||||
if: ${{ env.PYFILES != '' }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
##################################################################
|
||||
|
||||
##################################################################
|
||||
# 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 }}
|
||||
##################################################################
|
||||
|
@ -5,7 +5,6 @@ members on the logging.LogRecord instance for use in logging.Formatter()
|
||||
strings.
|
||||
"""
|
||||
|
||||
# A small comment
|
||||
# So that any warning about accessing a protected member is only in one place.
|
||||
from sys import _getframe as getframe
|
||||
import inspect
|
||||
|
Loading…
x
Reference in New Issue
Block a user