Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@ jobs:
distribution: 'temurin'
java-version: '25'

- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d

- name: Build with Gradle
run: ./gradlew clean build
Expand Down Expand Up @@ -56,15 +66,6 @@ jobs:
name: build-artifact
path: build/libs

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Generate version tag
id: version
run: |
Expand All @@ -80,13 +81,17 @@ jobs:
echo "tag=$VERSION_TAG" >> $GITHUB_OUTPUT
echo "Generated version tag: $VERSION_TAG"

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.DOCKERHUB_USERNAME }}/devoops-backend-poc:${{ steps.version.outputs.tag }}
${{ env.DOCKERHUB_USERNAME }}/devoops-backend-poc:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push Docker image with Kaniko
run: |
mkdir -p /tmp/kaniko/.docker
echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$(echo -n ${{ env.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }} | base64)\"}}}" > /tmp/kaniko/.docker/config.json
docker run \
-v ${{ github.workspace }}:/workspace \
-v /tmp/kaniko/.docker:/kaniko/.docker \
gcr.io/kaniko-project/executor:latest \
--context=/workspace \
--dockerfile=/workspace/Dockerfile \
--destination=${{ env.DOCKERHUB_USERNAME }}/devoops-backend-poc:${{ steps.version.outputs.tag }} \
--destination=${{ env.DOCKERHUB_USERNAME }}/devoops-backend-poc:latest \
--cache=true \
--cache-repo=${{ env.DOCKERHUB_USERNAME }}/devoops-backend-poc-cache
62 changes: 60 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,66 @@ jobs:
distribution: 'temurin'
java-version: '25'

- name: Cache Gradle dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@0b6dd653ba04f4f93bf581ec31e66cbd7dcb644d

- name: Build with Gradle
run: ./gradlew clean build
run: ./gradlew clean build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: |
build/classes
build/libs
build/test-results
retention-days: 1

sonarcloud:
name: SonarCloud Analysis
needs: build-and-test
runs-on: ubuntu-latest

steps:
- name: Checkout code (full history for PR analysis)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 25
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '25'

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifact
path: build

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: >
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
-Dsonar.sources=.
-Dsonar.java.binaries=build/classes/java/main
-Dsonar.java.test.binaries=build/classes/java/test
-Dsonar.junit.reportPaths=build/test-results/test
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,3 @@ out/

### Mac ###
.DS_Store

### Environment variables ###
*.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ public String test() {
MDC.remove("requestId");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void contextLoads() {

@Test
void notFailingTest() {
System.out.println( "Not failing test");
System.out.println( "Not failing test for sure, (Misa Rus)");
}

}