From 385e19c161d457bc6af17baf1476d114fdb424ff Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:38:12 +0100 Subject: [PATCH 1/8] update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 549e00a..819ddb9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/**/target/ !**/src/test/**/target/ +db/ ### STS ### .apt_generated From acc417be46201a1ea205aa6d83a49df99d476b68 Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:39:11 +0100 Subject: [PATCH 2/8] create ci-cd.yml --> created github actions --- .github/workflows/ci-cd.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ci-cd.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..9aeb552 --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,35 @@ +name: CI/CD Actions + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + name: Unit Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'corretto' + cache: 'maven' + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven- + + - name: Run Tests + run: mvn -B test From 176cc4b5d1e9b050888b27d8621c1466f3947f37 Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:42:36 +0100 Subject: [PATCH 3/8] update ci-cd.yml --- .github/workflows/ci-cd.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9aeb552..859c941 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,20 +12,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'corretto' + distribution: 'temurin' cache: 'maven' - name: Build with Maven run: mvn -B package --file pom.xml - name: Cache local Maven repository - uses: actions/cache@v4 + uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} From af458ac0ed4e189552e2da01f305711111ffaf1a Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:46:18 +0100 Subject: [PATCH 4/8] update ci-cd.yml --- .github/workflows/ci-cd.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 859c941..40aba97 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,10 +1,10 @@ -name: CI/CD Actions +name: CI/CD Pipeline on: push: - branches: [ main ] + branches: [ "main" ] pull_request: - branches: [ main ] + branches: [ "main" ] jobs: test: @@ -24,12 +24,12 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml - - name: Cache local Maven repository + - name: Cache Maven packages uses: actions/cache@v3 with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven- + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 - name: Run Tests run: mvn -B test From b8aed6bac094dc7f7908e5c95cdb6b07eb628cfb Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:47:48 +0100 Subject: [PATCH 5/8] update ci-cd.yml --- .github/workflows/ci-cd.yml | 61 ++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 40aba97..1e75dfd 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,10 +1,10 @@ -name: CI/CD Pipeline +name: CI/CD Actions on: push: - branches: [ "main" ] + branches: [ main ] pull_request: - branches: [ "main" ] + branches: [ main ] jobs: test: @@ -12,24 +12,63 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' - distribution: 'temurin' + distribution: 'corretto' cache: 'maven' - name: Build with Maven run: mvn -B package --file pom.xml - - name: Cache Maven packages - uses: actions/cache@v3 + - name: Cache local Maven repository + uses: actions/cache@v4 with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven- - name: Run Tests run: mvn -B test + + docker: + name: Build and Deploy Spring Boot App + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: 17 + cache: 'maven' + + - name: Cache local Maven repository + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Build App + run: mvn -B package --file pom.xml -DskipTests + + - name: Login to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + dockerfile: Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/stock-management:latest From 24c2dd379921e387e18890a82df3be78ba42f6d6 Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 20:49:52 +0100 Subject: [PATCH 6/8] update ci-cd.yml --- .github/workflows/ci-cd.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 1e75dfd..a5f0162 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v3 with: java-version: '17' distribution: 'corretto' @@ -39,17 +39,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Setup JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v3 with: distribution: 'corretto' java-version: 17 cache: 'maven' - name: Cache local Maven repository - uses: actions/cache@v4 + uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} From 2b48aaa9a19908b6d9fb6ece9959fe62c5d14cdc Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 21:23:14 +0100 Subject: [PATCH 7/8] update ci-cd.yml --- .github/workflows/ci-cd.yml | 39 ------------------------------------- 1 file changed, 39 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a5f0162..b7dbe43 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -33,42 +33,3 @@ jobs: - name: Run Tests run: mvn -B test - - docker: - name: Build and Deploy Spring Boot App - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: 17 - cache: 'maven' - - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Build App - run: mvn -B package --file pom.xml -DskipTests - - - name: Login to Docker Hub - uses: docker/login-action@v4 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: Build and Push - uses: docker/build-push-action@v5 - with: - context: . - dockerfile: Dockerfile - push: true - tags: ${{ secrets.DOCKER_USERNAME }}/stock-management:latest From 834c49722334e12c645100f05fc69da3dea9fd97 Mon Sep 17 00:00:00 2001 From: Mehmet Seymus Yuzen Date: Thu, 28 Mar 2024 21:23:32 +0100 Subject: [PATCH 8/8] update StockTransactionCreateServiceImplTest --- .../impl/StockTransactionCreateServiceImplTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/study/stockmanagementstudycase/service/stock_transaction/impl/StockTransactionCreateServiceImplTest.java b/src/test/java/com/study/stockmanagementstudycase/service/stock_transaction/impl/StockTransactionCreateServiceImplTest.java index 4fffdbc..7bfc3da 100644 --- a/src/test/java/com/study/stockmanagementstudycase/service/stock_transaction/impl/StockTransactionCreateServiceImplTest.java +++ b/src/test/java/com/study/stockmanagementstudycase/service/stock_transaction/impl/StockTransactionCreateServiceImplTest.java @@ -117,7 +117,7 @@ void givenValidParameters_whenCreateStockTransactionForStockEntry_thenReturnStoc .build(); final BigDecimal mockEntryAmount = BigDecimal.TEN; - final LocalDateTime mockEntryTime = LocalDateTime.now(); + final LocalDateTime mockEntryTime = LocalDateTime.now().plusHours(1); // Then final StockTransaction response = stockTransactionCreateService