Skip to content

Commit

Permalink
add format check
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Jun 27, 2024
1 parent 54f23b4 commit 33870e2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/Java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ env:
OVERRIDE_GIT_DESCRIBE: ${{ inputs.override_git_describe }}

jobs:
format_check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.git_ref }}

- run: make format-check

java-linux-amd64:
name: Java Linux (amd64)
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ release:
format:
python3 scripts/format.py

format-check:
python3 scripts/format.py --check

clean:
rm -rf build
11 changes: 10 additions & 1 deletion scripts/format.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
from subprocess import check_call
from os import scandir
from glob import glob
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument('--check', action='store_true')
args = parser.parse_args()

template = ['clang-format', '-i']
if args.check:
template += ['--dry-run', '--Werror']

for name in ['src/jni/duckdb_java.cpp'] + glob('src/**/*.java', recursive=True):
print('Formatting', name)
check_call(['clang-format', '-i', name])
check_call(template + [name])

0 comments on commit 33870e2

Please sign in to comment.