From d5e4e4b7162d523027cf7533622f23ce41e7a540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herik=20dos=20Santos=20Loren=C3=A7=C3=A3o?= Date: Sat, 2 Apr 2022 11:04:48 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Adiciona=20configura=C3=A7=C3=A3o=20b=C3=A1?= =?UTF-8?q?sica=20do=20gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ .../java/com/cheffon/gateway/Application.java | 17 ++++++++++++++ .../cheffon/gateway/GatewayApplication.java | 13 ----------- src/main/resources/application-dev.yml | 2 ++ src/main/resources/application-prod.yml | 2 ++ src/main/resources/application.properties | 1 - src/main/resources/application.yml | 22 +++++++++++++++++++ ...cationTests.java => ApplicationTests.java} | 2 +- 8 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 README.md create mode 100644 src/main/java/com/cheffon/gateway/Application.java delete mode 100644 src/main/java/com/cheffon/gateway/GatewayApplication.java create mode 100644 src/main/resources/application-dev.yml create mode 100644 src/main/resources/application-prod.yml delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml rename src/test/java/com/cheffon/gateway/{GatewayApplicationTests.java => ApplicationTests.java} (84%) diff --git a/README.md b/README.md new file mode 100644 index 0000000..d9c0918 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Cheffon Gateway + +```bash +-Dspring.profiles.active=dev +``` \ No newline at end of file diff --git a/src/main/java/com/cheffon/gateway/Application.java b/src/main/java/com/cheffon/gateway/Application.java new file mode 100644 index 0000000..1a51f5a --- /dev/null +++ b/src/main/java/com/cheffon/gateway/Application.java @@ -0,0 +1,17 @@ +package com.cheffon.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; + +@SpringBootApplication +@EnableDiscoveryClient +@EnableEurekaClient +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/src/main/java/com/cheffon/gateway/GatewayApplication.java b/src/main/java/com/cheffon/gateway/GatewayApplication.java deleted file mode 100644 index f920915..0000000 --- a/src/main/java/com/cheffon/gateway/GatewayApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.cheffon.gateway; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class GatewayApplication { - - public static void main(String[] args) { - SpringApplication.run(GatewayApplication.class, args); - } - -} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..3a6f32c --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,2 @@ +server: + port: 5555 \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..47fbb02 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,2 @@ +server: + port: 8080 \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..d5c4b5d --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,22 @@ +spring: + profiles: + active: dev + application: + name: 'gateway' + cloud: + gateway: + discovery: + locator: + enabled: true + lower-case-service-id: true + routes: + - id: api + uri: lb://api + predicates: + - Path=/api/** +eureka: + client: + register-with-eureka: true + fetch-registry: true + service-url: + defaultZone: http://localhost:8761/eureka \ No newline at end of file diff --git a/src/test/java/com/cheffon/gateway/GatewayApplicationTests.java b/src/test/java/com/cheffon/gateway/ApplicationTests.java similarity index 84% rename from src/test/java/com/cheffon/gateway/GatewayApplicationTests.java rename to src/test/java/com/cheffon/gateway/ApplicationTests.java index be0d044..33455b3 100644 --- a/src/test/java/com/cheffon/gateway/GatewayApplicationTests.java +++ b/src/test/java/com/cheffon/gateway/ApplicationTests.java @@ -4,7 +4,7 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class GatewayApplicationTests { +class ApplicationTests { @Test void contextLoads() { From 6e5a33bfef19da562f2c7b58b977897aba5f0af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herik=20dos=20Santos=20Loren=C3=A7=C3=A3o?= Date: Sat, 2 Apr 2022 11:15:33 -0300 Subject: [PATCH 2/5] Atualiza README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d9c0918..93ccbaa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ # Cheffon Gateway -```bash --Dspring.profiles.active=dev -``` \ No newline at end of file +Gateway da API backend do Cheffon \ No newline at end of file From 4170867d6f104b07a12242b81ac5c4c0ed97eb54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herik=20dos=20Santos=20Loren=C3=A7=C3=A3o?= Date: Sat, 2 Apr 2022 11:32:11 -0300 Subject: [PATCH 3/5] Adiciona workflow de pull request --- .github/workflows/pull_request.yml | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..e1adc81 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,51 @@ +name: pull-request +on: + pull_request: + types: [ opened, synchronize, reopened ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 18 + - run: mvn -B install --no-transfer-progress + sonarqube: + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout codebase + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up JDK 18 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 18 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=${{secrets.SONAR_PROJECT_KEY}} + discord-notification: + runs-on: ubuntu-latest + needs: sonarqube + steps: + - name: Discord notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_PR_WEBHOOK }} + uses: sarisia/actions-status-discord@v1 + with: + username: 'Pull Request' + title: "${{ github.event.pull_request.title }}" + avatar_url: ${{ secrets.AVATAR_PR_URL }} + description: ${{ github.event.pull_requests.url }} \ No newline at end of file From 98f3b6d8f0b9e0944cc7366bef750461f5fcf352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herik=20dos=20Santos=20Loren=C3=A7=C3=A3o?= Date: Sat, 2 Apr 2022 11:49:35 -0300 Subject: [PATCH 4/5] =?UTF-8?q?Ajusta=20vers=C3=A3o=20do=20Java=20para=20c?= =?UTF-8?q?ompat=C3=ADvel=20com=20o=20worflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull_request.yml | 6 +++--- pom.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e1adc81..31e029d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: 18 + java-version: 17 - run: mvn -B install --no-transfer-progress sonarqube: runs-on: ubuntu-latest @@ -20,11 +20,11 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up JDK 18 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: distribution: 'adopt' - java-version: 18 + java-version: 17 - name: Cache SonarCloud packages uses: actions/cache@v1 with: diff --git a/pom.xml b/pom.xml index 7645285..20f3f7d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ gateway API Gateway para o projeto cheffon.com - 18 + 17 2021.0.1 From c420dc3e4ca628117beaee4416a3e2fe5890c901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herik=20dos=20Santos=20Loren=C3=A7=C3=A3o?= Date: Sat, 2 Apr 2022 12:07:51 -0300 Subject: [PATCH 5/5] =?UTF-8?q?Ajusta=20configura=C3=A7=C3=B5es=20do=20son?= =?UTF-8?q?ar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 20f3f7d..5a3a3ef 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,8 @@ 17 2021.0.1 + zero28devs + https://sonarcloud.io