CI: add a workflow to show flake8/mypy violations in modified files of a PR (#1513)
* CI: add a workflow to show flake8 violations in modified files of a PR * modify a file to trigger the lint check * CI: add a workflow to show mypy violations in modified files of a PR * modify a file to trigger the type check * Split flake8 and mypy into two parallel jobs; run a variant of the workflow on push event; modify a file to trigger the push workflow * fail the task if there are syntax errors; remove old lint workflow
This commit is contained in:
parent
18127a75f5
commit
5255bc5cd8
|
@ -0,0 +1,75 @@
|
||||||
|
name: Analyze modified files
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "**.py"
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "**.py"
|
||||||
|
|
||||||
|
env:
|
||||||
|
BASE: ${{ github.event.pull_request.base.sha }}
|
||||||
|
HEAD: ${{ github.event.pull_request.head.sha }}
|
||||||
|
BEFORE: ${{ github.event.before }}
|
||||||
|
AFTER: ${{ github.event.after }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
flake8-or-mypy:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
task: [flake8, mypy]
|
||||||
|
|
||||||
|
name: ${{ matrix.task }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: "Determine modified files (pull_request)"
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
run: |
|
||||||
|
git fetch origin $BASE $HEAD
|
||||||
|
DIFF=$(git diff --diff-filter=d --name-only $BASE...$HEAD -- "*.py")
|
||||||
|
echo "modified files:"
|
||||||
|
echo "$DIFF"
|
||||||
|
echo "diff=${DIFF//$'\n'/$' '}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: "Determine modified files (push)"
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
git fetch origin $BEFORE $AFTER
|
||||||
|
DIFF=$(git diff --diff-filter=d --name-only $BEFORE..$AFTER -- "*.py")
|
||||||
|
echo "modified files:"
|
||||||
|
echo "$DIFF"
|
||||||
|
echo "diff=${DIFF//$'\n'/$' '}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
if: env.diff != ''
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: "Install dependencies"
|
||||||
|
if: env.diff != ''
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip ${{ matrix.task }}
|
||||||
|
python ModuleUpdate.py --append "WebHostLib/requirements.txt" --force --yes
|
||||||
|
|
||||||
|
- name: "flake8: Stop the build if there are Python syntax errors or undefined names"
|
||||||
|
continue-on-error: false
|
||||||
|
if: env.diff != '' && matrix.task == 'flake8'
|
||||||
|
run: |
|
||||||
|
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics ${{ env.diff }}
|
||||||
|
|
||||||
|
- name: "flake8: Lint modified files"
|
||||||
|
continue-on-error: true
|
||||||
|
if: env.diff != '' && matrix.task == 'flake8'
|
||||||
|
run: |
|
||||||
|
flake8 --count --max-complexity=10 --max-doc-length=120 --max-line-length=120 --statistics ${{ env.diff }}
|
||||||
|
|
||||||
|
- name: "mypy: Type check modified files"
|
||||||
|
continue-on-error: true
|
||||||
|
if: env.diff != '' && matrix.task == 'mypy'
|
||||||
|
run: |
|
||||||
|
mypy --follow-imports=silent --install-types --non-interactive --strict ${{ env.diff }}
|
|
@ -1,35 +0,0 @@
|
||||||
# This workflow will install Python dependencies, run tests and 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: lint
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- '**.py'
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- '**.py'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
flake8:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Set up Python 3.9
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: 3.9
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip wheel
|
|
||||||
pip install flake8
|
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
- name: Lint with flake8
|
|
||||||
run: |
|
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
|
@ -57,7 +57,7 @@ class AdventureWeb(WebWorld):
|
||||||
|
|
||||||
|
|
||||||
def get_item_position_data_start(table_index: int):
|
def get_item_position_data_start(table_index: int):
|
||||||
item_ram_address = item_ram_addresses[table_index];
|
item_ram_address = item_ram_addresses[table_index]
|
||||||
return item_position_table + item_ram_address - items_ram_start
|
return item_position_table + item_ram_address - items_ram_start
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue