diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba83f76..48b89a0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,10 @@ on: - 'src/*' - '*gradle*' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: scan-sonar: runs-on: ubuntu-22.04 diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index dda6a8a..4d9a788 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -162,8 +162,9 @@ jobs: run: | docker pull ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }}-RC docker image tag ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }}-RC ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }} + docker image tag ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }}-RC ghcr.io/${{ github.repository }}:latest docker rmi ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }}-RC - docker image push --all-tags ghcr.io/${{ github.repository }}:${{ needs.versioning.outputs.new_version }} + docker image push --all-tags ghcr.io/${{ github.repository }} - name: "STABLE - Update Container App" shell: bash diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index a08c30a..9734b22 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -9,6 +9,10 @@ on: - edited - synchronize +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: pr-validation: runs-on: ubuntu-22.04 diff --git a/build.gradle b/build.gradle index cadaf98..f1c5f0b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.openapitools.generator.gradle.plugin.tasks.GenerateTask + plugins { id 'java' id 'org.springframework.boot' version '3.3.5' @@ -80,7 +82,7 @@ sourceSets { } } -task generateOpenAPIActivate(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +tasks.register('generateOpenAPIActivate', GenerateTask) { generatorName.set("spring") inputSpec.set("$rootDir/openapi/activation.openapi.yaml") outputDir.set("$projectDir/build/generated") @@ -110,7 +112,7 @@ task generateOpenAPIActivate(type: org.openapitools.generator.gradle.plugin.task } -task generateOpenAPISend(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +tasks.register('generateOpenAPISend', GenerateTask) { generatorName.set("spring") inputSpec.set("$rootDir/openapi/send.openapi.yaml") outputDir.set("$projectDir/build/generated") @@ -139,21 +141,22 @@ task generateOpenAPISend(type: org.openapitools.generator.gradle.plugin.tasks.Ge ]) } -task generateOpenAPIEPC(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { - generatorName.set("spring") +tasks.register('generateOpenAPIEPC', GenerateTask) { + generatorName.set("java") inputSpec.set("$rootDir/openapi/EPC133-22 v3.1 - SRTP scheme rulebook v3.1 related API specifications_optimized.yaml") outputDir.set("$projectDir/build/generated") - apiPackage.set("it.gov.pagopa.rtp.activator.controller.generated.epc") - modelPackage.set("it.gov.pagopa.rtp.activator.model.generated.epc") + apiPackage.set("it.gov.pagopa.rtp.activator.client.epc.api") + modelPackage.set("it.gov.pagopa.rtp.activator.client.epc.model") + invokerPackage.set("it.gov.pagopa.rtp.activator.client.epc.invoker") modelNameSuffix.set("Dto") generateApiTests.set(false) generateApiDocumentation.set(false) generateApiTests.set(false) generateModelTests.set(false) - library.set("spring-boot") + library.set("webclient") configOptions.set([ "dateLibrary" : "java8", - "useSpringBoot3" : "true", + "useJakartaEe" : "true", "interfaceOnly" : "true", "useTags" : "true", "useSwaggerUI" : "false", @@ -184,7 +187,7 @@ bootRun { ] } -tasks.withType(JavaExec) { +tasks.withType(JavaExec).configureEach { jvmArgs += '-Djava.security.properties=src/main/resources/custom.security' } diff --git a/gradle.properties b/gradle.properties index 6eb5849..ff12af1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=1.5.0 \ No newline at end of file +version=1.5.1 \ No newline at end of file diff --git a/src/main/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfig.java b/src/main/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfig.java index cfdd312..f6a9534 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfig.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfig.java @@ -2,16 +2,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; -import lombok.Getter; -import lombok.Setter; - @ConfigurationProperties(prefix = "activation") -@Getter -@Setter -public class ActivationPropertiesConfig{ - private String baseUrl; +public record ActivationPropertiesConfig( + String baseUrl) { - public ActivationPropertiesConfig(String baseUrl){ - this.baseUrl = baseUrl; - } } diff --git a/src/main/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImpl.java b/src/main/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImpl.java index 4b486f2..342dc2a 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImpl.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImpl.java @@ -46,7 +46,7 @@ public Mono> activate( .flatMap(t -> activationPayerService.activatePayer(t.getPayer().getRtpSpId(), t.getPayer().getFiscalCode())) .>map(payer -> ResponseEntity - .created(URI.create(activationPropertiesConfig.getBaseUrl() + payer.payerID().toString())) + .created(URI.create(activationPropertiesConfig.baseUrl() + payer.payerID().toString())) .build()) .onErrorReturn(PayerAlreadyExists.class, ResponseEntity.status(409).build()); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index ccf4b8f..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1,15 +0,0 @@ -logging.level.root=INFO - -spring.application.name=rtp-activator - -# enable spring boot actuator health endpoint -management.endpoints.enabled-by-default=false -management.endpoints.web.exposure.include=health -management.endpoint.health.enabled=true -management.endpoint.health.probes.enabled=true - -#repository -management.health.mongo.enabled=false -spring.data.mongodb.uri=${COSMOS_ACCOUNT_RTP_CONNECTION_STRING:} -spring.data.mongodb.database=${DB_NAME:rtp} -activation.base-url=${BASE_URL:http://localhost} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..7d13c42 --- /dev/null +++ b/src/main/resources/application.yaml @@ -0,0 +1,20 @@ +logging.level.root: INFO + +spring.application.name: rtp-activator + +# enable spring boot actuator health endpoint +management: + endpoints: + enabled-by-default: false + web.exposure.include: health + endpoint: + health: + enabled: true + probes.enabled: true +#repository + health.mongo.enabled: false + +spring.data.mongodb: + uri: ${COSMOS_ACCOUNT_RTP_CONNECTION_STRING:} + database: ${DB_NAME:rtp} +activation.base-url: ${BASE_URL:http://localhost} diff --git a/src/test/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfigTest.java b/src/test/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfigTest.java index 76ab056..4517272 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfigTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/configuration/ActivationPropertiesConfigTest.java @@ -12,7 +12,7 @@ @ExtendWith(SpringExtension.class) @EnableConfigurationProperties(value = ActivationPropertiesConfig.class) -@TestPropertySource("classpath:application.properties") +@TestPropertySource("classpath:application.yaml") class ActivationPropertiesConfigTest { @Autowired @@ -21,6 +21,6 @@ class ActivationPropertiesConfigTest { @Test void testPropertiesLoaded() { assertNotNull(activationPropertiesConfig); - assertEquals("https://example.com", activationPropertiesConfig.getBaseUrl()); + assertEquals("https://example.com", activationPropertiesConfig.baseUrl()); } } \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImplTest.java b/src/test/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImplTest.java index 557be0d..87420f2 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImplTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/controller/ActivationAPIControllerImplTest.java @@ -75,7 +75,7 @@ void testActivatePayerSuccessful() { when(activationPayerService.activatePayer(any(String.class), any(String.class))) .thenReturn(Mono.just(payer)); - when(activationPropertiesConfig.getBaseUrl()).thenReturn("http://localhost:8080/"); + when(activationPropertiesConfig.baseUrl()).thenReturn("http://localhost:8080/"); webTestClient.post() .uri("/activations") diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties deleted file mode 100644 index 9b31274..0000000 --- a/src/test/resources/application.properties +++ /dev/null @@ -1,6 +0,0 @@ -logging.level.org.springframework.security=DEBUG -activation.baseUrl=https://example.com - -azure.cosmos.uri=https://example.com/db/endpoint -azure.cosmos.key=your-primary-key -azure.cosmos.database=rtp \ No newline at end of file diff --git a/src/test/resources/application.yaml b/src/test/resources/application.yaml new file mode 100644 index 0000000..4d337fd --- /dev/null +++ b/src/test/resources/application.yaml @@ -0,0 +1,7 @@ +logging.level.org.springframework.security: DEBUG +activation.baseUrl: https://example.com + +azure.cosmos: + uri: https://example.com/db/endpoint + key: your-primary-key + database: rtp \ No newline at end of file