From 9777145ec8e4cf02fef691f27f1b0fb874e60e37 Mon Sep 17 00:00:00 2001 From: SVAdithya Date: Thu, 18 Jul 2024 01:08:02 +0530 Subject: [PATCH] checks error fix --- .github/workflows/main.yml | 55 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a509cb4..1660c67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: SonarQube Scan +name: Build on: push: @@ -9,32 +9,33 @@ on: - '**' jobs: - sonarQube: + build: + name: Build and analyze runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up JDK 22 - uses: actions/setup-java@v2 - with: - java-version: '22' - - - name: Cache SonarQube packages - uses: actions/cache@v2 - with: - path: ~/.sonar/cache - key: ${{ runner.os }}-sonar-cache - restore-keys: | - ${{ runner.os }}-sonar-cache - - - name: SonarQube Scan - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar -Dsonar.projectKey= -Dsonar.host.url= -Dsonar.login=${{ secrets.SONAR_TOKEN }} - - - name: Upload SonarQube results - if: always() - run: | - echo "Uploading SonarQube results" + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 22 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' # or 'adopt', depending on your preference + java-version: '22' + - name: Cache SonarQube packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=com.kafka.learn:kafkaStudy -Dsonar.projectName='KafkaStudy'