From 64ccc48493cda95987dc81fc64c44334fb033eff Mon Sep 17 00:00:00 2001 From: Murilo Kakazu Date: Tue, 30 Apr 2024 21:55:51 -0300 Subject: [PATCH] build: add ci workflow --- .github/workflows/ci.yaml | 42 +++++++++++++++++++ build.gradle | 18 ++++++++ .../grupo30/fastfood/FastfoodApplication.java | 7 ++-- .../fastfood/FastfoodApplicationTests.java | 6 +-- 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a794e24 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: 'zulu' + + - name: Cache Gradle packages + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Code linting + run: ./gradlew spotlessCheck + + - name: Build + run: ./gradlew clean build + + - name: Run tests + run: ./gradlew test diff --git a/build.gradle b/build.gradle index 9805106..3bfe9ab 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.2.5' id 'io.spring.dependency-management' version '1.1.4' + id 'com.diffplug.spotless' version '6.25.0' } group = 'br.com.fiap.grupo30' @@ -17,6 +18,23 @@ configurations { } } +spotless { + format 'misc', { + // define the files to apply `misc` to + target '*.gradle', '.gitattributes', '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithTabs() // or spaces. Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + googleJavaFormat('1.22.0').aosp().reflowLongStrings().skipJavadocFormatting() + formatAnnotations() + target 'src/main/**/*.java', 'src/test/**/*.java' + } +} + repositories { mavenCentral() } diff --git a/src/main/java/br/com/fiap/grupo30/fastfood/FastfoodApplication.java b/src/main/java/br/com/fiap/grupo30/fastfood/FastfoodApplication.java index 8e62359..dbba8e1 100644 --- a/src/main/java/br/com/fiap/grupo30/fastfood/FastfoodApplication.java +++ b/src/main/java/br/com/fiap/grupo30/fastfood/FastfoodApplication.java @@ -6,8 +6,7 @@ @SpringBootApplication public class FastfoodApplication { - public static void main(String[] args) { - SpringApplication.run(FastfoodApplication.class, args); - } - + public static void main(String[] args) { + SpringApplication.run(FastfoodApplication.class, args); + } } diff --git a/src/test/java/br/com/fiap/grupo30/fastfood/FastfoodApplicationTests.java b/src/test/java/br/com/fiap/grupo30/fastfood/FastfoodApplicationTests.java index 9d11b9b..460f0f3 100644 --- a/src/test/java/br/com/fiap/grupo30/fastfood/FastfoodApplicationTests.java +++ b/src/test/java/br/com/fiap/grupo30/fastfood/FastfoodApplicationTests.java @@ -6,8 +6,6 @@ @SpringBootTest class FastfoodApplicationTests { - @Test - void contextLoads() { - } - + @Test + void contextLoads() {} }