diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 00000000..0db6cd02 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,20 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Breaking Changes + labels: + - breaking-change + - title: Features + labels: + - feature + - title: Enhancements + labels: + - enhancement + - title: Bug Fixes + labels: + - bug + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/label-checker.yml b/.github/workflows/label-checker.yml index abfc09b3..2bd9019b 100644 --- a/.github/workflows/label-checker.yml +++ b/.github/workflows/label-checker.yml @@ -16,6 +16,6 @@ jobs: steps: - uses: docker://agilepathway/pull-request-label-checker:latest with: - one_of: breaking-change,enhancement,bug,documentation,ignore-for-release + one_of: breaking-change,enhancement,bug,documentation,ignore-for-release,dependencies repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 5f1c27c4..f262b2bf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ This is the git repository for version 2+ of the PIC-SURE API. ## Pre-requisits -* Java 11 +* Java 11 +* Before contributing code, please set up our git hook: + `cp code-formatting/pre-commit.sh .git/hooks/pre-commit` ## Build The build consists of the following top level maven modules: diff --git a/code-formatting/eclipse-formatter.xml b/code-formatting/eclipse-formatter.xml new file mode 100644 index 00000000..e7cfabab --- /dev/null +++ b/code-formatting/eclipse-formatter.xml @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code-formatting/pre-commit.sh b/code-formatting/pre-commit.sh new file mode 100755 index 00000000..ed051d18 --- /dev/null +++ b/code-formatting/pre-commit.sh @@ -0,0 +1,28 @@ +#!/bin/sh -e +CWD=$(pwd) +cd $(git rev-parse --show-toplevel) +format_cmd="" + +# skip if NO_VERIFY env var set +if [ "$NO_VERIFY" ]; then + echo 'code formatting skipped' 1>&2 + exit 0 +fi + +# I'm not great at bash, so this is a bit ugly, but I'll explain each pipe +# 1. Get all staged files +# 2. Reduce to just .java files +# 3. Replace newlines with commas (this was really hard to do in sed) +# 4. Replace commas with $,^.* +# 5. Crop off the last 4 chars +# This results in foo.java$,^.*bar.java$,^.*baz.java$ +# I then append ^.* to the beginning of that. +STAGED_JAVA_FILES_AS_REGEX=$(git diff --staged --name-only --diff-filter=ACMR | grep '.java$' | tr '\n' ',' | sed -e 's/,/$,^.*/g' | sed 's/.\{4\}$//') +FILES_TO_RESTAGE=$(git diff --staged --name-only --diff-filter=ACMR) +if [ -n "$STAGED_JAVA_FILES_AS_REGEX" ]; then + echo "Found the following staged java files to format: $STAGED_JAVA_FILES_AS_REGEX" + mvn spotless:apply -DspotlessFiles=^.*$STAGED_JAVA_FILES_AS_REGEX + git add $FILES_TO_RESTAGE +fi + +cd $CWD \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4283a1e7..d09e1d9d 100644 --- a/pom.xml +++ b/pom.xml @@ -33,10 +33,24 @@ 4.5.13 2.15.1 1.18.30 + 2.41.1 + + com.diffplug.spotless + spotless-maven-plugin + ${spotless.version} + + + + 4.26 + code-formatting/eclipse-formatter.xml + + + + org.apache.maven.plugins maven-compiler-plugin