diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 000000000..a6ef14289 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,50 @@ +name: Black autoformat + +on: + push: + branches: + - "**" + paths: + - "ultraplot/**.py" + - "ultraplot/**.pyi" + - ".github/workflows/black.yml" + - ".pre-commit-config.yaml" + - "pyproject.toml" + +permissions: + contents: write + +concurrency: + group: black-${{ github.ref }} + cancel-in-progress: false + +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.ref_name }} + + - uses: actions/setup-python@v7 + with: + python-version: "3.14" + + - name: Install Black + run: python -m pip install black==26.5.1 + + - name: Format Python files + run: black ultraplot + + - name: Commit formatting changes + run: | + if git diff --quiet -- '*.py' '*.pyi'; then + echo "Black made no changes." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add --update -- '*.py' '*.pyi' + git commit -m "Apply Black formatting" + git push diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8daf1d1a2..0dfc57479 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: autofix_prs: false autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: monthly - skip: [] + skip: [black] submodules: false repos: