Skip to content

Commit 6c314ea

Browse files
committed
Add pre-commit config and GitHub action to enforce its checks
1 parent 0348589 commit 6c314ea

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,36 @@ jobs:
3131
run: echo "maven_bundle_url=$(./scripts/maven-bundle-url.sh | tail -n 1)" >> $GITHUB_OUTPUT
3232
shell: bash
3333

34+
pre_commit:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
40+
- name: Setup Java 21
41+
id: java21
42+
uses: actions/setup-java@v4
43+
with:
44+
distribution: temurin
45+
java-version: 21
46+
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.11'
51+
52+
- name: Install pre-commit
53+
run: python -m pip install --upgrade pip pre-commit
54+
shell: bash
55+
56+
- name: run pre-commit
57+
run: pre-commit run --all-files
58+
shell: bash
59+
3460
build:
3561
runs-on: ${{ matrix.os }}
36-
needs: maven_bundle_url
62+
# pre_commit not needed, but is in 'needs' to avoid wasting CI cycles in case it doesn't pass
63+
needs: [maven_bundle_url, pre_commit]
3764
strategy:
3865
matrix:
3966
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -207,4 +234,4 @@ jobs:
207234

208235
- name: Run Maven tests
209236
run: mvn --batch-mode -s settings.xml -Dgradle.java.home=$GRADLE_JAVA_HOME ${{ matrix.maven_args }}
210-
shell: bash
237+
shell: bash

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-xml
10+
- id: check-executables-have-shebangs
11+
- id: check-shebang-scripts-are-executable
12+
- id: check-symlinks
13+
- id: mixed-line-ending
14+
args: ['--fix=no']
15+
- repo: local
16+
hooks:
17+
- id: maven-validate-spotless
18+
name: Maven validate & spotless:apply
19+
entry: ./mvnw
20+
args: ['validate', 'spotless:apply']
21+
language: system
22+
pass_filenames: false

0 commit comments

Comments
 (0)