From a21a729d97df3e0b2d65af3c5f1064050df17542 Mon Sep 17 00:00:00 2001 From: Erwin Wessels Date: Sat, 27 Jan 2024 22:16:22 +0100 Subject: [PATCH 1/5] Upgrade to Guice v7 --- gradle/libs.versions.toml | 4 ++-- .../kotlin/io/pleo/prop/objects/BothNamedAnnotations.kt | 6 +++--- .../src/test/kotlin/io/pleo/prop/objects/ComplexObjects.kt | 4 ++-- .../test/kotlin/io/pleo/prop/objects/CurrencyUnitProp.kt | 4 ++-- .../src/test/kotlin/io/pleo/prop/objects/DefaultValue.kt | 4 ++-- .../kotlin/io/pleo/prop/objects/EmptyNamedAnnotation.kt | 4 ++-- .../kotlin/io/pleo/prop/objects/InlineProviderModule.kt | 2 +- .../kotlin/io/pleo/prop/objects/InvalidDefaultValue.kt | 4 ++-- .../pleo/prop/objects/InvalidDefaultValueButValidValue.kt | 4 ++-- .../src/test/kotlin/io/pleo/prop/objects/InvalidJSON.kt | 4 ++-- .../io/pleo/prop/objects/MyAssistedInjectFactoryImp.kt | 2 +- .../io/pleo/prop/objects/MyAssistedInjectFactoryImp2.kt | 2 +- .../kotlin/io/pleo/prop/objects/MyInterfaceProvider.kt | 6 +++--- .../src/test/kotlin/io/pleo/prop/objects/NoPropObject.kt | 2 +- prop-all/src/test/kotlin/io/pleo/prop/objects/NullValue.kt | 4 ++-- .../io/pleo/prop/objects/SamePropertyAsComplexObjects.kt | 4 ++-- .../src/test/kotlin/io/pleo/prop/objects/UnnamedProp.kt | 2 +- .../test/kotlin/io/pleo/prop/objects/UsesTwiceSameProp.kt | 4 ++-- .../io/pleo/prop/guice/internal/PropMappingVisitor.kt | 7 ++++--- 19 files changed, 37 insertions(+), 36 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c2837558..d3c7d432 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,10 +3,10 @@ commonsBeanUtilsVersion = "1.9.4" commonsConfiguration2Version = "2.8.0" googleGuavaVersion = "31.1-jre" googleTruthVersion = "1.1.3" -guiceVersion = "5.1.0" +guiceVersion = "7.0.0" jacksonVersion = "2.14.2" junitVersion = "5.9.3" -kotlinGuiceVersion = "1.6.0" +kotlinGuiceVersion = "3.0.0" kotlinVersion = "1.8.0" kotlinterGradleVersion = "3.13.0" logbackClassicVersion = "1.4.5" diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/BothNamedAnnotations.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/BothNamedAnnotations.kt index 04bbe1a5..da94ad15 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/BothNamedAnnotations.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/BothNamedAnnotations.kt @@ -1,11 +1,11 @@ package io.pleo.prop.objects +import com.google.inject.Inject import io.pleo.prop.core.Prop -import javax.inject.Inject import com.google.inject.name.Named as GoogleNamed -import javax.inject.Named as JavaxNamed +import jakarta.inject.Named as JakartaNamed class BothNamedAnnotations @Inject constructor( - @JavaxNamed("io.pleo.test.prop3") val stringProp1: Prop, + @JakartaNamed("io.pleo.test.prop3") val stringProp1: Prop, @GoogleNamed("io.pleo.test.prop4") val stringProp2: Prop ) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/ComplexObjects.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/ComplexObjects.kt index c776555c..479a3f31 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/ComplexObjects.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/ComplexObjects.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named @Suppress("unused") class ComplexObjects @Inject constructor( diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/CurrencyUnitProp.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/CurrencyUnitProp.kt index 45223eef..dc32094b 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/CurrencyUnitProp.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/CurrencyUnitProp.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named import javax.money.CurrencyUnit @Suppress("unused_parameter") diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/DefaultValue.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/DefaultValue.kt index c335e388..b57a3af4 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/DefaultValue.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/DefaultValue.kt @@ -1,9 +1,9 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Default import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named class DefaultValue @Inject constructor( @Default(DEFAULT_VALUE) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/EmptyNamedAnnotation.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/EmptyNamedAnnotation.kt index f3fbc7fe..fce9889c 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/EmptyNamedAnnotation.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/EmptyNamedAnnotation.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named +import jakarta.inject.Named @Suppress("UNUSED_PARAMETER") class EmptyNamedAnnotation @Inject constructor(@Named myProp: Prop) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/InlineProviderModule.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/InlineProviderModule.kt index 796f61a8..f2b3ea44 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/InlineProviderModule.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/InlineProviderModule.kt @@ -4,8 +4,8 @@ package io.pleo.prop.objects import com.google.inject.AbstractModule import com.google.inject.Provides import com.google.inject.Singleton +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Named @Suppress("unused", "SpellCheckingInspection", "unused_parameter") class InlineProviderModule : AbstractModule() { diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValue.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValue.kt index bf799333..1af3249e 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValue.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValue.kt @@ -1,9 +1,9 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Default import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named @Suppress("unused") class InvalidDefaultValue @Inject constructor( diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValueButValidValue.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValueButValidValue.kt index 69877681..7c801459 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValueButValidValue.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidDefaultValueButValidValue.kt @@ -1,9 +1,9 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Default import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named @Suppress("unused") class InvalidDefaultValueButValidValue @Inject constructor( diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidJSON.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidJSON.kt index 1989db92..db906e99 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidJSON.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/InvalidJSON.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named @Suppress("UNUSED_PARAMETER") class InvalidJSON @Inject constructor(@Named("io.pleo.prop5") objectProp: Prop) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp.kt index 662232ef..f32f88eb 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp.kt @@ -2,8 +2,8 @@ package io.pleo.prop.objects import com.google.inject.Inject import com.google.inject.assistedinject.Assisted +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Named @Suppress("unused") class MyAssistedInjectFactoryImp @Inject constructor( diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp2.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp2.kt index d614e308..2f1a58dc 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp2.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyAssistedInjectFactoryImp2.kt @@ -2,8 +2,8 @@ package io.pleo.prop.objects import com.google.inject.Inject import com.google.inject.assistedinject.Assisted +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Named @Suppress("unused") class MyAssistedInjectFactoryImp2 @Inject constructor( diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyInterfaceProvider.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyInterfaceProvider.kt index 31ec5812..8443dd3a 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/MyInterfaceProvider.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/MyInterfaceProvider.kt @@ -1,9 +1,9 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named -import javax.inject.Provider +import jakarta.inject.Provider class MyInterfaceProvider @Inject constructor( @Named("io.pleo.test.prop3") val prop: Prop diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/NoPropObject.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/NoPropObject.kt index c0bd0db6..cbf37a5e 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/NoPropObject.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/NoPropObject.kt @@ -1,6 +1,6 @@ package io.pleo.prop.objects -import javax.inject.Inject +import com.google.inject.Inject import javax.sql.DataSource class NoPropObject @Inject constructor(val dataSource: DataSource) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/NullValue.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/NullValue.kt index 75833b67..e7be8f6b 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/NullValue.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/NullValue.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named @Suppress("unused_parameter") class NullValue @Inject constructor(@Named("io.pleo.undefined.property") thisThrows: Prop) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/SamePropertyAsComplexObjects.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/SamePropertyAsComplexObjects.kt index 5950674e..69025ca9 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/SamePropertyAsComplexObjects.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/SamePropertyAsComplexObjects.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named class SamePropertyAsComplexObjects @Inject constructor( @Named("io.pleo.test.prop1") val myComplexObjectProp: Prop diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/UnnamedProp.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/UnnamedProp.kt index 8d619ed0..1e305c20 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/UnnamedProp.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/UnnamedProp.kt @@ -1,7 +1,7 @@ package io.pleo.prop.objects +import com.google.inject.Inject import io.pleo.prop.core.Prop -import javax.inject.Inject @Suppress("unused_parameter") class UnnamedProp @Inject constructor(unnamedProp: Prop) diff --git a/prop-all/src/test/kotlin/io/pleo/prop/objects/UsesTwiceSameProp.kt b/prop-all/src/test/kotlin/io/pleo/prop/objects/UsesTwiceSameProp.kt index 062193a7..ade65b35 100644 --- a/prop-all/src/test/kotlin/io/pleo/prop/objects/UsesTwiceSameProp.kt +++ b/prop-all/src/test/kotlin/io/pleo/prop/objects/UsesTwiceSameProp.kt @@ -1,8 +1,8 @@ package io.pleo.prop.objects +import com.google.inject.Inject +import com.google.inject.name.Named import io.pleo.prop.core.Prop -import javax.inject.Inject -import javax.inject.Named class UsesTwiceSameProp @Inject constructor( @Named("io.pleo.test.prop3") val stringProp1: Prop, diff --git a/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt b/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt index 4465f9ef..c406d6c7 100644 --- a/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt +++ b/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt @@ -20,7 +20,8 @@ import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.util.Optional.ofNullable import java.util.function.Predicate -import javax.inject.Named +import com.google.inject.name.Named as JuiceNamed +import jakarta.inject.Named as JakartaNamed typealias PropResult = Result> @@ -127,8 +128,8 @@ class PropMappingVisitor( private fun annotationValueIfNamed(annotation: Annotation): String? = when (annotation) { - is Named -> annotation.value - is com.google.inject.name.Named -> annotation.value + is JakartaNamed -> annotation.value + is JuiceNamed -> annotation.value else -> null }?.ifEmpty { null } } From a5c16f8d528b8d8586add75227ab8139643e8116 Mon Sep 17 00:00:00 2001 From: Erwin Wessels Date: Mon, 29 Jan 2024 19:45:07 +0100 Subject: [PATCH 2/5] Remove centralised-templates github actions --- .github/templates.yaml | 20 -- .../workflows/assign-random-codeowner.yaml | 47 ----- .github/workflows/build-and-test.yaml | 23 -- .github/workflows/codeql-analysis.yaml | 84 -------- .github/workflows/format-kotlin.yaml | 72 ------- .github/workflows/pr-help.yaml | 42 ---- .github/workflows/release.yaml | 5 - .github/workflows/verify-release.yaml | 198 ------------------ gradle.properties | 2 +- 9 files changed, 1 insertion(+), 492 deletions(-) delete mode 100644 .github/templates.yaml delete mode 100644 .github/workflows/assign-random-codeowner.yaml delete mode 100644 .github/workflows/codeql-analysis.yaml delete mode 100644 .github/workflows/format-kotlin.yaml delete mode 100644 .github/workflows/pr-help.yaml delete mode 100644 .github/workflows/verify-release.yaml diff --git a/.github/templates.yaml b/.github/templates.yaml deleted file mode 100644 index dbbc438e..00000000 --- a/.github/templates.yaml +++ /dev/null @@ -1,20 +0,0 @@ -version: v32.0.1 - -files: - - .github/.kodiak.toml - - .github/workflows/format-kotlin.yaml - - .github/workflows/release.yaml - - .github/workflows/verify-release.yaml - - .autorc.json - - .github/workflows/pr-help.yaml - - .github/workflows/assign-random-codeowner.yaml - - .github/workflows/build-and-test.yaml - - .github/workflows/codeql-analysis.yaml - -values: - autoRelease: true - allowKodiakAutoMerge: true - defaultBranch: main - sendOpsLevelDeployNotifications: true - sendOpsLevelVulnerabilityCheck: true - deploymentEnabled: false diff --git a/.github/workflows/assign-random-codeowner.yaml b/.github/workflows/assign-random-codeowner.yaml deleted file mode 100644 index 67939add..00000000 --- a/.github/workflows/assign-random-codeowner.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - -name: Assign Random CODEOWNERS - -on: - pull_request: - types: - - review_requested - - ready_for_review - - opened - -concurrency: - group: ci-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - assign-codeowners: - name: Assign CODEOWNERS - timeout-minutes: 5 - if: github.event.pull_request.draft == false - runs-on: ubuntu-latest - - steps: - # Checkout the repository in order to detect and parse CODEOWNERS - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - # Elevate token permissions to allow assigning people to PRs - - name: Allow assigning reviewers - id: get-assigning-token - uses: peter-murray/workflow-application-token-action@v2 - with: - application_id: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_APP_ID }} - application_private_key: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_PRIVATE_KEY }} - - # Assign random CODEOWNERS unless reviewers have been assigned manually - - name: Assign CODEOWNERS - uses: pleo-io/assign-random-codeowners@v0.3.27 - with: - reviewers-to-assign: 2 - assign-from-changed-files: true - assign-individuals-from-teams: true - env: - GITHUB_TOKEN: ${{ steps.get-assigning-token.outputs.token }} diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 9a682ced..a89dc984 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -1,8 +1,3 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - name: Build & Test Kotlin on: push @@ -128,24 +123,6 @@ jobs: check_name: Unit Tests report report_paths: "**/build/test-results/test/TEST-*.xml" - # Run Detekt - - name: Run Detekt - continue-on-error: true - if: ${{ github.ref == 'refs/heads/main' }} - run: ./gradlew detekt --stacktrace - env: - GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} - - # Publish Detekt results to GitHub. - - name: Publish Detekt SARIF report to GitHub - continue-on-error: true - if: ${{ github.ref == 'refs/heads/main' }} - uses: github/codeql-action/upload-sarif@v2 - with: - sarif_file: build/reports/detekt/detekt.sarif - - name: Trigger release if: ${{ github.ref == 'refs/heads/main' }} uses: peter-evans/repository-dispatch@v2 diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml deleted file mode 100644 index b7d2fd3f..00000000 --- a/.github/workflows/codeql-analysis.yaml +++ /dev/null @@ -1,84 +0,0 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/security - -name: CodeQL Analysis - -on: - push: - branches: - - main - pull_request: - branches: - - main - -env: - language_Kotlin: "java" - language_Java: "java" - language_Go: "go" - language_Python: "python" - language_JavaScript: "javascript" - language_TypeScript: "javascript" - WORKING_LANGUAGE: "" - -jobs: - analyze-java: - name: Analyze ${{ github.event.repository.language }} - continue-on-error: true - runs-on: codeql-runner - timeout-minutes: 30 - permissions: - actions: read - contents: read - security-events: write - steps: - - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - name: Set Working Language - run: echo "WORKING_LANGUAGE=${{env[format('language_{0}', github.event.repository.language)]}}" >> "$GITHUB_ENV" - # Set up a JDK environment for building, testing and releasing. - - name: Set up JDK 17 - uses: actions/setup-java@v3.13.0 - if: ${{ env.WORKING_LANGUAGE == 'java' }} - with: - java-version: 17 - distribution: temurin - - # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. - - name: Setup Gradle - uses: gradle/gradle-build-action@v2.10.0 - if: ${{ env.WORKING_LANGUAGE == 'java' }} - with: - gradle-executable: ./gradlew - gradle-version: wrapper - cache-read-only: true - - # Set up a Node environment for JS/TS/Node client generation. - - name: Set up Node 20 - uses: actions/setup-node@v4 - if: ${{ env.WORKING_LANGUAGE == 'javascript' }} - with: - node-version: 20 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ github.event.repository.language }} - ram: 4096 - queries: security-and-quality - tools: latest - - - name: Gradle Build - run: ./gradlew classes testClasses --stacktrace -Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.parallel=true - if: ${{ env.WORKING_LANGUAGE == 'java' }} - env: - GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - ram: 4096 diff --git a/.github/workflows/format-kotlin.yaml b/.github/workflows/format-kotlin.yaml deleted file mode 100644 index d885451e..00000000 --- a/.github/workflows/format-kotlin.yaml +++ /dev/null @@ -1,72 +0,0 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - -name: Format Kotlin -on: - push: - branches-ignore: - - main - - master - - "depencencies/**" - pull_request: - branches: - - main - - master - -concurrency: - group: ci-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - format: - name: Format Kotlin - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - # Generate temporary token for allowing CI to run on the formatted files. - - name: Generate temporary CI token - id: get-admin-token - uses: peter-murray/workflow-application-token-action@v2 - with: - application_id: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_APP_ID }} - application_private_key: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_PRIVATE_KEY }} - - # Checkout code with push privileges. - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - token: ${{ steps.get-admin-token.outputs.token }} - - # Set up a JDK environment for building, testing and releasing. - - name: Set up JDK 17 - uses: actions/setup-java@v3.13.0 - with: - java-version: 17 - distribution: temurin - - # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. - - name: Setup Gradle - uses: gradle/gradle-build-action@v2.10.0 - with: - gradle-executable: ./gradlew - gradle-version: wrapper - cache-read-only: true - - # Format code via the formatkotlin Gradle task. - - name: Format files - run: | - ./gradlew formatkotlin - env: - GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} - - # Add and commit any formatted files. - - name: Add formatted files - uses: EndBug/add-and-commit@v9.1.3 - with: - author_name: github-actions[bot] - author_email: github-actions@pleo.io - message: Format Kotlin - commit: --no-verify diff --git a/.github/workflows/pr-help.yaml b/.github/workflows/pr-help.yaml deleted file mode 100644 index 17753ea0..00000000 --- a/.github/workflows/pr-help.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - -name: Check PR -on: - pull_request: - types: - - assigned - - unassigned - - labeled - - unlabeled - - opened - - edited - - closed - - reopened - - synchronize - - ready_for_review - - locked - - unlocked - - review_requested - - review_request_removed - -concurrency: - group: ci-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - autoApproveEnabled: true - -jobs: - auto-approve-pr: - runs-on: ubuntu-latest - name: Auto-approve PR - if: ${{ github.actor == 'pleo-bot-renovate' && contains(github.event.pull_request.labels.*.name, 'autoapprove') }} - steps: - - uses: hmarr/auto-approve-action@v3 - if: env.autoApproveEnabled == 'true' - with: - github-token: ${{ secrets.PLEO_BOT_AUTO_APPROVER_TOKEN }} - review-message: "This has been auto-approved by @pleo-bot-auto-approver. If your PR isn't being auto-merged as desired, make sure to add @pleo-bot-auto-approver to the CODEOWNERS file. More details how to use Renovate [here](https://www.notion.so/pleo/How-to-use-Renovate-781e4861200744c6b38d3efd8c6d525a?pvs=4)" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6aab9a36..2788a05b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,3 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - name: Release # This workflow # - calculates the version number to release diff --git a/.github/workflows/verify-release.yaml b/.github/workflows/verify-release.yaml deleted file mode 100644 index 51f46b3f..00000000 --- a/.github/workflows/verify-release.yaml +++ /dev/null @@ -1,198 +0,0 @@ -# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY -# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: -# - centralized-templates -# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver - -name: Verify Release -# This verifies that a given PR has the required labels before merge into the default branch. -on: - pull_request: - types: - - opened - - edited - - labeled - - unlabeled - - synchronize - - ready_for_review - -jobs: - auto-version-pr: - name: Detect OpenAPI changes - if: ${{ (github.event.repository.language == 'Kotlin' || github.event.repository.language == 'Java') && github.event.pull_request.draft == false && false && github.event.action != 'unlabeled' }} - runs-on: ubuntu-latest - timeout-minutes: 30 - concurrency: ci-${{ github.workflow }}-${{ github.ref }} - steps: - # Caches openapi docs - - name: Caches generated openapi docs - id: cache-docs - uses: actions/cache@v3 - with: - path: | - generated.yaml - existing.yaml - key: OpenApiDocs-${{ github.workflow }}-${{ github.sha }} - - # Checkout the default branch - - name: Checkout '${{ github.event.repository.default_branch }}' - if: steps.cache-docs.outputs.cache-hit != 'true' - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - ref: ${{ github.event.repository.default_branch }} - - # Set up a JDK environment for building, testing and releasing. - - name: Setup JDK 17 - if: steps.cache-docs.outputs.cache-hit != 'true' - uses: actions/setup-java@v3.13.0 - with: - java-version: 17 - distribution: temurin - - # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. - - name: Setup Gradle - if: steps.cache-docs.outputs.cache-hit != 'true' - uses: gradle/gradle-build-action@v2.10.0 - with: - gradle-executable: ./gradlew - gradle-version: wrapper - gradle-home-cache-cleanup: true - cache-read-only: true - - # Generate the '${{ github.event.repository.default_branch }}' OpenAPI definition. - - name: Generate '${{ github.event.repository.default_branch }}' OpenAPI spec - if: steps.cache-docs.outputs.cache-hit != 'true' - run: | - ./gradlew pleo-"$REPOSITORY_NAME"-rest:resolve --stacktrace - env: - GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - REPOSITORY_NAME: ${{ github.event.repository.name }} - JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} - - - name: Move OpenAPI schema - if: steps.cache-docs.outputs.cache-hit != 'true' - run: | - echo "Using OpenAPI spec path: 'pleo-$REPOSITORY_NAME-rest'" - FILE_PATH="$(find "pleo-$REPOSITORY_NAME-rest" -type f -name "$REPOSITORY_NAME-openapi.yaml" -not -path "pleo-$REPOSITORY_NAME-rest/build/*")" - mv "$FILE_PATH" "$NEW_PATH" - env: - REPOSITORY_NAME: ${{ github.event.repository.name }} - NEW_PATH: existing.yaml - - - name: Checkout HEAD - if: steps.cache-docs.outputs.cache-hit != 'true' - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - with: - ref: ${{ env.GITHUB_SHA }} - clean: false - - # Generate modified OpenAPI definition from changes. - - name: Generate 'HEAD' OpenAPI spec - if: steps.cache-docs.outputs.cache-hit != 'true' - run: | - ./gradlew pleo-"$REPOSITORY_NAME"-rest:resolve --stacktrace - env: - GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} - REPOSITORY_NAME: ${{ github.event.repository.name }} - JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} - - - name: Move OpenAPI schema - if: steps.cache-docs.outputs.cache-hit != 'true' - run: | - echo "Using OpenAPI spec path: 'pleo-$REPOSITORY_NAME-rest'" - FILE_PATH="$(find "pleo-$REPOSITORY_NAME-rest" -type f -name "$REPOSITORY_NAME-openapi.yaml" -not -path "pleo-$REPOSITORY_NAME-rest/build/*")" - mv "$FILE_PATH" "$NEW_PATH" - env: - REPOSITORY_NAME: ${{ github.event.repository.name }} - NEW_PATH: generated.yaml - - - name: Show spec contents - run: | - echo "::group::existing.yaml" - cat existing.yaml - echo "::group::generated.yaml" - cat generated.yaml - - # Install OpenAPI diff tools. - - name: Install 'openapi-diff' - run: | - npm install openapi-diff yaml - - # Diff OpenAPI specs. - - name: Diff OpenAPI specs - id: openapi-diff - uses: actions/github-script@v7 - continue-on-error: true - with: - result-encoding: string - script: | - const fs = require('fs/promises') - const yaml = require('yaml') - const openapiDiff = require('openapi-diff') - const [existingContents, generatedContents] = await Promise.all([fs.readFile('existing.yaml', 'utf-8'), fs.readFile('generated.yaml', 'utf-8')]) - const [existing, generated] = [yaml.parse(existingContents), yaml.parse(generatedContents)] - const {breakingDifferencesFound, nonBreakingDifferences} = await openapiDiff.diffSpecs({ - sourceSpec: { content: JSON.stringify(existing), location: 'existing.yaml', format: 'openapi3' }, - destinationSpec: { content: JSON.stringify(generated), location: 'generated.yaml', format: 'openapi3' } - }) - core.info(`Saw breaking differences: ${breakingDifferencesFound}`) - core.info(`Saw non-breaking differences: ${JSON.stringify(nonBreakingDifferences)}`) - if (breakingDifferencesFound) { - core.info('Detected breaking changes (major).') - return 'major' - } - if (nonBreakingDifferences.length > 0) { - core.info('Detected non-breaking changes (minor).') - return 'minor' - } - core.info('Detected no changes (unknown).') - return 'unknown' - - - name: Get all PR labels - id: pr-labels - uses: joerick/pr-labels-action@v1.0.9 - - - name: Add labels for unlabelled PRs - if: ${{ steps.pr-labels.outputs.labels == '' && (steps.openapi-diff.outputs.result != 'unknown' || steps.openapi-diff.outputs.result != '') }} - uses: actions-ecosystem/action-add-labels@v1 - with: - labels: ${{ steps.openapi-diff.outputs.result }} - - - name: Add 'minor' label for non-breaking changes - if: contains(steps.pr-labels.outputs.labels, 'minor') != true && steps.openapi-diff.outputs.result == 'minor' - uses: actions-ecosystem/action-add-labels@v1 - with: - labels: ${{ steps.openapi-diff.outputs.result }} - - - name: Add 'major' label for breaking changes - if: contains(steps.pr-labels.outputs.labels, 'major') != true && steps.openapi-diff.outputs.result == 'major' - uses: actions-ecosystem/action-add-labels@v1 - with: - labels: ${{ steps.openapi-diff.outputs.result }} - - verify-release: - name: Verify Release - runs-on: ubuntu-latest - needs: auto-version-pr - timeout-minutes: 10 - if: always() - steps: - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - # Allow Renovate to pass this check on checks on branches where a PR isn't present yet. - - name: Determine author - id: determine_author - run: | - AUTHOR="$(git log -1 --pretty=format:'%an' | xargs -0)" - echo "$AUTHOR" - echo "author=$AUTHOR" >> "$GITHUB_OUTPUT" - - - name: Verify PR labels - id: verify_pr_labels - if: steps.determine_author.outputs.author != 'Renovate (Pleo)' - uses: docker://agilepathway/pull-request-label-checker:latest - with: - any_of: major,minor,patch,internal - repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/gradle.properties b/gradle.properties index 61101f3a..b910be52 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ #Thu Feb 02 09:01:06 UTC 2023 -version=6.0.28 +version=6.0.29-test From 93f80c0837751e46104a2ad36f4503ed9d7133ae Mon Sep 17 00:00:00 2001 From: Erwin Wessels Date: Mon, 29 Jan 2024 19:49:33 +0100 Subject: [PATCH 3/5] Do not push test release version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b910be52..61101f3a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ #Thu Feb 02 09:01:06 UTC 2023 -version=6.0.29-test +version=6.0.28 From c9ed2e881c60b8863c9a117b71f9f8705272b0cc Mon Sep 17 00:00:00 2001 From: Erwin Wessels Date: Tue, 30 Jan 2024 11:29:50 +0100 Subject: [PATCH 4/5] Revert "Remove centralised-templates github actions" This reverts commit a5c16f8d528b8d8586add75227ab8139643e8116. --- .github/templates.yaml | 20 ++ .../workflows/assign-random-codeowner.yaml | 47 +++++ .github/workflows/build-and-test.yaml | 23 ++ .github/workflows/codeql-analysis.yaml | 84 ++++++++ .github/workflows/format-kotlin.yaml | 72 +++++++ .github/workflows/pr-help.yaml | 42 ++++ .github/workflows/release.yaml | 5 + .github/workflows/verify-release.yaml | 198 ++++++++++++++++++ 8 files changed, 491 insertions(+) create mode 100644 .github/templates.yaml create mode 100644 .github/workflows/assign-random-codeowner.yaml create mode 100644 .github/workflows/codeql-analysis.yaml create mode 100644 .github/workflows/format-kotlin.yaml create mode 100644 .github/workflows/pr-help.yaml create mode 100644 .github/workflows/verify-release.yaml diff --git a/.github/templates.yaml b/.github/templates.yaml new file mode 100644 index 00000000..dbbc438e --- /dev/null +++ b/.github/templates.yaml @@ -0,0 +1,20 @@ +version: v32.0.1 + +files: + - .github/.kodiak.toml + - .github/workflows/format-kotlin.yaml + - .github/workflows/release.yaml + - .github/workflows/verify-release.yaml + - .autorc.json + - .github/workflows/pr-help.yaml + - .github/workflows/assign-random-codeowner.yaml + - .github/workflows/build-and-test.yaml + - .github/workflows/codeql-analysis.yaml + +values: + autoRelease: true + allowKodiakAutoMerge: true + defaultBranch: main + sendOpsLevelDeployNotifications: true + sendOpsLevelVulnerabilityCheck: true + deploymentEnabled: false diff --git a/.github/workflows/assign-random-codeowner.yaml b/.github/workflows/assign-random-codeowner.yaml new file mode 100644 index 00000000..67939add --- /dev/null +++ b/.github/workflows/assign-random-codeowner.yaml @@ -0,0 +1,47 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + +name: Assign Random CODEOWNERS + +on: + pull_request: + types: + - review_requested + - ready_for_review + - opened + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + assign-codeowners: + name: Assign CODEOWNERS + timeout-minutes: 5 + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + + steps: + # Checkout the repository in order to detect and parse CODEOWNERS + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + # Elevate token permissions to allow assigning people to PRs + - name: Allow assigning reviewers + id: get-assigning-token + uses: peter-murray/workflow-application-token-action@v2 + with: + application_id: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_APP_ID }} + application_private_key: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_PRIVATE_KEY }} + + # Assign random CODEOWNERS unless reviewers have been assigned manually + - name: Assign CODEOWNERS + uses: pleo-io/assign-random-codeowners@v0.3.27 + with: + reviewers-to-assign: 2 + assign-from-changed-files: true + assign-individuals-from-teams: true + env: + GITHUB_TOKEN: ${{ steps.get-assigning-token.outputs.token }} diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index a89dc984..9a682ced 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -1,3 +1,8 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + name: Build & Test Kotlin on: push @@ -123,6 +128,24 @@ jobs: check_name: Unit Tests report report_paths: "**/build/test-results/test/TEST-*.xml" + # Run Detekt + - name: Run Detekt + continue-on-error: true + if: ${{ github.ref == 'refs/heads/main' }} + run: ./gradlew detekt --stacktrace + env: + GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} + + # Publish Detekt results to GitHub. + - name: Publish Detekt SARIF report to GitHub + continue-on-error: true + if: ${{ github.ref == 'refs/heads/main' }} + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: build/reports/detekt/detekt.sarif + - name: Trigger release if: ${{ github.ref == 'refs/heads/main' }} uses: peter-evans/repository-dispatch@v2 diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml new file mode 100644 index 00000000..b7d2fd3f --- /dev/null +++ b/.github/workflows/codeql-analysis.yaml @@ -0,0 +1,84 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/security + +name: CodeQL Analysis + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + language_Kotlin: "java" + language_Java: "java" + language_Go: "go" + language_Python: "python" + language_JavaScript: "javascript" + language_TypeScript: "javascript" + WORKING_LANGUAGE: "" + +jobs: + analyze-java: + name: Analyze ${{ github.event.repository.language }} + continue-on-error: true + runs-on: codeql-runner + timeout-minutes: 30 + permissions: + actions: read + contents: read + security-events: write + steps: + - name: Checkout repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - name: Set Working Language + run: echo "WORKING_LANGUAGE=${{env[format('language_{0}', github.event.repository.language)]}}" >> "$GITHUB_ENV" + # Set up a JDK environment for building, testing and releasing. + - name: Set up JDK 17 + uses: actions/setup-java@v3.13.0 + if: ${{ env.WORKING_LANGUAGE == 'java' }} + with: + java-version: 17 + distribution: temurin + + # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.10.0 + if: ${{ env.WORKING_LANGUAGE == 'java' }} + with: + gradle-executable: ./gradlew + gradle-version: wrapper + cache-read-only: true + + # Set up a Node environment for JS/TS/Node client generation. + - name: Set up Node 20 + uses: actions/setup-node@v4 + if: ${{ env.WORKING_LANGUAGE == 'javascript' }} + with: + node-version: 20 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ github.event.repository.language }} + ram: 4096 + queries: security-and-quality + tools: latest + + - name: Gradle Build + run: ./gradlew classes testClasses --stacktrace -Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.parallel=true + if: ${{ env.WORKING_LANGUAGE == 'java' }} + env: + GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + ram: 4096 diff --git a/.github/workflows/format-kotlin.yaml b/.github/workflows/format-kotlin.yaml new file mode 100644 index 00000000..d885451e --- /dev/null +++ b/.github/workflows/format-kotlin.yaml @@ -0,0 +1,72 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + +name: Format Kotlin +on: + push: + branches-ignore: + - main + - master + - "depencencies/**" + pull_request: + branches: + - main + - master + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + format: + name: Format Kotlin + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + # Generate temporary token for allowing CI to run on the formatted files. + - name: Generate temporary CI token + id: get-admin-token + uses: peter-murray/workflow-application-token-action@v2 + with: + application_id: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_APP_ID }} + application_private_key: ${{ secrets.PLEO_GH_APP_TOKEN_SIGNER_PRIVATE_KEY }} + + # Checkout code with push privileges. + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + token: ${{ steps.get-admin-token.outputs.token }} + + # Set up a JDK environment for building, testing and releasing. + - name: Set up JDK 17 + uses: actions/setup-java@v3.13.0 + with: + java-version: 17 + distribution: temurin + + # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.10.0 + with: + gradle-executable: ./gradlew + gradle-version: wrapper + cache-read-only: true + + # Format code via the formatkotlin Gradle task. + - name: Format files + run: | + ./gradlew formatkotlin + env: + GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} + + # Add and commit any formatted files. + - name: Add formatted files + uses: EndBug/add-and-commit@v9.1.3 + with: + author_name: github-actions[bot] + author_email: github-actions@pleo.io + message: Format Kotlin + commit: --no-verify diff --git a/.github/workflows/pr-help.yaml b/.github/workflows/pr-help.yaml new file mode 100644 index 00000000..17753ea0 --- /dev/null +++ b/.github/workflows/pr-help.yaml @@ -0,0 +1,42 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + +name: Check PR +on: + pull_request: + types: + - assigned + - unassigned + - labeled + - unlabeled + - opened + - edited + - closed + - reopened + - synchronize + - ready_for_review + - locked + - unlocked + - review_requested + - review_request_removed + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + autoApproveEnabled: true + +jobs: + auto-approve-pr: + runs-on: ubuntu-latest + name: Auto-approve PR + if: ${{ github.actor == 'pleo-bot-renovate' && contains(github.event.pull_request.labels.*.name, 'autoapprove') }} + steps: + - uses: hmarr/auto-approve-action@v3 + if: env.autoApproveEnabled == 'true' + with: + github-token: ${{ secrets.PLEO_BOT_AUTO_APPROVER_TOKEN }} + review-message: "This has been auto-approved by @pleo-bot-auto-approver. If your PR isn't being auto-merged as desired, make sure to add @pleo-bot-auto-approver to the CODEOWNERS file. More details how to use Renovate [here](https://www.notion.so/pleo/How-to-use-Renovate-781e4861200744c6b38d3efd8c6d525a?pvs=4)" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2788a05b..6aab9a36 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,3 +1,8 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + name: Release # This workflow # - calculates the version number to release diff --git a/.github/workflows/verify-release.yaml b/.github/workflows/verify-release.yaml new file mode 100644 index 00000000..51f46b3f --- /dev/null +++ b/.github/workflows/verify-release.yaml @@ -0,0 +1,198 @@ +# THIS CODE WAS AUTOGENERATED. DO NOT MODIFY THIS FILE DIRECTLY +# THE SOURCE CODE LIVES IN A DIFFERENT REPOSITORY: +# - centralized-templates +# FILE STEWARD: @pleo-io/devx,@pleo-bot-auto-approver + +name: Verify Release +# This verifies that a given PR has the required labels before merge into the default branch. +on: + pull_request: + types: + - opened + - edited + - labeled + - unlabeled + - synchronize + - ready_for_review + +jobs: + auto-version-pr: + name: Detect OpenAPI changes + if: ${{ (github.event.repository.language == 'Kotlin' || github.event.repository.language == 'Java') && github.event.pull_request.draft == false && false && github.event.action != 'unlabeled' }} + runs-on: ubuntu-latest + timeout-minutes: 30 + concurrency: ci-${{ github.workflow }}-${{ github.ref }} + steps: + # Caches openapi docs + - name: Caches generated openapi docs + id: cache-docs + uses: actions/cache@v3 + with: + path: | + generated.yaml + existing.yaml + key: OpenApiDocs-${{ github.workflow }}-${{ github.sha }} + + # Checkout the default branch + - name: Checkout '${{ github.event.repository.default_branch }}' + if: steps.cache-docs.outputs.cache-hit != 'true' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + ref: ${{ github.event.repository.default_branch }} + + # Set up a JDK environment for building, testing and releasing. + - name: Setup JDK 17 + if: steps.cache-docs.outputs.cache-hit != 'true' + uses: actions/setup-java@v3.13.0 + with: + java-version: 17 + distribution: temurin + + # Allow caching Gradle executions to further speed up CI/CD steps invoking Gradle. + - name: Setup Gradle + if: steps.cache-docs.outputs.cache-hit != 'true' + uses: gradle/gradle-build-action@v2.10.0 + with: + gradle-executable: ./gradlew + gradle-version: wrapper + gradle-home-cache-cleanup: true + cache-read-only: true + + # Generate the '${{ github.event.repository.default_branch }}' OpenAPI definition. + - name: Generate '${{ github.event.repository.default_branch }}' OpenAPI spec + if: steps.cache-docs.outputs.cache-hit != 'true' + run: | + ./gradlew pleo-"$REPOSITORY_NAME"-rest:resolve --stacktrace + env: + GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + REPOSITORY_NAME: ${{ github.event.repository.name }} + JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} + + - name: Move OpenAPI schema + if: steps.cache-docs.outputs.cache-hit != 'true' + run: | + echo "Using OpenAPI spec path: 'pleo-$REPOSITORY_NAME-rest'" + FILE_PATH="$(find "pleo-$REPOSITORY_NAME-rest" -type f -name "$REPOSITORY_NAME-openapi.yaml" -not -path "pleo-$REPOSITORY_NAME-rest/build/*")" + mv "$FILE_PATH" "$NEW_PATH" + env: + REPOSITORY_NAME: ${{ github.event.repository.name }} + NEW_PATH: existing.yaml + + - name: Checkout HEAD + if: steps.cache-docs.outputs.cache-hit != 'true' + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + with: + ref: ${{ env.GITHUB_SHA }} + clean: false + + # Generate modified OpenAPI definition from changes. + - name: Generate 'HEAD' OpenAPI spec + if: steps.cache-docs.outputs.cache-hit != 'true' + run: | + ./gradlew pleo-"$REPOSITORY_NAME"-rest:resolve --stacktrace + env: + GITHUB_TOKEN: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + GRADLE_READ_KEY: ${{ secrets.GH_REGISTRY_GRADLE_TOKEN }} + REPOSITORY_NAME: ${{ github.event.repository.name }} + JOB_RUNR_REPO_PASSWORD: ${{ secrets.JOB_RUNR_REPO_PASSWORD }} + + - name: Move OpenAPI schema + if: steps.cache-docs.outputs.cache-hit != 'true' + run: | + echo "Using OpenAPI spec path: 'pleo-$REPOSITORY_NAME-rest'" + FILE_PATH="$(find "pleo-$REPOSITORY_NAME-rest" -type f -name "$REPOSITORY_NAME-openapi.yaml" -not -path "pleo-$REPOSITORY_NAME-rest/build/*")" + mv "$FILE_PATH" "$NEW_PATH" + env: + REPOSITORY_NAME: ${{ github.event.repository.name }} + NEW_PATH: generated.yaml + + - name: Show spec contents + run: | + echo "::group::existing.yaml" + cat existing.yaml + echo "::group::generated.yaml" + cat generated.yaml + + # Install OpenAPI diff tools. + - name: Install 'openapi-diff' + run: | + npm install openapi-diff yaml + + # Diff OpenAPI specs. + - name: Diff OpenAPI specs + id: openapi-diff + uses: actions/github-script@v7 + continue-on-error: true + with: + result-encoding: string + script: | + const fs = require('fs/promises') + const yaml = require('yaml') + const openapiDiff = require('openapi-diff') + const [existingContents, generatedContents] = await Promise.all([fs.readFile('existing.yaml', 'utf-8'), fs.readFile('generated.yaml', 'utf-8')]) + const [existing, generated] = [yaml.parse(existingContents), yaml.parse(generatedContents)] + const {breakingDifferencesFound, nonBreakingDifferences} = await openapiDiff.diffSpecs({ + sourceSpec: { content: JSON.stringify(existing), location: 'existing.yaml', format: 'openapi3' }, + destinationSpec: { content: JSON.stringify(generated), location: 'generated.yaml', format: 'openapi3' } + }) + core.info(`Saw breaking differences: ${breakingDifferencesFound}`) + core.info(`Saw non-breaking differences: ${JSON.stringify(nonBreakingDifferences)}`) + if (breakingDifferencesFound) { + core.info('Detected breaking changes (major).') + return 'major' + } + if (nonBreakingDifferences.length > 0) { + core.info('Detected non-breaking changes (minor).') + return 'minor' + } + core.info('Detected no changes (unknown).') + return 'unknown' + + - name: Get all PR labels + id: pr-labels + uses: joerick/pr-labels-action@v1.0.9 + + - name: Add labels for unlabelled PRs + if: ${{ steps.pr-labels.outputs.labels == '' && (steps.openapi-diff.outputs.result != 'unknown' || steps.openapi-diff.outputs.result != '') }} + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ steps.openapi-diff.outputs.result }} + + - name: Add 'minor' label for non-breaking changes + if: contains(steps.pr-labels.outputs.labels, 'minor') != true && steps.openapi-diff.outputs.result == 'minor' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ steps.openapi-diff.outputs.result }} + + - name: Add 'major' label for breaking changes + if: contains(steps.pr-labels.outputs.labels, 'major') != true && steps.openapi-diff.outputs.result == 'major' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ steps.openapi-diff.outputs.result }} + + verify-release: + name: Verify Release + runs-on: ubuntu-latest + needs: auto-version-pr + timeout-minutes: 10 + if: always() + steps: + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + # Allow Renovate to pass this check on checks on branches where a PR isn't present yet. + - name: Determine author + id: determine_author + run: | + AUTHOR="$(git log -1 --pretty=format:'%an' | xargs -0)" + echo "$AUTHOR" + echo "author=$AUTHOR" >> "$GITHUB_OUTPUT" + + - name: Verify PR labels + id: verify_pr_labels + if: steps.determine_author.outputs.author != 'Renovate (Pleo)' + uses: docker://agilepathway/pull-request-label-checker:latest + with: + any_of: major,minor,patch,internal + repo_token: ${{ secrets.GITHUB_TOKEN }} From 96f0d249dc1ea42f6138ed737612ccd948a5312f Mon Sep 17 00:00:00 2001 From: Erwin Wessels Date: Fri, 2 Feb 2024 10:55:19 +0100 Subject: [PATCH 5/5] PR feedback: consistency fix --- .../kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt b/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt index 197af228..a88af3cb 100644 --- a/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt +++ b/prop-guice/src/main/kotlin/io/pleo/prop/guice/internal/PropMappingVisitor.kt @@ -20,7 +20,7 @@ import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.util.Optional.ofNullable import java.util.function.Predicate -import com.google.inject.name.Named as JuiceNamed +import com.google.inject.name.Named as GoogleNamed import jakarta.inject.Named as JakartaNamed typealias PropResult = Result> @@ -136,7 +136,7 @@ class PropMappingVisitor( private fun annotationValueIfNamed(annotation: Annotation): String? = when (annotation) { is JakartaNamed -> annotation.value - is JuiceNamed -> annotation.value + is GoogleNamed -> annotation.value else -> null }?.ifEmpty { null } }