From f008b9b850cdae325758c04e37938e208e163485 Mon Sep 17 00:00:00 2001 From: kristijanjakimov Date: Tue, 15 Oct 2024 11:16:15 +0200 Subject: [PATCH 1/3] Workflow added --- .github/workflows/build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ab38623 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,12 @@ +on: push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: "22" + distribution: "temurin" + cache: 'maven' + - run: mvn package --batch-mode \ No newline at end of file From 36877f6efea993b7a53a3ffbd97ebac0d9a134ee Mon Sep 17 00:00:00 2001 From: kristijanjakimov Date: Tue, 15 Oct 2024 11:34:12 +0200 Subject: [PATCH 2/3] SonarCloud added --- .github/workflows/backend.yml | 38 ++++++++++++++++++++++++++++++++++ .github/workflows/frontend.yml | 20 ++++++++++++++++++ backend/lombok.config | 4 ++++ backend/pom.xml | 25 ++++++++++++++++++++++ sonar-project.properties | 13 ++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 .github/workflows/backend.yml create mode 100644 .github/workflows/frontend.yml create mode 100644 backend/lombok.config create mode 100644 sonar-project.properties diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..56db6c0 --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,38 @@ +name: SonarCloudBackend +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build and analyze + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: 'zulu' # Alternative distribution options are available. + - name: Cache SonarCloud packages + uses: actions/cache@v4 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=neuefische_java-coffee-beans-teamproject-2_backend --file backend/pom.xml \ No newline at end of file diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000..26d6410 --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,20 @@ +name: SonarCloudFrontend +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/backend/lombok.config b/backend/lombok.config new file mode 100644 index 0000000..78a6ce5 --- /dev/null +++ b/backend/lombok.config @@ -0,0 +1,4 @@ +# Define that this is the root directory and that Lombok shouldn't search parent directories for more configuration files +config.stopBubbling=true +# Let Lombok add @lombok.Generated annotation to all generated methods +lombok.addLombokGeneratedAnnotation=true \ No newline at end of file diff --git a/backend/pom.xml b/backend/pom.xml index c399b1b..160c112 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -28,6 +28,8 @@ 21 + neuefische + https://sonarcloud.io @@ -49,6 +51,10 @@ + + maven-surefire-plugin + 3.1.2 + org.springframework.boot spring-boot-maven-plugin @@ -61,6 +67,25 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.12 + + + + prepare-agent + + + + report + test + + report + + + + diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..9bc3909 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=neuefische_java-coffee-beans-teamproject-2_frontend +sonar.organization=neuefische + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=neuefische_java-coffee-beans-teamproject-2_frontend +#sonar.projectVersion=1.0 + + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=./frontend/src + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 \ No newline at end of file From a7992968eb27d9ead0e52f70d6dadf70ff97dc96 Mon Sep 17 00:00:00 2001 From: kristijanjakimov Date: Tue, 15 Oct 2024 11:38:39 +0200 Subject: [PATCH 3/3] build.yml updated --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab38623..83ce110 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,4 +9,4 @@ jobs: java-version: "22" distribution: "temurin" cache: 'maven' - - run: mvn package --batch-mode \ No newline at end of file + - run: mvn -B package --file backend/pom.xml \ No newline at end of file