Skip to content

Commit 0119f5a

Browse files
committed
Changing formatter plugin, add license check, add formatters githooks
Signed-off-by: Ricardo Zanini <[email protected]>
1 parent 9f7b967 commit 0119f5a

File tree

15 files changed

+120
-68
lines changed

15 files changed

+120
-68
lines changed

.githooks/pre-commit

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT="$(git rev-parse --show-toplevel)"
5+
6+
# which Java files are staged?
7+
mapfile -t STAGED_JAVA < <(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.java$' || true)
8+
[ ${#STAGED_JAVA[@]} -eq 0 ] && exit 0
9+
10+
# stash unstaged changes so we don't accidentally commit them
11+
git stash -q --keep-index --include-untracked
12+
13+
# Build regexes for Spotless' -DspotlessFiles (matches absolute paths)
14+
# escape regex metachars, then anchor to ^$ with absolute path
15+
PATTERNS="$(
16+
printf "%s\n" "${STAGED_JAVA[@]}" \
17+
| sed -e 's/[.[\*^$()+?{}|\\]/\\&/g' -e "s|^|^$ROOT/|" -e 's|$|$|' \
18+
| paste -sd, -
19+
)"
20+
21+
# run Spotless just on those files (adds headers + formats)
22+
mvn -q -DskipTests -DspotlessFiles="$PATTERNS" spotless:apply
23+
24+
# re-stage exactly what was staged before
25+
git add -- "${STAGED_JAVA[@]}"
26+
27+
# restore unstaged changes (may conflict if they touch the same lines the formatter changed)
28+
git stash pop -q || true
29+
30+
exit 0

.github/workflows/maven-verify.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
java-version: 17
2626
cache: 'maven'
2727

28+
- name: Check formatting
29+
run: |
30+
make ci
31+
2832
# 3. Verify the main sdk-java project, excluding the two agentic modules
2933
- name: Verify with Maven
3034
run: |

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Makefile
2+
# NOTE: each command line below begins with a literal TAB character.
3+
4+
MVN ?= mvn
5+
MVN_FLAGS ?= -q -DskipTests
6+
7+
.PHONY: help hooks format check verify ci status clean
8+
9+
help:
10+
@echo ""
11+
@echo "Targets:"
12+
@echo " make hooks - Install/enable repo-local git hooks"
13+
@echo " make format - Spotless apply (format + license headers)"
14+
@echo " make check - Spotless check + Checkstyle"
15+
@echo " make verify - mvn verify"
16+
@echo " make ci - CI checks (Spotless + Checkstyle, no tests)"
17+
@echo " make status - Show git hooksPath"
18+
@echo " make clean - mvn clean"
19+
@echo ""
20+
21+
hooks:
22+
@bash scripts/install-git-hooks.sh
23+
@echo "✅ Git hooks ready."
24+
25+
format:
26+
@echo "✨ Formatting (Spotless apply + headers)…"
27+
@$(MVN) $(MVN_FLAGS) spotless:apply
28+
29+
check:
30+
@echo "🔍 Checking format + headers + checkstyle…"
31+
@$(MVN) $(MVN_FLAGS) spotless:check checkstyle:check
32+
33+
verify:
34+
@echo "🧪 Running mvn verify…"
35+
@$(MVN) -B verify
36+
37+
ci:
38+
@echo "🏗️ CI checks (no tests)…"
39+
@$(MVN) -B -DskipTests spotless:check checkstyle:check
40+
41+
status:
42+
@echo -n "hooksPath: "
43+
@git config --get core.hooksPath || echo "(not set)"
44+
45+
clean:
46+
@echo "🧹 Cleaning…"
47+
@$(MVN) -q clean

config/license-header.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright 2020-Present The Serverless Workflow Specification Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/

experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.func;
1817

1918
import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.safeObject;

experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaListenExecutorBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.func;
1817

1918
import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.predObject;

experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaSwitchExecutorBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.executors.func;
1817

1918
import static io.serverlessworkflow.impl.executors.func.JavaFuncUtils.predObject;

fluent/agentic/src/test/java/io/serverlessworkflow/fluent/agentic/WorkflowTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.fluent.agentic;
1817

1918
import static io.serverlessworkflow.fluent.agentic.Agents.*;

generators/types/pom.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,4 @@
1919
</dependency>
2020

2121
</dependencies>
22-
<build>
23-
<plugins>
24-
<plugin>
25-
<groupId>com.spotify.fmt</groupId>
26-
<artifactId>fmt-maven-plugin</artifactId>
27-
<configuration>
28-
<sourceDirectory>src/main/java</sourceDirectory>
29-
<testSourceDirectory>src/test/java</testSourceDirectory>
30-
<verbose>false</verbose>
31-
<filesNamePattern>.*\.java</filesNamePattern>
32-
<skip>false</skip>
33-
<skipSortingImports>false</skipSortingImports>
34-
<style>google</style>
35-
</configuration>
36-
<executions>
37-
<execution>
38-
<goals>
39-
<goal>format</goal>
40-
</goals>
41-
</execution>
42-
</executions>
43-
</plugin>
44-
</plugins>
45-
</build>
4622
</project>

impl/core/src/main/java/io/serverlessworkflow/impl/events/TypeEventRegistration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package io.serverlessworkflow.impl.events;
1817

1918
import io.cloudevents.CloudEvent;

0 commit comments

Comments
 (0)