diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 698d948..4544d83 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -48,4 +48,36 @@ jobs: uses: actions/upload-artifact@v5.0.0 with: name: jacoco-report - path: target/site/jacoco \ No newline at end of file + path: target/site/jacoco + + format: + name: Format Code + permissions: + contents: write + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5.0.0 + with: + ref: ${{ github.event.pull_request.head.ref}} + fetch-depth: 0 + + - name: Instalar Java 25 + uses: actions/setup-java@v5.0.0 + with: + distribution: "temurin" + java-version: 25 + - name: Formatar código com Spotless + run: ./mvnw spotless:apply + + - name: Faz um commit e push das mudanças + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + if ! git diff --staged --quiet; then + git commit -m "Aplica formatação do spotless" + git push + else + echo "Nenhuma mudança de formatação necessária." + fi diff --git a/.github/workflows/spotless.yml b/.github/workflows/spotless.yml deleted file mode 100644 index d221517..0000000 --- a/.github/workflows/spotless.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Format Code - -on: - pull_request_review: - types: [submitted] - -permissions: - contents: write - pull-requests: write - -jobs: - format: - if: github.event.review.state == 'approved' - runs-on: ubuntu-latest - - steps: - - name: Checkout na branch do Pull Request - uses: actions/checkout@v5 - with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - fetch-depth: 0 - - - name: Instalar Java 25 - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: 25 - - - name: Aplicar Spotless - run: ./mvnw spotless:apply - - - name: Commit e push se houver mudanças - run: | - if [[ -n "$(git status --porcelain)" ]]; then - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "chore: apply spotless formatting" - git push - else - echo "Nenhuma mudança de formatação." - fi \ No newline at end of file diff --git a/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java b/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java index 1eeabb1..3529253 100644 --- a/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java +++ b/src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java @@ -35,15 +35,14 @@ public ResponseEntity findById(@PathVariable Long id) { return ResponseEntity.ok(reminderService.findById(id)); } - @PostMapping + @PostMapping() public ResponseEntity create(@RequestBody @Valid CreateReminderRequestDTO dto) { return ResponseEntity.status(HttpStatus.CREATED).body(reminderService.create(dto)); } @PutMapping("/{id}") public ResponseEntity update( - @PathVariable Long id, @RequestBody @Valid UpdateReminderRequestDTO dto) - { + @PathVariable Long id, @RequestBody @Valid UpdateReminderRequestDTO dto) { return ResponseEntity.ok(reminderService.update(id, dto)); }