ci: Trigger black on python file changes only + autocommit (#139)

Co-authored-by: haidaraM <haidaraM@users.noreply.github.com>
This commit is contained in:
Mohamed El Mouctar Haidara 2023-04-12 16:43:44 +02:00 committed by GitHub
parent 68e137e762
commit 84d759d70c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 3 deletions

View file

@ -4,15 +4,32 @@ on:
push:
branches:
- main
paths:
- '**.py'
pull_request:
branches:
- main
paths:
- '**.py'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --diff --color"
version: "~= 23.0" # https://black.readthedocs.io/en/stable/integrations/github_actions.html
options: ""
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Autoformat code using black

View file

@ -202,6 +202,10 @@ The graphs are generated in the folder `tests/generated-svgs`. They are also gen
in [Github Actions](https://github.com/haidaraM/ansible-playbook-grapher/actions). Feel free to look at them when
submitting PRs.
### Lint and format
The project uses black to format the code. Run `black .` to format.
## License
GNU General Public License v3.0 or later (Same as Ansible)

View file

@ -45,7 +45,6 @@ OPEN_PROTOCOL_HANDLERS = {
class Grapher:
def __init__(self, playbook_filenames: List[str]):
"""
:param playbook_filenames: List of playbooks to graph
"""
self.playbook_filenames = playbook_filenames

View file

@ -2,3 +2,4 @@
pytest==7.1.3
pytest-cov==4.0.0
pyquery==2.0.0
black~=23.0

View file

@ -43,7 +43,6 @@ def test_get_all_tasks_nodes():
:return:
"""
play = PlayNode("play")
role_1 = RoleNode("my_role_1")
play.add_node("roles", role_1)