diff --git a/.github/workflows/build-server.yml b/.github/workflows/build-server.yml index 21796181f..94f42533d 100644 --- a/.github/workflows/build-server.yml +++ b/.github/workflows/build-server.yml @@ -9,6 +9,8 @@ jobs: steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up JDK 15 uses: actions/setup-java@v1 with: diff --git a/README.md b/README.md index 0ad051dcf..462c3af0d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # BlockCOVID-server Modulo Server per il progetto di SWE 2020/2021 - BlockCOVID +## Pre-Commit +Eseguire il seguente comando per salvare il git hook: +``` bash +ln -s pre-commit.sh .git/hooks/pre-commit +``` + ## Come usare mongo Sono inclusi degli script per utilizzare mongo per testare come si comporta: - **Avvio**: `./spawnMongo.sh`, spawna un'istanza di `mongod` che lavora sulla cartella locale `./db` e raccoglie i log nel file `log`. Fallisce se ci sono altre istanze giĆ  attive. diff --git a/build.gradle b/build.gradle index 039b29ab6..43bdbfee4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'com.diffplug.spotless' version '5.6.1' id 'org.springframework.boot' version '2.4.2' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' @@ -30,3 +31,15 @@ dependencies { test { useJUnitPlatform() } + +spotless { + ratchetFrom 'origin/develop' + java { + toggleOffOn() + + importOrder() + removeUnusedImports() + + googleJavaFormat() + } +} diff --git a/pre-commit.sh b/pre-commit.sh new file mode 100755 index 000000000..8e5403ac6 --- /dev/null +++ b/pre-commit.sh @@ -0,0 +1,8 @@ +#!/bin/bash +RED='\033[1;31m' +NC='\033[0m' +if !(./gradlew spotlessCheck) >/dev/null 2>&1 +then + echo "${RED}Spotless error:${NC} please run './gradlew spotlessApply'" 1>&2 + exit 1 +fi