diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..9cd06bf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" diff --git a/.github/release-drafter.yaml b/.github/release-drafter.yaml index 18cf027..ce2ae2b 100644 --- a/.github/release-drafter.yaml +++ b/.github/release-drafter.yaml @@ -12,6 +12,9 @@ categories: - 'bug' - title: '🧰 Maintenance' label: 'chore' + - title: '🤖 Dependencies' + labels: + - 'dependencies' change-template: '- $TITLE @$AUTHOR (#$NUMBER)' change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2cf2bc0..2f7efa1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + workflow_dispatch: jobs: run_tests: diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 90a07d3..55a1762 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -44,3 +44,19 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} + automerge: + needs: run_tests_and_build + permissions: + pull-requests: write + contents: write + runs-on: + - self-hosted + - kaas + timeout-minutes: 15 + if: github.actor == 'dependabot[bot]' + steps: + - name: Automerge dependabot PR + uses: fastify/github-action-merge-dependabot@v3 + with: + target: minor + skip-commit-verification: true diff --git a/Dockerfile b/Dockerfile index 5181eac..fdda551 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 gradle:7.6-jdk17-alpine as builder +FROM --platform=linux/amd64 gradle:8.1.1-jdk17-alpine as builder WORKDIR /builder COPY . . diff --git a/build.gradle.kts b/build.gradle.kts index 36e3c8a..9efbc34 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,16 @@ plugins { - id("org.springframework.boot") version "3.0.1" - id("com.github.ben-manes.versions") version "0.44.0" - kotlin("jvm") version "1.8.0" - kotlin("plugin.allopen") version "1.8.0" - kotlin("plugin.spring") version "1.8.0" - kotlin("plugin.jpa") version "1.8.0" + id("org.springframework.boot") version "3.0.6" + id("com.github.ben-manes.versions") version "0.46.0" + kotlin("jvm") version "1.8.21" + kotlin("plugin.allopen") version "1.8.21" + kotlin("plugin.spring") version "1.8.21" + kotlin("plugin.jpa") version "1.8.21" } -val kotlinVersion = "1.8.0" -val jacksonVersion = "2.14.1" -val springBootVersion = "3.0.1" -val junitVersion = "5.9.2" +val kotlinVersion = "1.8.21" +val jacksonVersion = "2.15.0" +val springBootVersion = "3.0.6" +val junitVersion = "5.9.3" val ktlint: Configuration by configurations.creating @@ -33,20 +33,20 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion") implementation("jakarta.persistence:jakarta.persistence-api:3.1.0") - implementation("org.flywaydb:flyway-core:9.11.0") - implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2") - implementation("io.github.microutils:kotlin-logging-jvm:3.0.4") + implementation("org.flywaydb:flyway-core:9.17.0") + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0") + implementation("io.github.microutils:kotlin-logging-jvm:3.0.5") implementation("com.google.firebase:firebase-admin:9.1.1") - runtimeOnly("org.postgresql:postgresql:42.5.1") + runtimeOnly("org.postgresql:postgresql:42.6.0") testImplementation("org.springframework.boot:spring-boot-starter-test:$springBootVersion") - testImplementation("org.assertj:assertj-core:3.24.1") + testImplementation("org.assertj:assertj-core:3.24.2") testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion") testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") testImplementation("io.zonky.test:embedded-database-spring-test:2.2.0") - ktlint("com.pinterest:ktlint:0.48.1") { + ktlint("com.pinterest:ktlint:0.49.0") { attributes { attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..943f0cb 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..37aef8d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..65dcd68 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/kotlin/three/consulting/epoc/service/CustomerService.kt b/src/main/kotlin/three/consulting/epoc/service/CustomerService.kt index 3162235..7319ce2 100644 --- a/src/main/kotlin/three/consulting/epoc/service/CustomerService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/CustomerService.kt @@ -1,7 +1,6 @@ package three.consulting.epoc.service import mu.KotlinLogging -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -57,13 +56,8 @@ class CustomerService(private val customerRepository: CustomerRepository) { } fun deleteCustomer(customerId: Long) { - try { - logger.info { "Deleting customer with id: $customerId" } - customerRepository.deleteById(customerId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete customer" } - throw UnableToDeleteCustomerException(customerId) - } + logger.info { "Deleting customer with id: $customerId" } + customerRepository.deleteById(customerId) } fun findAllCustomers(): List { diff --git a/src/main/kotlin/three/consulting/epoc/service/EmployeeService.kt b/src/main/kotlin/three/consulting/epoc/service/EmployeeService.kt index cc35e8b..a9f02e6 100644 --- a/src/main/kotlin/three/consulting/epoc/service/EmployeeService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/EmployeeService.kt @@ -1,7 +1,6 @@ package three.consulting.epoc.service import mu.KotlinLogging -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -60,13 +59,8 @@ class EmployeeService( } fun deleteEmployee(employeeId: Long) { - try { - logger.info { "Deleting employee with id: $employeeId" } - employeeRepository.deleteById(employeeId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete employee" } - throw UnableToDeleteEmployeeException(employeeId) - } + logger.info { "Deleting employee with id: $employeeId" } + employeeRepository.deleteById(employeeId) } fun findAllEmployees(): List { diff --git a/src/main/kotlin/three/consulting/epoc/service/ProjectService.kt b/src/main/kotlin/three/consulting/epoc/service/ProjectService.kt index 4713a66..c0bf1ad 100644 --- a/src/main/kotlin/three/consulting/epoc/service/ProjectService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/ProjectService.kt @@ -2,7 +2,6 @@ package three.consulting.epoc.service import mu.KotlinLogging import org.springframework.dao.DataIntegrityViolationException -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -78,13 +77,8 @@ class ProjectService(private val projectRepository: ProjectRepository) { } fun deleteProject(projectId: Long) { - try { - logger.info { "Deleting project with id: $projectId" } - projectRepository.deleteById(projectId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete project" } - throw UnableToDeleteProjectException(projectId) - } + logger.info { "Deleting project with id: $projectId" } + projectRepository.deleteById(projectId) } fun findAllProjects(): List { diff --git a/src/main/kotlin/three/consulting/epoc/service/TaskService.kt b/src/main/kotlin/three/consulting/epoc/service/TaskService.kt index 1b0b9f7..08ea828 100644 --- a/src/main/kotlin/three/consulting/epoc/service/TaskService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/TaskService.kt @@ -2,7 +2,6 @@ package three.consulting.epoc.service import mu.KotlinLogging import org.springframework.dao.DataIntegrityViolationException -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -65,13 +64,8 @@ class TaskService(private val taskRepository: TaskRepository) { } fun deleteTask(taskId: Long) { - try { - logger.info { "Deleting task with id: $taskId" } - taskRepository.deleteById(taskId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete task" } - throw UnableToDeleteTaskException(taskId) - } + logger.info { "Deleting task with id: $taskId" } + taskRepository.deleteById(taskId) } } diff --git a/src/main/kotlin/three/consulting/epoc/service/TimesheetEntryService.kt b/src/main/kotlin/three/consulting/epoc/service/TimesheetEntryService.kt index a47831b..9adae73 100644 --- a/src/main/kotlin/three/consulting/epoc/service/TimesheetEntryService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/TimesheetEntryService.kt @@ -2,7 +2,6 @@ package three.consulting.epoc.service import mu.KotlinLogging import org.springframework.dao.DataIntegrityViolationException -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -96,13 +95,8 @@ class TimesheetEntryService(private val timesheetEntryRepository: TimesheetEntry } fun deleteTimesheetEntry(timesheetEntryId: Long) { - try { - logger.info { "Deleting timesheetEntry with id: $timesheetEntryId" } - timesheetEntryRepository.deleteById(timesheetEntryId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete timesheetEntry" } - throw UnableToDeleteTimesheetEntryException(timesheetEntryId) - } + logger.info { "Deleting timesheetEntry with id: $timesheetEntryId" } + timesheetEntryRepository.deleteById(timesheetEntryId) } fun hasValidEmails(timesheetEntries: List, email: String): Boolean { diff --git a/src/main/kotlin/three/consulting/epoc/service/TimesheetService.kt b/src/main/kotlin/three/consulting/epoc/service/TimesheetService.kt index 91654b9..73fb705 100644 --- a/src/main/kotlin/three/consulting/epoc/service/TimesheetService.kt +++ b/src/main/kotlin/three/consulting/epoc/service/TimesheetService.kt @@ -2,7 +2,6 @@ package three.consulting.epoc.service import mu.KotlinLogging import org.springframework.dao.DataIntegrityViolationException -import org.springframework.dao.EmptyResultDataAccessException import org.springframework.data.repository.findByIdOrNull import org.springframework.http.HttpStatus import org.springframework.stereotype.Service @@ -71,13 +70,8 @@ class TimesheetService(private val timesheetRepository: TimesheetRepository) { } fun deleteTimesheet(timesheetId: Long) { - try { - logger.info { "Deleting timesheet with id: $timesheetId" } - timesheetRepository.deleteById(timesheetId) - } catch (e: EmptyResultDataAccessException) { - logger.error(e) { "Cannot delete timesheet" } - throw UnableToDeleteTimesheetException(timesheetId) - } + logger.info { "Deleting timesheet with id: $timesheetId" } + timesheetRepository.deleteById(timesheetId) } } diff --git a/src/test/kotlin/three/consulting/epoc/service/CustomerServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/CustomerServiceIntegrationTest.kt index 7af6f63..386662e 100644 --- a/src/test/kotlin/three/consulting/epoc/service/CustomerServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/CustomerServiceIntegrationTest.kt @@ -103,13 +103,6 @@ class CustomerServiceIntegrationTest : IntegrationTest() { assertThat(customerRepository.findByIdOrNull(3L)).isNull() } - @Test - fun `delete customer with non-existing id raises error`() { - assertThatThrownBy { customerService.deleteCustomer(1000L) } - .isInstanceOf(UnableToDeleteCustomerException::class.java) - .hasMessage("Cannot delete customer, no customer found for the given id: 1000") - } - @Test fun `get all customers`() { val customers = customerService.findAllCustomers() diff --git a/src/test/kotlin/three/consulting/epoc/service/EmployeeServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/EmployeeServiceIntegrationTest.kt index b56caf8..0c75693 100644 --- a/src/test/kotlin/three/consulting/epoc/service/EmployeeServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/EmployeeServiceIntegrationTest.kt @@ -142,13 +142,6 @@ class EmployeeServiceIntegrationTest : IntegrationTest() { assertThat(employeeRepository.findByIdOrNull(4L)).isNull() } - @Test - fun `delete employee with non-existing id raise error`() { - assertThatThrownBy { employeeService.deleteEmployee(1000L) } - .isInstanceOf(UnableToDeleteEmployeeException::class.java) - .hasMessage("Cannot delete employee, no employee found for given id: 1000") - } - @Test fun `get all employees`() { val employees = employeeService.findAllEmployees() diff --git a/src/test/kotlin/three/consulting/epoc/service/ProjectServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/ProjectServiceIntegrationTest.kt index b0f2255..94961a4 100644 --- a/src/test/kotlin/three/consulting/epoc/service/ProjectServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/ProjectServiceIntegrationTest.kt @@ -178,13 +178,6 @@ class ProjectServiceIntegrationTest : IntegrationTest() { assertThat(projectRepository.findByIdOrNull(2L)).isNull() } - @Test - fun `delete project with non-existing id raise error`() { - Assertions.assertThatThrownBy { projectService.deleteProject(1000L) } - .isInstanceOf(UnableToDeleteProjectException::class.java) - .hasMessage("Cannot delete project, no project found for given id: 1000") - } - @Test fun `get all projects`() { val projects = projectService.findAllProjects() diff --git a/src/test/kotlin/three/consulting/epoc/service/TaskServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/TaskServiceIntegrationTest.kt index c0a5566..00cbc79 100644 --- a/src/test/kotlin/three/consulting/epoc/service/TaskServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/TaskServiceIntegrationTest.kt @@ -152,13 +152,6 @@ class TaskServiceIntegrationTest : IntegrationTest() { assertThat(taskRepository.findByIdOrNull(2L)).isNull() } - @Test - fun `delete task with non-existing id raise error`() { - Assertions.assertThatThrownBy { taskService.deleteTask(1000L) } - .isInstanceOf(UnableToDeleteTaskException::class.java) - .hasMessage("Cannot delete task, no task found for given id: 1000") - } - @Test fun `searching task with project id 1 returns array of task objects`() { val tasks = taskService.findTasks(1L) diff --git a/src/test/kotlin/three/consulting/epoc/service/TimesheetEntryServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/TimesheetEntryServiceIntegrationTest.kt index 70d5e07..b393261 100644 --- a/src/test/kotlin/three/consulting/epoc/service/TimesheetEntryServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/TimesheetEntryServiceIntegrationTest.kt @@ -256,13 +256,6 @@ class TimesheetEntryServiceIntegrationTest : IntegrationTest() { assertThat(timesheetEntryRepository.findByIdOrNull(2L)).isNull() } - @Test - fun `delete timesheetEntry with non-existing id raise error`() { - assertThatThrownBy { timesheetEntryService.deleteTimesheetEntry(1000L) } - .isInstanceOf(UnableToDeleteTimesheetEntryException::class.java) - .hasMessage("Cannot delete timesheetEntry, no timesheetEntry found for given id: 1000") - } - @Test fun `getting timesheet entries for timesheetId returns multiple entries`() { val entries = timesheetEntryService.findTimesheetEntries(1L, null, null, null) diff --git a/src/test/kotlin/three/consulting/epoc/service/TimesheetServiceIntegrationTest.kt b/src/test/kotlin/three/consulting/epoc/service/TimesheetServiceIntegrationTest.kt index da0b82b..0df1942 100644 --- a/src/test/kotlin/three/consulting/epoc/service/TimesheetServiceIntegrationTest.kt +++ b/src/test/kotlin/three/consulting/epoc/service/TimesheetServiceIntegrationTest.kt @@ -259,13 +259,6 @@ class TimesheetServiceIntegrationTest : IntegrationTest() { assertThat(timesheetRepository.findByIdOrNull(3L)).isNull() } - @Test - fun `delete timesheet with non-existing id raise error`() { - assertThatThrownBy { timesheetService.deleteTimesheet(1000L) } - .isInstanceOf(UnableToDeleteTimesheetException::class.java) - .hasMessage("Cannot delete timesheet, no timesheet found for given id: 1000") - } - @Test fun `searching timesheet with project id 1 returns array of timesheet objects`() { val timesheets = timesheetService.findTimesheets(1L, null, null)