mirror of
https://github.com/YunoHost/ynh-dev.git
synced 2024-09-03 20:05:59 +02:00
Reorganize github workflows: one check on push+pr, one check+format then commit, only on push on master
This commit is contained in:
parent
751ff67fd9
commit
e03e960249
4 changed files with 61 additions and 44 deletions
36
.github/workflows/autoblack.yml
vendored
36
.github/workflows/autoblack.yml
vendored
|
@ -1,36 +0,0 @@
|
||||||
name: Check / auto apply Black
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
black:
|
|
||||||
name: Check / auto apply black
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Check files using the black formatter
|
|
||||||
uses: psf/black@stable
|
|
||||||
id: black
|
|
||||||
with:
|
|
||||||
options: "."
|
|
||||||
continue-on-error: true
|
|
||||||
- shell: pwsh
|
|
||||||
id: check_files_changed
|
|
||||||
run: |
|
|
||||||
# Diff HEAD with the previous commit
|
|
||||||
$diff = git diff
|
|
||||||
$HasDiff = $diff.Length -gt 0
|
|
||||||
Write-Host "::set-output name=files_changed::$HasDiff"
|
|
||||||
- name: Create Pull Request
|
|
||||||
if: steps.check_files_changed.outputs.files_changed == 'true'
|
|
||||||
uses: peter-evans/create-pull-request@v6
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
title: "Format Python code with Black"
|
|
||||||
commit-message: ":art: Format Python code with Black"
|
|
||||||
body: |
|
|
||||||
This pull request uses the [psf/black](https://github.com/psf/black) formatter.
|
|
||||||
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
|
|
||||||
branch: actions/black
|
|
|
@ -1,9 +1,9 @@
|
||||||
name: Python Ruff Lint and commit
|
name: Python Lint with Ruff and Mypy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ruff:
|
ruff:
|
||||||
|
@ -12,14 +12,14 @@ jobs:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
- name: Install Ruff
|
- name: Install Ruff and Mypy
|
||||||
run: pip install ruff
|
run: pip install ruff
|
||||||
|
|
||||||
- name: Ruff check and fix
|
- name: Ruff check
|
||||||
run: |
|
run: |
|
||||||
ruff check .
|
ruff check .
|
||||||
ruff fix .
|
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
- name: mypy check
|
||||||
with:
|
run: |
|
||||||
commit_message: 'Python style fixes from Ruff'
|
yes | mypy src --install-types || true
|
||||||
|
mypy .
|
32
.github/workflows/python-format.yml
vendored
Normal file
32
.github/workflows/python-format.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
name: Python formatting with Black and Ruff
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
name: Formatting with Black and Ruff
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check files using the black formatter
|
||||||
|
uses: psf/black@stable
|
||||||
|
id: black
|
||||||
|
with:
|
||||||
|
options: "."
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
- name: Install Ruff
|
||||||
|
run: pip install ruff
|
||||||
|
|
||||||
|
- name: Ruff check and fix
|
||||||
|
run: |
|
||||||
|
ruff check .
|
||||||
|
ruff check --fix .
|
||||||
|
|
||||||
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
|
with:
|
||||||
|
commit_message: 'Python formatting fixes from Black and Ruff'
|
21
pyproject.toml
Normal file
21
pyproject.toml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[tool.black]
|
||||||
|
line-length = 120
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 120
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = [
|
||||||
|
"F", # pyflakes
|
||||||
|
"E", # pycodestyle
|
||||||
|
"W", # pycodestyle
|
||||||
|
"I", # isort
|
||||||
|
"N", # pep8-naming
|
||||||
|
"B", # flake8-ubgbear
|
||||||
|
"ANN", # flake8-annotations
|
||||||
|
"Q", # flake8-quotes
|
||||||
|
"PTH", # flake8-use-pathlib
|
||||||
|
"UP", # pyupgrade,
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.mypy]
|
Loading…
Add table
Reference in a new issue