Skip to content

Commit fb2af07

Browse files
authored
PR AutoFixing via GHA (#600)
auto commit changelog and black formatting fixes
1 parent 151ed82 commit fb2af07

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

.github/workflows/test.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
concurrency:
3+
group: ${{ github.head_ref }}
4+
cancel-in-progress: true
5+
6+
on:
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- labeled
12+
- unlabeled
13+
- synchronize
14+
branches:
15+
- main
16+
- stable-*
17+
tags:
18+
- '*'
19+
20+
jobs:
21+
auto_changelog:
22+
name: changelog / black formatting
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout the collection repository
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: "0"
29+
30+
- name: Set up Python '3.9'
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.9'
34+
35+
# black should be defined as input parameter of the action
36+
- name: Install python dependencies
37+
run: |
38+
pip install -U pyyaml pygithub tox
39+
shell: bash
40+
41+
- name: Download script
42+
run: >-
43+
curl -o /tmp/add_changelog.py
44+
https://raw.githubusercontent.com/abikouo/gha_testing/main/tools/add_changelog.py
45+
46+
- name: Validate or add pull request changelog
47+
run:
48+
python3 /tmp/add_changelog.py
49+
env:
50+
PR_REPOSITORY: ${{ github.repository }}
51+
PR_NUMBER: ${{ github.event.pull_request.number }}
52+
53+
- name: Run black check
54+
id: black_check
55+
continue-on-error: true
56+
run: |
57+
tox -e black -vv 2>/tmp/black_check.txt
58+
shell: bash
59+
60+
- name: Run black formatting
61+
run: |
62+
tox -e black_format -vv -- $(grep "would reformat" /tmp/black_check.txt | cut -d ' ' -f3 | tr '\n' ' ')
63+
shell: bash
64+
if: steps.black_check.outcome != 'success'
65+
66+
- name: (debug only) list files in diff
67+
run: |
68+
git status
69+
shell: bash
70+
if: steps.black_check.outcome != 'success'
71+
72+
- name: commit and push changes
73+
id: commit
74+
uses: stefanzweifel/git-auto-commit-action@v4
75+
with:
76+
commit_message: "automated changes for changelog and/or black formatting"

tox.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@ deps =
2626
commands =
2727
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
2828

29+
[testenv:black_format]
30+
deps =
31+
{[testenv:black]deps}
32+
33+
commands =
34+
black -v {posargs}
35+
2936
[testenv:linters]
3037
deps =
3138
yamllint
3239
flake8
3340
{[testenv:black]deps}
3441

3542
commands =
36-
black -v --check --diff {toxinidir}/plugins {toxinidir}/tests
43+
{[testenv:black]commands}
3744
yamllint -s {toxinidir}
3845
flake8 {toxinidir}

0 commit comments

Comments
 (0)