[llvm] Add GitHub workflow for check Python file formatting (PR #65482)

Tobias Hieta via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 07:02:52 PDT 2023


https://github.com/tru created https://github.com/llvm/llvm-project/pull/65482:

Using darker which is doing black on diffs, similar to git-clang-format.

>From a4f4dcea05bd9498287d1acfe1f7ee646d4b6275 Mon Sep 17 00:00:00 2001
From: Tobias Hieta <tobias at hieta.se>
Date: Tue, 5 Sep 2023 16:29:38 +0200
Subject: [PATCH] Add GitHub workflow for check Python file formatting

Using darker which is doing black on diffs, similar to
git-clang-format.
---
 .github/workflows/pr-python-format.yml | 39 ++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 .github/workflows/pr-python-format.yml

diff --git a/.github/workflows/pr-python-format.yml b/.github/workflows/pr-python-format.yml
new file mode 100644
index 000000000000000..c6122958826545c
--- /dev/null
+++ b/.github/workflows/pr-python-format.yml
@@ -0,0 +1,39 @@
+name: "Check Python Formatting"
+on:
+  pull_request:
+    # run on .py
+    paths:
+      - '**.py'
+
+jobs:
+  python_formatting:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Fetch LLVM sources
+        uses: actions/checkout at v4
+        with:
+          persist-credentials: false
+          fetch-depth: 2
+
+      - name: Get changed files
+        id: changed-files
+        uses: tj-actions/changed-files at v39
+        with:
+          files: '**/*.py'
+
+      - name: "Listed files"
+        run: |
+          echo "Formatting files:"
+          echo "${{ steps.changed-files.outputs.all_changed_files }}"
+
+      - name: Setup Python env
+        uses: actions/setup-python at v4
+        with:
+          python-version: '3.11'
+
+      - name: Python Formatting
+        uses: akaihola/darker at 1.7.2
+        with:
+          options: "--check --diff --color"
+          version: "~=1.7.2"
+          src: "${{ steps.changed-files.outputs.all_changed_files }}"



More information about the llvm-commits mailing list