diff --git a/.github/workflows/formatter.yaml b/.github/workflows/formatter.yaml new file mode 100644 index 0000000..a2607e6 --- /dev/null +++ b/.github/workflows/formatter.yaml @@ -0,0 +1,32 @@ +name: Check formatting + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + formatter: + name: Check formatting of Python, C++, and Bazel files. + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build wheel + shell: bash + run: | + bazelisk run //:bazel_formatter + bazelisk run //:python_formatter + bazelisk run //:clang_formatter + + - name: Check if any files have changed + id: changes + uses: UnicornGlobal/has-changes-action@v1 + + - name: Error if code has not been formatted + if: steps.changes.outputs.changed == 1 + run: | + echo "Code has not been formatted. Please run the formatters as described by the README." + return 1 \ No newline at end of file