diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..31e029d --- /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: 17 + - 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 17 + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 17 + - 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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..93ccbaa --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Cheffon Gateway + +Gateway da API backend do Cheffon \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7645285..5a3a3ef 100644 --- a/pom.xml +++ b/pom.xml @@ -14,8 +14,10 @@ gateway API Gateway para o projeto cheffon.com - 18 + 17 2021.0.1 + zero28devs + https://sonarcloud.io 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() {