Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 65 additions & 54 deletions .github/workflows/CI.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
name: Build
on:
push:
branches:
- main # the name of your main branch
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 23
uses: actions/setup-java@v1
with:
java-version: 23
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build
- name: Store HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: "${{github.workspace}}/build/reports/jacoco/test/html/"
- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.7.1
with:
paths: |
${{ github.workspace }}/**/build/reports/jacoco/test/*.xml,
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
name: Build
on:
push:
branches:
- "**"

jobs:
build:
name: Build & Test (H2)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure full history for SonarQube analysis

- name: Set up JDK 23
uses: actions/setup-java@v1
with:
java-version: 23

- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: gradle-cache-${{ runner.os }}-${{ hashFiles('**/*.gradle') }}
restore-keys: gradle-cache-${{ runner.os }}

- name: Run Tests (Using H2)
env:
SPRING_PROFILES_ACTIVE: test # Force use of H2 DB
run: ./gradlew test

- name: Build and Analyze with SonarQube
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_SCANNER_OPTS: "-Dsonar.qualitygate.wait=true -Dsonar.pullrequest.github.summary_only=true"
run: ./gradlew build sonar --info

- name: Store HTML coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: "${{github.workspace}}/build/reports/jacoco/test/html/"

- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.7.1
with:
paths: |
${{ github.workspace }}/**/build/reports/jacoco/test/*.xml,
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ plugins {
id("org.sonarqube") version "6.0.1.5171"
}

sonar {
properties {
property("sonar.projectKey", "frank-connolly_gymcore")
property("sonar.organization", "frank-connolly")
property("sonar.host.url", "https://sonarcloud.io")
}
}

group = "org.justjava"
version = "0.0.1-SNAPSHOT"

Expand All @@ -24,11 +32,11 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.flywaydb:flyway-core")
implementation("org.flywaydb:flyway-database-postgresql")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0") // Version must be specified explicitly
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testCompileOnly("org.projectlombok:lombok")
testAnnotationProcessor("org.projectlombok:lombok")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0") // Version must be specified explicitly
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test")
Expand Down