mirror of
https://github.com/noDRM/DeDRM_tools.git
synced 2024-12-29 21:07:39 +06:00
Refine gh-actions
* Update and rename Python_test.yml to Lint.yaml * Create Format.yaml
This commit is contained in:
parent
dbc5c2b4de
commit
731eeac087
39
.github/workflows/Format.yaml
vendored
Normal file
39
.github/workflows/Format.yaml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Python code format
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: master
|
||||||
|
jobs:
|
||||||
|
Format:
|
||||||
|
if: "!contains(github.event.head_commit.message, '!format')"
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@main
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@main
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
- uses: actions/cache@main
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-format
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-format
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install autopep8 pycodestyle
|
||||||
|
- name: Format by autopep8 then Push
|
||||||
|
env:
|
||||||
|
GIT_EMAIL: github-actions[bot]@users.noreply.github.com
|
||||||
|
GIT_ACTOR: github-actions[bot]
|
||||||
|
run: |
|
||||||
|
export HASH_SHORT=$(git rev-parse --short HEAD)
|
||||||
|
git checkout -b format--${HASH_SHORT}
|
||||||
|
git config --global user.email $GIT_EMAIL
|
||||||
|
git config --global user.name $GIT_ACTOR
|
||||||
|
python -m autopep8 --in-place --aggressive --aggressive --experimental -r ./
|
||||||
|
git add -A
|
||||||
|
git commit -m 'Format by autopep8' -m From: -m $(git rev-parse HEAD)
|
||||||
|
git push --set-upstream origin format--${HASH_SHORT}
|
26
.github/workflows/Lint.yaml
vendored
Normal file
26
.github/workflows/Lint.yaml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: Python code review
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
Test:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@main
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@main
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
- uses: actions/cache@main
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip-lint
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pip-lint
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install flake8
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
python -m flake8 . --builtins=_,I --ignore=E501 --count --benchmark --show-source --statistics
|
35
.github/workflows/Python_tests.yml
vendored
35
.github/workflows/Python_tests.yml
vendored
@ -1,35 +0,0 @@
|
|||||||
name: Python_tests
|
|
||||||
on: [push, pull_request]
|
|
||||||
jobs:
|
|
||||||
Python_tests:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest]
|
|
||||||
python-version: [2.7, 3.8]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install flake8 pytest # -r requirements.txt
|
|
||||||
#- name: Check formatting with black
|
|
||||||
# if: matrix.python-version == '3.8'
|
|
||||||
# run: |
|
|
||||||
# pip install black
|
|
||||||
# black --check .
|
|
||||||
- name: Lint with flake8
|
|
||||||
run: |
|
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
|
||||||
flake8 . --builtins=_,I --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
||||||
flake8 . --builtins=_,I --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
||||||
#- name: Test with pytest
|
|
||||||
# run: pytest
|
|
||||||
#- name: Run doctests with pytest
|
|
||||||
# run: pytest --doctest-modules
|
|
Loading…
Reference in New Issue
Block a user