diff --git a/.github/workflows/pr-annotate-with-flake8.yml b/.github/workflows/pr-annotate-with-flake8.yml index 54e91393..f293a9fc 100644 --- a/.github/workflows/pr-annotate-with-flake8.yml +++ b/.github/workflows/pr-annotate-with-flake8.yml @@ -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 }} + ################################################################## diff --git a/EDMCLogging.py b/EDMCLogging.py index 72e7c81c..15a29286 100644 --- a/EDMCLogging.py +++ b/EDMCLogging.py @@ -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