Skip to content

Commit

Permalink
ci(task-nr): test nested needs outputs (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: André Caiado da Silva <[email protected]>
  • Loading branch information
andrecaiado and acaiado authored Mar 7, 2024
1 parent 4248f05 commit cec1359
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ name: CI/CD

on:
pull_request:
types: [opened, synchronize, reopened, closed]
types: [opened, synchronize, reopened]
branches:
- main
release:
types: [published]
branches:
- main

concurrency:
group: ${{ github.ref }}
Expand Down Expand Up @@ -45,7 +43,7 @@ jobs:
id: set-push-image
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]] ||
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.merged }}" == "true" ]] ||
[[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
echo "Setting PUSH_IMAGE to true"
echo "PUSH_IMAGE=true" >> "$GITHUB_OUTPUT"
Expand All @@ -57,7 +55,7 @@ jobs:
id: set-deploy
shell: bash
run: |
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
echo "Setting DEPLOY to true"
echo "Setting ENVIRONMENT to staging"
echo "DEPLOY=true" >> "$GITHUB_OUTPUT"
Expand All @@ -72,6 +70,7 @@ jobs:
echo "DEPLOY=false" >> "$GITHUB_OUTPUT"
fi
build-and-test:
if: ${{ github.event_name }} != 'release'
runs-on: ubuntu-latest
needs: prepare
steps:
Expand All @@ -90,6 +89,18 @@ jobs:
run: |
echo "Running the tests"
./mvnw test
- name: Add coverage to PR
id: jacoco
uses: madrapps/[email protected]
with:
paths: |
${{ github.workspace }}/target/site/jacoco/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
title: Coverage report
comment: true
only-changed-files: true
build-image-push:
runs-on: ubuntu-latest
needs: [prepare, build-and-test]
Expand All @@ -116,7 +127,7 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:${{ needs.prepare.outputs.tag_version }}
deploy:
runs-on: ubuntu-latest
needs: [prepare, build-and-test, build-image-push]
needs: [prepare, build-image-push]
if: ${{ needs.prepare.outputs.deploy == 'true' }}
steps:
- name: Deploy
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ The main purpose of this repository is to demonstrate how to set up a CI/CD work

The application used is a simple Spring Boot application with a REST controller and a test class.

Test

## Workflows

There are two workflows in this repository:
Expand Down
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class TutorialController {
@Autowired
TutorialRepository tutorialRepository;

@GetMapping("/cenas")
public ResponseEntity<Void> getCenas() {
return new ResponseEntity<>(HttpStatus.OK);
}

@GetMapping("/tutorials")
public ResponseEntity<List<Tutorial>> getAllTutorials(@RequestParam(required = false) String title) {
try {
Expand Down

0 comments on commit cec1359

Please sign in to comment.