From 9e196b1898e99a6b8999616d540431930603ec8d Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 08:29:43 -0300 Subject: [PATCH 01/21] Add ci --- .github/workflows/ci.yaml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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..25d9944 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,36 @@ +name: Continuous Integration + +on: + push: + # pull_request: + # types: [opened, reopened] + # branches: "feature/**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Unit tests + run: mvn test + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push to Registry + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:latest From 8c74e0f2f776f347c9365bdbc46681a3ce51e890 Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 08:45:27 -0300 Subject: [PATCH 02/21] CD --- .github/workflows/cd.yaml | 46 +++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yaml | 20 ++++------------- 2 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/cd.yaml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..3c3658a --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,46 @@ +name: Continuous Deployment +on: + push: + branches: "develop" +env: + IMAGE_NAME: simple-api-java + AZURE_WEBAPP_NAME: simple-api-java + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push to Registry + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + + # deploy: + # runs-on: ubuntu-latest + # needs: build + # steps: + # - + # name: Deploy to Azure Web App + # id: deploy-to-webapp + # uses: azure/webapps-deploy@v2 + # with: + # app-name: ${{ env.AZURE_WEBAPP_NAME }} + # publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + # images: 'ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest' \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 25d9944..b4b2c9f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,10 +1,9 @@ name: Continuous Integration -on: - push: - # pull_request: - # types: [opened, reopened] - # branches: "feature/**" +on: + pull_request: + types: [opened, reopened] + branches: "feature/**" jobs: build: @@ -23,14 +22,3 @@ jobs: - name: Unit tests run: mvn test - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push to Registry - uses: docker/build-push-action@v6 - with: - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:latest From e09f4a43f55fbdb980558b8e691462f7c05629be Mon Sep 17 00:00:00 2001 From: Antonio Carlos de Lima Junior Date: Fri, 30 Aug 2024 08:55:40 -0300 Subject: [PATCH 03/21] Add or update the App Service deployment workflow configuration from Azure Portal. --- .../workflows/develop_simple-api-java-dev.yml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/develop_simple-api-java-dev.yml diff --git a/.github/workflows/develop_simple-api-java-dev.yml b/.github/workflows/develop_simple-api-java-dev.yml new file mode 100644 index 0000000..ed7e93c --- /dev/null +++ b/.github/workflows/develop_simple-api-java-dev.yml @@ -0,0 +1,51 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy container app to Azure Web App - simple-api-java-dev + +on: + push: + branches: + - develop + workflow_dispatch: + +jobs: + build: + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: https://index.docker.io/v1/ + username: ${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }} + password: ${{ secrets.AzureAppService_ContainerPassword_7c8cea40d0d4422abbaeb449769a9f8d }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v3 + with: + push: true + tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }}/simple-api-java:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'simple-api-java-dev' + slot-name: 'production' + publish-profile: ${{ secrets.AzureAppService_PublishProfile_a685135380f841ec9979b9679ecbd2b8 }} + images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }}/simple-api-java:${{ github.sha }}' \ No newline at end of file From a97bedf02481f674b4fe7029355c50ec6abb9571 Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 08:56:46 -0300 Subject: [PATCH 04/21] Remove CD --- .github/workflows/cd.yaml | 84 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 3c3658a..3fd2d04 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -1,46 +1,46 @@ -name: Continuous Deployment -on: - push: - branches: "develop" -env: - IMAGE_NAME: simple-api-java - AZURE_WEBAPP_NAME: simple-api-java - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: Git Checkout - uses: actions/checkout@v4 +# name: Continuous Deployment +# on: +# push: +# branches: "develop" +# env: +# IMAGE_NAME: simple-api-java +# AZURE_WEBAPP_NAME: simple-api-java-dev + +# jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - +# name: Git Checkout +# uses: actions/checkout@v4 - - name: Setup Java SDK - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' +# - name: Setup Java SDK +# uses: actions/setup-java@v4 +# with: +# distribution: 'temurin' +# java-version: '21' - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} +# - name: Login to Docker Hub +# uses: docker/login-action@v3 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Push to Registry - uses: docker/build-push-action@v6 - with: - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest +# - name: Push to Registry +# uses: docker/build-push-action@v6 +# with: +# push: true +# tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest - # deploy: - # runs-on: ubuntu-latest - # needs: build - # steps: - # - - # name: Deploy to Azure Web App - # id: deploy-to-webapp - # uses: azure/webapps-deploy@v2 - # with: - # app-name: ${{ env.AZURE_WEBAPP_NAME }} - # publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} - # images: 'ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest' \ No newline at end of file +# deploy: +# runs-on: ubuntu-latest +# needs: build +# steps: +# - +# name: Deploy to Azure Web App +# id: deploy-to-webapp +# uses: azure/webapps-deploy@v2 +# with: +# app-name: ${{ env.AZURE_WEBAPP_NAME }} +# publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} +# images: 'ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest' \ No newline at end of file From 1a06083f32c091a15db701b8c36798574e3bfd47 Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 09:02:53 -0300 Subject: [PATCH 05/21] CD --- .github/workflows/develop_simple-api-java-dev.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/develop_simple-api-java-dev.yml b/.github/workflows/develop_simple-api-java-dev.yml index ed7e93c..383d817 100644 --- a/.github/workflows/develop_simple-api-java-dev.yml +++ b/.github/workflows/develop_simple-api-java-dev.yml @@ -1,12 +1,11 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions -name: Build and deploy container app to Azure Web App - simple-api-java-dev +name: Continuous Deployment on: push: branches: - develop + workflow_dispatch: jobs: @@ -23,14 +22,14 @@ jobs: uses: docker/login-action@v2 with: registry: https://index.docker.io/v1/ - username: ${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }} - password: ${{ secrets.AzureAppService_ContainerPassword_7c8cea40d0d4422abbaeb449769a9f8d }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push container image to registry uses: docker/build-push-action@v3 with: push: true - tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }}/simple-api-java:${{ github.sha }} + tags: index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }} file: ./Dockerfile deploy: @@ -48,4 +47,4 @@ jobs: app-name: 'simple-api-java-dev' slot-name: 'production' publish-profile: ${{ secrets.AzureAppService_PublishProfile_a685135380f841ec9979b9679ecbd2b8 }} - images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_0db90b21033c40f9866332ebed68111e }}/simple-api-java:${{ github.sha }}' \ No newline at end of file + images: 'index.docker.io/${{ secrets.ADOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file From 40e27149076ccbb65c8cd5e8a3576ad2673a7a74 Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 09:14:17 -0300 Subject: [PATCH 06/21] Continuous Deployment --- .github/workflows/develop_simple-api-java-dev.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/develop_simple-api-java-dev.yml b/.github/workflows/develop_simple-api-java-dev.yml index 383d817..e975436 100644 --- a/.github/workflows/develop_simple-api-java-dev.yml +++ b/.github/workflows/develop_simple-api-java-dev.yml @@ -5,7 +5,6 @@ on: push: branches: - develop - workflow_dispatch: jobs: @@ -46,5 +45,5 @@ jobs: with: app-name: 'simple-api-java-dev' slot-name: 'production' - publish-profile: ${{ secrets.AzureAppService_PublishProfile_a685135380f841ec9979b9679ecbd2b8 }} - images: 'index.docker.io/${{ secrets.ADOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file + publish-profile: ${{ secrets.AZURE_PROFILE }} + images: 'index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file From 750093a6d93fb9d0d27fffabbef666950b7e3625 Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 09:29:56 -0300 Subject: [PATCH 07/21] Continuos --- .github/workflows/cd.yaml | 46 ------------------- ...java-dev.yml => continuous_deployment.yml} | 0 .../{ci.yaml => continuous_integration.yaml} | 0 3 files changed, 46 deletions(-) delete mode 100644 .github/workflows/cd.yaml rename .github/workflows/{develop_simple-api-java-dev.yml => continuous_deployment.yml} (100%) rename .github/workflows/{ci.yaml => continuous_integration.yaml} (100%) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml deleted file mode 100644 index 3fd2d04..0000000 --- a/.github/workflows/cd.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# name: Continuous Deployment -# on: -# push: -# branches: "develop" -# env: -# IMAGE_NAME: simple-api-java -# AZURE_WEBAPP_NAME: simple-api-java-dev - -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - -# name: Git Checkout -# uses: actions/checkout@v4 - -# - name: Setup Java SDK -# uses: actions/setup-java@v4 -# with: -# distribution: 'temurin' -# java-version: '21' - -# - name: Login to Docker Hub -# uses: docker/login-action@v3 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} - -# - name: Push to Registry -# uses: docker/build-push-action@v6 -# with: -# push: true -# tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest - -# deploy: -# runs-on: ubuntu-latest -# needs: build -# steps: -# - -# name: Deploy to Azure Web App -# id: deploy-to-webapp -# uses: azure/webapps-deploy@v2 -# with: -# app-name: ${{ env.AZURE_WEBAPP_NAME }} -# publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} -# images: 'ghcr.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest' \ No newline at end of file diff --git a/.github/workflows/develop_simple-api-java-dev.yml b/.github/workflows/continuous_deployment.yml similarity index 100% rename from .github/workflows/develop_simple-api-java-dev.yml rename to .github/workflows/continuous_deployment.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/continuous_integration.yaml similarity index 100% rename from .github/workflows/ci.yaml rename to .github/workflows/continuous_integration.yaml From 66615e967075634d18a68328b63cc7dbd9d490ea Mon Sep 17 00:00:00 2001 From: AC Date: Fri, 30 Aug 2024 09:47:11 -0300 Subject: [PATCH 08/21] Remove workflows --- .github/workflows/continuous_deployment.yml | 49 ------------------- .github/workflows/continuous_integration.yaml | 24 --------- 2 files changed, 73 deletions(-) delete mode 100644 .github/workflows/continuous_deployment.yml delete mode 100644 .github/workflows/continuous_integration.yaml diff --git a/.github/workflows/continuous_deployment.yml b/.github/workflows/continuous_deployment.yml deleted file mode 100644 index e975436..0000000 --- a/.github/workflows/continuous_deployment.yml +++ /dev/null @@ -1,49 +0,0 @@ - -name: Continuous Deployment - -on: - push: - branches: - - develop - workflow_dispatch: - -jobs: - build: - runs-on: 'ubuntu-latest' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to registry - uses: docker/login-action@v2 - with: - registry: https://index.docker.io/v1/ - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push container image to registry - uses: docker/build-push-action@v3 - with: - push: true - tags: index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }} - file: ./Dockerfile - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'simple-api-java-dev' - slot-name: 'production' - publish-profile: ${{ secrets.AZURE_PROFILE }} - images: 'index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file diff --git a/.github/workflows/continuous_integration.yaml b/.github/workflows/continuous_integration.yaml deleted file mode 100644 index b4b2c9f..0000000 --- a/.github/workflows/continuous_integration.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Continuous Integration - -on: - pull_request: - types: [opened, reopened] - branches: "feature/**" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Java SDK - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - - name: Unit tests - run: mvn test - From 6a03397d949ce87243b10c6e41b6063b344b1732 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 15:05:43 -0300 Subject: [PATCH 09/21] Adicionando workflow de CI --- .../workflows/continuous_integrations.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/continuous_integrations.yaml diff --git a/.github/workflows/continuous_integrations.yaml b/.github/workflows/continuous_integrations.yaml new file mode 100644 index 0000000..7410c72 --- /dev/null +++ b/.github/workflows/continuous_integrations.yaml @@ -0,0 +1,23 @@ +name: Continuous Integration + +on: + pull_request: + types: [opened, reopened] + branches: "feature/**" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Unit tests + run: mvn test \ No newline at end of file From 4deeef20ec473a10760bb75ca13781acd3306a0f Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 15:08:49 -0300 Subject: [PATCH 10/21] Adicionando workflow de CI --- .github/workflows/continuous_integrations.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous_integrations.yaml b/.github/workflows/continuous_integrations.yaml index 7410c72..a1369e6 100644 --- a/.github/workflows/continuous_integrations.yaml +++ b/.github/workflows/continuous_integrations.yaml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: Continuous Integration FIAP on: pull_request: From e94f41e1d9474190b03d6dc09b43142c8b6f2bf5 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 15:47:19 -0300 Subject: [PATCH 11/21] Add continuous integrations --- .github/workflows/continuous_integrations.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continuous_integrations.yaml b/.github/workflows/continuous_integrations.yaml index a1369e6..be5ad53 100644 --- a/.github/workflows/continuous_integrations.yaml +++ b/.github/workflows/continuous_integrations.yaml @@ -1,23 +1,23 @@ name: Continuous Integration FIAP -on: - pull_request: - types: [opened, reopened] - branches: "feature/**" +on: + pull_request: + types: [opened, reopened] + branches: "feature/**" jobs: build: runs-on: ubuntu-latest steps: - - - name: Git Checkout + + - name: Git Checkout uses: actions/checkout@v4 - + - name: Setup Java SDK uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' - + - name: Unit tests run: mvn test \ No newline at end of file From 9961b2ec65630e011a6e973808fe36cc04781126 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:04:23 -0300 Subject: [PATCH 12/21] Adicionando CI --- ...tinuous_integrations.yaml => continuous_integration.yaml} | 5 ++--- .../simple_api_java/controller/ProdutoControllerTest.java | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) rename .github/workflows/{continuous_integrations.yaml => continuous_integration.yaml} (86%) diff --git a/.github/workflows/continuous_integrations.yaml b/.github/workflows/continuous_integration.yaml similarity index 86% rename from .github/workflows/continuous_integrations.yaml rename to .github/workflows/continuous_integration.yaml index be5ad53..4f4ae0b 100644 --- a/.github/workflows/continuous_integrations.yaml +++ b/.github/workflows/continuous_integration.yaml @@ -2,14 +2,13 @@ name: Continuous Integration FIAP on: pull_request: - types: [opened, reopened] - branches: "feature/**" + branches: + - develop jobs: build: runs-on: ubuntu-latest steps: - - name: Git Checkout uses: actions/checkout@v4 diff --git a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java index 3c23c4a..72a0d1b 100644 --- a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java +++ b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java @@ -1,5 +1,6 @@ package com.github.fiap.simple_api_java.controller; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @@ -56,7 +57,7 @@ void testGivenNewProduto_whenCreate_thenSavedProduto() throws Exception{ @DisplayName("test fail") @Test void testGivenNewProduto_whenCreate_thenFail() throws Exception{ - // fail("Uma falha forçada"); + // fail("Uma nova falha"); } } From 40688fee1b211465fe7c86c9597d22ea4aa2fd4a Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:07:21 -0300 Subject: [PATCH 13/21] Update docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a75f17c..541f35a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Aplicação API docker compose up --build ``` -## Testes unitários +## Testes unitários (validação) ./mvnw test From 36b29078fabe03a4ab7bb8d8671edb4f4e9094e7 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:11:15 -0300 Subject: [PATCH 14/21] =?UTF-8?q?C=C3=B3digo=20com=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fiap/simple_api_java/controller/ProdutoControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java index 72a0d1b..6683f68 100644 --- a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java +++ b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java @@ -57,7 +57,7 @@ void testGivenNewProduto_whenCreate_thenSavedProduto() throws Exception{ @DisplayName("test fail") @Test void testGivenNewProduto_whenCreate_thenFail() throws Exception{ - // fail("Uma nova falha"); + fail("Um erro acontecerá"); } } From 4ff58f525d4c3aaba137c3d7793a2f81f1a596be Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:13:04 -0300 Subject: [PATCH 15/21] Bug corrigido --- .../fiap/simple_api_java/controller/ProdutoControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java index 6683f68..9670a52 100644 --- a/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java +++ b/src/test/java/com/github/fiap/simple_api_java/controller/ProdutoControllerTest.java @@ -57,7 +57,7 @@ void testGivenNewProduto_whenCreate_thenSavedProduto() throws Exception{ @DisplayName("test fail") @Test void testGivenNewProduto_whenCreate_thenFail() throws Exception{ - fail("Um erro acontecerá"); + // fail("Um erro acontecerá"); } } From 96f8a6d56934778b1467af8783194cb37f0d2ada Mon Sep 17 00:00:00 2001 From: Antonio Carlos de Lima Junior Date: Fri, 30 Aug 2024 16:32:51 -0300 Subject: [PATCH 16/21] Add or update the App Service deployment workflow configuration from Azure Portal. --- .../workflows/develop_fiap-simple-api-dev.yml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/develop_fiap-simple-api-dev.yml diff --git a/.github/workflows/develop_fiap-simple-api-dev.yml b/.github/workflows/develop_fiap-simple-api-dev.yml new file mode 100644 index 0000000..107554a --- /dev/null +++ b/.github/workflows/develop_fiap-simple-api-dev.yml @@ -0,0 +1,51 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy container app to Azure Web App - fiap-simple-api-dev + +on: + push: + branches: + - develop + workflow_dispatch: + +jobs: + build: + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: https://index.docker.io/v1/ + username: ${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }} + password: ${{ secrets.AzureAppService_ContainerPassword_c3761c75c50f4d9293d110b23c21f3b7 }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v3 + with: + push: true + tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }}/acnaweb/simple-api-java:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'fiap-simple-api-dev' + slot-name: 'production' + publish-profile: ${{ secrets.AzureAppService_PublishProfile_2c10af6af32f475e84081e19178a0dc6 }} + images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }}/acnaweb/simple-api-java:${{ github.sha }}' \ No newline at end of file From 8b45c5c2a20d25e54a7f801bc8e3f9e83c3d26ec Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:48:00 -0300 Subject: [PATCH 17/21] Remove workflow --- .../workflows/develop_fiap-simple-api-dev.yml | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 .github/workflows/develop_fiap-simple-api-dev.yml diff --git a/.github/workflows/develop_fiap-simple-api-dev.yml b/.github/workflows/develop_fiap-simple-api-dev.yml deleted file mode 100644 index 107554a..0000000 --- a/.github/workflows/develop_fiap-simple-api-dev.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy -# More GitHub Actions for Azure: https://github.com/Azure/actions - -name: Build and deploy container app to Azure Web App - fiap-simple-api-dev - -on: - push: - branches: - - develop - workflow_dispatch: - -jobs: - build: - runs-on: 'ubuntu-latest' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to registry - uses: docker/login-action@v2 - with: - registry: https://index.docker.io/v1/ - username: ${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }} - password: ${{ secrets.AzureAppService_ContainerPassword_c3761c75c50f4d9293d110b23c21f3b7 }} - - - name: Build and push container image to registry - uses: docker/build-push-action@v3 - with: - push: true - tags: index.docker.io/${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }}/acnaweb/simple-api-java:${{ github.sha }} - file: ./Dockerfile - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'fiap-simple-api-dev' - slot-name: 'production' - publish-profile: ${{ secrets.AzureAppService_PublishProfile_2c10af6af32f475e84081e19178a0dc6 }} - images: 'index.docker.io/${{ secrets.AzureAppService_ContainerUsername_7cd6c9cdfcd547a1884492a67a358420 }}/acnaweb/simple-api-java:${{ github.sha }}' \ No newline at end of file From 6eef35ad8bbe84a2e60e280d8734606c28de95c5 Mon Sep 17 00:00:00 2001 From: Antonio Carlos Date: Fri, 30 Aug 2024 16:54:34 -0300 Subject: [PATCH 18/21] Adicionando continuous delivery --- .github/workflows/continuous_delivery.yaml | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/continuous_delivery.yaml diff --git a/.github/workflows/continuous_delivery.yaml b/.github/workflows/continuous_delivery.yaml new file mode 100644 index 0000000..2de6643 --- /dev/null +++ b/.github/workflows/continuous_delivery.yaml @@ -0,0 +1,47 @@ +name: Continuous Delivery + +on: + push: + branches: + - develop + +jobs: + build: + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: https://index.docker.io/v1/ + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push container image to registry + uses: docker/build-push-action@v3 + with: + push: true + tags: index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }} + file: ./Dockerfile + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'fiap-simple-api-dev' + slot-name: 'production' + publish-profile: ${{ secrets.AZURE_PROFILE }} + images: 'index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file From a89ef486661575c3a4e33dd124660e251c9a632c Mon Sep 17 00:00:00 2001 From: AC Date: Mon, 2 Sep 2024 10:07:11 -0300 Subject: [PATCH 19/21] Remover workflows --- .github/workflows/continuous_delivery.yaml | 47 ------------------- .github/workflows/continuous_integration.yaml | 22 --------- 2 files changed, 69 deletions(-) delete mode 100644 .github/workflows/continuous_delivery.yaml delete mode 100644 .github/workflows/continuous_integration.yaml diff --git a/.github/workflows/continuous_delivery.yaml b/.github/workflows/continuous_delivery.yaml deleted file mode 100644 index 2de6643..0000000 --- a/.github/workflows/continuous_delivery.yaml +++ /dev/null @@ -1,47 +0,0 @@ -name: Continuous Delivery - -on: - push: - branches: - - develop - -jobs: - build: - runs-on: 'ubuntu-latest' - - steps: - - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to registry - uses: docker/login-action@v2 - with: - registry: https://index.docker.io/v1/ - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push container image to registry - uses: docker/build-push-action@v3 - with: - push: true - tags: index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }} - file: ./Dockerfile - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: 'production' - url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} - - steps: - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v2 - with: - app-name: 'fiap-simple-api-dev' - slot-name: 'production' - publish-profile: ${{ secrets.AZURE_PROFILE }} - images: 'index.docker.io/${{ secrets.DOCKERHUB_USERNAME }}/simple-api-java:${{ github.sha }}' \ No newline at end of file diff --git a/.github/workflows/continuous_integration.yaml b/.github/workflows/continuous_integration.yaml deleted file mode 100644 index 4f4ae0b..0000000 --- a/.github/workflows/continuous_integration.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Continuous Integration FIAP - -on: - pull_request: - branches: - - develop - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Git Checkout - uses: actions/checkout@v4 - - - name: Setup Java SDK - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '21' - - - name: Unit tests - run: mvn test \ No newline at end of file From c4bd24377418b2d898a422e418a57af2c3f70af2 Mon Sep 17 00:00:00 2001 From: Antonio Carlos de Lima Junior Date: Mon, 7 Oct 2024 01:06:15 +0000 Subject: [PATCH 20/21] Remove msgs --- .../fiap/simple_api_java/controller/ProdutoController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java b/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java index 7e8ca4c..2204bb2 100644 --- a/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java +++ b/src/main/java/com/github/fiap/simple_api_java/controller/ProdutoController.java @@ -42,7 +42,7 @@ public ResponseEntity findById(@PathVariable Long id) { ProdutoResponseDto responseDto = produtoService .findById(id) .map(produto -> new ProdutoResponseDto().toDto(produto)) - .orElseThrow(() -> new RuntimeException("Deu merda")); + .orElseThrow(() -> new RuntimeException("Erro")); return ResponseEntity.ok().body(responseDto); } @@ -58,7 +58,7 @@ public ResponseEntity create(@RequestBody ProdutoCreateDto r @PutMapping("{id}") public ResponseEntity update(@PathVariable Long id, @RequestBody ProdutoUpdateDto requestDto) { if (! produtoService.existsById(id)) { - new RuntimeException("Deu merda"); + new RuntimeException("Erro"); } Produto produto = produtoService.saveOrUpdate(requestDto.toModel()); @@ -70,7 +70,7 @@ public ResponseEntity update(@PathVariable Long id, @Request @DeleteMapping("{id}") public ResponseEntity update(@PathVariable Long id) { if (!produtoService.existsById(id)) { - new RuntimeException("Deu merda"); + new RuntimeException("Erro"); } produtoService.delete(id); From 32f741db7b9c9e2426d71325578adc39eed5db71 Mon Sep 17 00:00:00 2001 From: Cyntia Date: Tue, 12 May 2026 22:13:59 -0300 Subject: [PATCH 21/21] Renomear workflow --- .github/03-workflow-actions.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/03-workflow-actions.yaml diff --git a/.github/03-workflow-actions.yaml b/.github/03-workflow-actions.yaml new file mode 100644 index 0000000..e5a39da --- /dev/null +++ b/.github/03-workflow-actions.yaml @@ -0,0 +1,29 @@ +name: 03 - Actions 1.0 + +on: + push: + branches: "feature/**" + +jobs: + checkout_java_docker: + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Build + uses: docker/build-push-action@v6 + with: + push: false + + - name: Executar scripts + run: | + git branch + java --version + mvn clean package \ No newline at end of file