mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-22 19:40:30 +03:00
github: Add pr-checks workflow
* flake8 checks
This commit is contained in:
parent
d65b715222
commit
d9d3bc0de4
93
.github/workflows/pr-checks.yml
vendored
Normal file
93
.github/workflows/pr-checks.yml
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
# This workflow will:
|
||||
#
|
||||
# * install Python dependencies
|
||||
# * lint with a single version of Python
|
||||
#
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
||||
|
||||
name: PR-Checks
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ develop ]
|
||||
|
||||
jobs:
|
||||
flake8:
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
|
||||
# Debug show the info we have to work with
|
||||
- name: Show github context
|
||||
run: cat $GITHUB_EVENT_PATH
|
||||
|
||||
####################################################################
|
||||
# Checkout the necessary commits
|
||||
####################################################################
|
||||
# We need the repo from the 'head' of the PR, not what it's
|
||||
# based on.
|
||||
- name: Checkout head commits
|
||||
# https://github.com/actions/checkout
|
||||
uses: actions/checkout@v2.4.0
|
||||
#with:
|
||||
#ref: ${{github.head.sha}}
|
||||
#repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||
#fetch-depth: 0
|
||||
|
||||
# But we do need the base references
|
||||
- name: Fetch base commits
|
||||
env:
|
||||
BASE_REPO_URL: ${{github.event.pull_request.base.repo.svn_url}}
|
||||
BASE_REPO_OWNER: ${{github.event.pull_request.base.repo.owner.login}}
|
||||
|
||||
run: |
|
||||
echo "BASE_REPO_URL: ${BASE_REPO_URL}"
|
||||
echo "BASE_REPO_OWNER: ${BASE_REPO_OWNER}"
|
||||
# Add the 'base' repo as a new remote
|
||||
git remote add ${BASE_REPO_OWNER} ${BASE_REPO_URL}
|
||||
# And then fetch its references
|
||||
git fetch ${BASE_REPO_OWNER}
|
||||
####################################################################
|
||||
|
||||
####################################################################
|
||||
# Get Python set up
|
||||
####################################################################
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2.2.2
|
||||
with:
|
||||
python-version: 3.9
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install wheel flake8
|
||||
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; elif [ -f requirements.txt ]; then pip install -r requirements.txt ; fi
|
||||
####################################################################
|
||||
|
||||
# Have issues be annotated on run
|
||||
- name: Setup flake8 annotations
|
||||
uses: rbialon/flake8-annotations@v1
|
||||
|
||||
####################################################################
|
||||
# Lint with flake8
|
||||
####################################################################
|
||||
- name: Lint with flake8
|
||||
env:
|
||||
BASE_REPO_URL: ${{github.event.pull_request.base.repo.svn_url}}
|
||||
BASE_REPO_OWNER: ${{github.event.pull_request.base.repo.owner.login}}
|
||||
BASE_REF: ${{github.base_ref}}
|
||||
|
||||
run: |
|
||||
echo "BASE_REPO_URL: ${BASE_REPO_URL}"
|
||||
echo "BASE_REPO_OWNER: ${BASE_REPO_OWNER}"
|
||||
echo "BASE_REF: ${BASE_REF}"
|
||||
# Explicitly check for some errors
|
||||
# E9 - Runtime (syntax and the like)
|
||||
# F63 - 'tests' checking
|
||||
# F7 - syntax errors
|
||||
# F82 - undefined checking
|
||||
git diff "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --diff
|
||||
# Can optionally add `--exit-zero` to the flake8 arguments so that
|
||||
# this doesn't fail the build.
|
||||
# explicitly ignore docstring errors (start with D)
|
||||
git diff "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | flake8 . --count --statistics --diff --extend-ignore D
|
||||
####################################################################
|
Loading…
x
Reference in New Issue
Block a user